Commit Graph

225 Commits

Author SHA1 Message Date
Joseph Doherty 7c324843ff feat: add per-client trace mode flag with dynamic parser logger 2026-02-23 04:26:15 -05:00
Joseph Doherty cd87a48343 feat: add Windows Service integration via --service flag
Adds Microsoft.Extensions.Hosting.WindowsServices package and a --service
CLI flag to Program.cs that logs service mode activation, enabling future
Windows Service lifecycle management.
2026-02-23 04:26:04 -05:00
Joseph Doherty f952e6afab feat: add new NatsOptions fields for Go config parity
Adds 10 new fields to NatsOptions (ClientAdvertise, TraceVerbose, MaxTracedMsgLen,
DisableSublistCache, ConnectErrorReports, ReconnectErrorReports, NoHeaderSupport,
MaxClosedClients, NoSystemAccount, SystemAccount) plus InCmdLine tracking set.
Moves MaxClosedClients from a private constant in NatsServer to a configurable option.
2026-02-23 04:23:27 -05:00
Joseph Doherty f316e6e86e feat: add OcspMode enum, OcspConfig class, and wire into NatsOptions
Introduces NATS.Server.Tls.OcspMode (Auto/Always/Must/Never matching
Go ocsp.go constants) and OcspConfig with Mode and OverrideUrls. Adds
OcspConfig? and OcspPeerVerify to NatsOptions for stapling configuration
and peer certificate revocation checking. Covered by 12 new unit tests.
2026-02-23 04:23:14 -05:00
Joseph Doherty c8b347cb96 feat: implement IAccountResolver interface and MemAccountResolver
Adds the IAccountResolver interface (FetchAsync, StoreAsync, IsReadOnly)
and a MemAccountResolver backed by ConcurrentDictionary for in-memory
JWT storage in tests and simple operator deployments.

Reference: golang/nats-server/server/accounts.go:4035+
2026-02-23 04:22:36 -05:00
Joseph Doherty 9fff5709c4 feat: add NATS config file lexer (port of Go conf/lex.go)
Port the NATS configuration file lexer from Go's conf/lex.go to C#.
The lexer is a state-machine tokenizer that supports the NATS config
format: key-value pairs with =, :, or whitespace separators; nested
maps {}; arrays []; single and double quoted strings with escape
sequences; block strings (); variables $VAR; include directives;
comments (# and //); booleans; integers with size suffixes (kb, mb, gb);
floats; ISO8601 datetimes; and IP addresses.
2026-02-23 04:20:56 -05:00
Joseph Doherty 9f88b034eb docs: add implementation plan for remaining lower-priority gaps
14-task plan covering JWT auth (4 tasks), subject transforms (2 tasks),
OCSP support (2 tasks), and quick wins (5 tasks) + differences.md update.
Includes parallelization guide, TDD steps, and task persistence.
2026-02-23 04:20:24 -05:00
Joseph Doherty 30ae67f613 docs: add WebSocket support design document
Full port design for WebSocket connections from Go NATS server,
including HTTP upgrade handshake, custom frame parser, compression,
origin checking, and cookie-based auth.
2026-02-23 04:17:56 -05:00
Joseph Doherty f533bf0945 docs: add design document for remaining lower-priority gaps
Covers JWT authentication, subject mapping/transforms, OCSP support,
Windows Service integration, per-subsystem logging, per-client trace,
per-account stats, and TLS cert expiry in /varz.
2026-02-23 04:12:45 -05:00
Joseph Doherty fadbbf463c docs: add detailed implementation plan for config parsing and hot reload
8 tasks with TDD steps, complete test code, exact file paths,
and dependency chain from lexer through to verification.
2026-02-23 04:12:11 -05:00
Joseph Doherty 65fac32a14 docs: add config parsing and hot reload design document
Captures the design for resolving the two remaining high-priority gaps
in differences.md: config file parsing and SIGHUP hot reload.
2026-02-23 04:06:16 -05:00
Joseph Doherty cc5ce63cb9 Merge branch 'feature/sections-7-10-gaps' into main 2026-02-23 03:34:00 -05:00
Joseph Doherty 56de543713 docs: update differences.md sections 7-10 to reflect implemented features 2026-02-23 01:08:34 -05:00
Joseph Doherty 42c7c9cb7a docs: update differences.md sections 3-6 and 9 to reflect implemented features
Update comparison tables for protocol parsing (tracing, MIME headers, INFO caching,
Span-based MSG), subscriptions (generation ID, Stats, SubjectsCollide, token utils,
account limits), auth (deny enforcement, LRU cache, response permissions, auth expiry),
configuration (CLI flags, MaxSubs, Tags, file logging), and logging (trace/debug modes,
file output). Mark 11 summary items as resolved.
2026-02-23 01:07:14 -05:00
Joseph Doherty 8878301c7f test: add file logging and rotation tests 2026-02-23 01:05:10 -05:00
Joseph Doherty e31ba04fdb feat: add closed connection tracking, state filtering, ByStop/ByReason sorting 2026-02-23 01:01:56 -05:00
Joseph Doherty dab8004d6b feat: cache INFO serialization — build once at startup instead of per-connection
Avoids re-serializing the same ServerInfo JSON on every new connection. The
cache is rebuilt when the ephemeral port is resolved. Connections that carry a
per-connection nonce (NKey auth) continue to serialize individually so the nonce
is included correctly.
2026-02-23 01:01:38 -05:00
Joseph Doherty f0b5edd7c6 feat: add response permission tracking for dynamic reply subject authorization 2026-02-23 00:59:15 -05:00
Joseph Doherty 1806ae607e test: add TLS rate limiter unit tests 2026-02-23 00:57:14 -05:00
Joseph Doherty 1f13269447 feat: implement TLS cert-to-user mapping via X500 DN matching 2026-02-23 00:55:29 -05:00
Joseph Doherty 7a897c1087 feat: add MaxSubs enforcement, delivery-time deny filtering, auto-unsub cleanup 2026-02-23 00:53:15 -05:00
Joseph Doherty e9b6c7fdd3 feat: add protocol tracing (<<- op arg) at LogLevel.Trace 2026-02-23 00:52:00 -05:00
Joseph Doherty 1269ae8275 feat: implement /subz endpoint with account filter, test subject, and pagination 2026-02-23 00:50:26 -05:00
Joseph Doherty 0347e8a28c fix: increment _removes counter in RemoveBatch for accurate stats 2026-02-23 00:48:53 -05:00
Joseph Doherty 6afe11ad4d feat: add per-account connection/subscription limits with AccountConfig 2026-02-23 00:46:16 -05:00
Joseph Doherty 345e7ca15c feat: implement log reopening on SIGUSR1 signal 2026-02-23 00:46:09 -05:00
Joseph Doherty cc0fe04f3c feat: add generation-based cache, Stats, HasInterest, NumInterest, RemoveBatch, All, ReverseMatch to SubList 2026-02-23 00:45:28 -05:00
Joseph Doherty cf75077bc4 feat: add CLI flags for debug/trace modes, file logging, syslog, color, timestamps 2026-02-23 00:43:27 -05:00
Joseph Doherty 4ad821394b feat: add -D/-V/-DV debug/trace CLI flags and file logging support 2026-02-23 00:41:49 -05:00
Joseph Doherty b7c0e321d9 fix: move stale connection stat increments to detection site in RunPingTimerAsync 2026-02-23 00:41:12 -05:00
Joseph Doherty 0ec5583422 fix: address code quality review findings for batch 1
- SubjectsCollide: split tokens once upfront instead of O(n²) TokenAt calls
- NatsHeaderParser: manual digit accumulation avoids string allocation and overflow
- NatsHeaders: use IReadOnlyDictionary for Headers, immutable Invalid sentinel
- PermissionLruCache: add missing Count property
2026-02-23 00:40:14 -05:00
Joseph Doherty cd4ae3cce6 feat: add stale connection stats tracking and varz exposure 2026-02-23 00:38:43 -05:00
Joseph Doherty eb25d52ed5 feat: add RTT tracking and first-PING delay to NatsClient 2026-02-23 00:34:30 -05:00
Joseph Doherty dddced444e feat: add NumTokens, TokenAt, SubjectsCollide, UTF-8 validation to SubjectMatch 2026-02-23 00:33:43 -05:00
Joseph Doherty e87d4c00d9 feat: add NatsHeaderParser for MIME header parsing 2026-02-23 00:33:24 -05:00
Joseph Doherty 7cf6bb866e feat: add PermissionLruCache (128-entry LRU) and wire into ClientPermissions 2026-02-23 00:33:15 -05:00
Joseph Doherty 17a0a217dd feat: add MaxSubs, MaxSubTokens, Debug, Trace, LogFile, LogSizeLimit, Tags to NatsOptions 2026-02-23 00:32:12 -05:00
Joseph Doherty 573cd06bb1 feat: add logging and timestamp options to NatsOptions 2026-02-23 00:29:45 -05:00
Joseph Doherty a0f02d6641 chore: add Serilog.Sinks.File and SyslogMessages packages 2026-02-23 00:28:32 -05:00
Joseph Doherty 5b383ada4b docs: add implementation plan for sections 3-6 gaps 2026-02-23 00:28:31 -05:00
Joseph Doherty 060e1ee23d docs: add implementation plan for sections 7-10 gaps 2026-02-23 00:25:04 -05:00
Joseph Doherty f4efbcf09e docs: add design for sections 7-10 gaps implementation 2026-02-23 00:17:35 -05:00
Joseph Doherty f86ea57f43 docs: add design for sections 3-6 gaps implementation 2026-02-23 00:17:24 -05:00
Joseph Doherty 3941c85e76 Merge branch 'feature/core-lifecycle' into main
Reconcile close reason tracking: feature branch's MarkClosed() and
ShouldSkipFlush/FlushAndCloseAsync now use main's ClientClosedReason
enum. ClosedState enum retained for forward compatibility.
2026-02-23 00:09:30 -05:00
Joseph Doherty 2baf8a85bf docs: update differences.md section 2 to reflect implemented features 2026-02-22 23:59:19 -05:00
Joseph Doherty f5c0c4f906 feat: wire pending bytes and close reason into connz monitoring 2026-02-22 23:57:39 -05:00
Joseph Doherty 5323c8bb30 docs: update differences.md section 1 to reflect core lifecycle implementation 2026-02-22 23:56:57 -05:00
Joseph Doherty 2fb14821e0 feat: add no-responders CONNECT validation and tests
Reject connections that send no_responders:true without headers:true,
since the 503 HMSG response requires header support. Add three tests:
connection rejection, acceptance with headers, and 503 delivery flow.
2026-02-22 23:56:49 -05:00
Joseph Doherty 04305447f9 feat: implement verbose mode (+OK after commands)
When a client sends CONNECT {"verbose":true}, the server now responds
with +OK\r\n after successfully processing CONNECT, PING, SUB, UNSUB,
and PUB/HPUB commands, matching the Go NATS server behavior.
2026-02-22 23:54:41 -05:00
Joseph Doherty df39ebdc58 feat: add signal handling (SIGTERM, SIGUSR2, SIGHUP) and CLI stubs 2026-02-22 23:52:49 -05:00