Commit Graph

31 Commits

Author SHA1 Message Date
Joseph Doherty
f6b38df291 feat: add TlsHelper, PeekableStream, and TlsRateLimiter
Add TLS utility classes for certificate loading, peekable stream for TLS
detection, token-bucket rate limiter for handshake throttling, and
TlsConnectionState for post-handshake info. Add TlsState property to
NatsClient. Fix X509Certificate2 constructor usage for .NET 10 compat.
2026-02-22 22:13:53 -05:00
Joseph Doherty
045c12cce7 feat: add Varz and Connz monitoring JSON models with Go field name parity 2026-02-22 22:13:50 -05:00
Joseph Doherty
b2f7b1b2a0 feat: add -m/--http_port CLI flag for monitoring 2026-02-22 22:10:07 -05:00
Joseph Doherty
a26c1359de refactor: NatsClient accepts Stream parameter for TLS support 2026-02-22 22:09:48 -05:00
Joseph Doherty
1a777e09c9 feat: add ServerStats counters and NatsClient metadata for monitoring 2026-02-22 22:08:30 -05:00
Joseph Doherty
ceaafc48d4 feat: add project setup for monitoring and TLS — csproj, config options, ServerInfo TLS fields
Add FrameworkReference to Microsoft.AspNetCore.App to enable Kestrel
Minimal APIs for the monitoring HTTP server. Remove the now-redundant
Microsoft.Extensions.Logging.Abstractions PackageReference (it is
included transitively via the framework reference).

Add monitoring config properties (MonitorPort, MonitorHost,
MonitorBasePath, MonitorHttpsPort) and TLS config properties (TlsCert,
TlsKey, TlsCaCert, TlsVerify, TlsHandshakeFirst, etc.) to NatsOptions.

Add TlsRequired, TlsVerify, and TlsAvailable fields to ServerInfo so
the server can advertise TLS capability in the INFO protocol message.
2026-02-22 22:00:42 -05:00
Joseph Doherty
d08ce7f6fb chore: add .worktrees/ to .gitignore for isolated development 2026-02-22 21:54:26 -05:00
Joseph Doherty
b744913296 feat: add server-side PING keepalive with stale connection detection 2026-02-22 21:53:42 -05:00
Joseph Doherty
d14d73a7d0 feat: add pedantic subject validation and max payload enforcement on PUB
Move max payload validation from the parser to ProcessPubAsync so the
server sends -ERR 'Maximum Payload Violation' and closes the connection
(matching Go reference client.go:2442). In pedantic mode, reject PUB
with wildcard subjects via -ERR 'Invalid Publish Subject' (client.go:2869).
Add disposed guard to SubList.Remove to prevent crash during shutdown.
2026-02-22 21:49:01 -05:00
Joseph Doherty
9d0d5064ac docs: add implementation plan for monitoring HTTP and TLS support
12 tasks covering ServerStats, monitoring models, Kestrel endpoints,
TLS helpers, 4-mode connection wrapper, and full integration tests.
2026-02-22 21:47:23 -05:00
Joseph Doherty
0c12b0f6e3 feat: enforce MaxConnections limit in accept loop 2026-02-22 21:44:18 -05:00
Joseph Doherty
19e8c65f6d feat: add -ERR response infrastructure with SendErrAsync and SendErrAndCloseAsync 2026-02-22 21:42:04 -05:00
Joseph Doherty
8ee5a7f97b docs: add design for monitoring HTTP and TLS support
Covers /varz, /connz endpoints via Kestrel Minimal APIs,
full TLS support with four modes (none/required/first/mixed),
cert pinning, rate limiting, and testing strategy.
2026-02-22 21:33:24 -05:00
Joseph Doherty
16b8f9e2e2 docs: add implementation plan for hardening base server
Four tasks: -ERR infrastructure, MaxConnections enforcement,
pedantic subject validation + max payload on PUB, PING keepalive.
Full TDD steps with exact code and commands.
2026-02-22 21:29:10 -05:00
Joseph Doherty
b8acca19dd docs: add design doc for hardening base server
Covers -ERR infrastructure, MaxConnections enforcement,
pedantic subject validation on PUB, and server-side PING keepalive.
2026-02-22 21:25:10 -05:00
Joseph Doherty
5dee4f5fa6 chore: expand .gitignore with standard .NET/Visual Studio entries 2026-02-22 21:15:39 -05:00
Joseph Doherty
2e1e1bb341 fix: resolve slopwatch issues — add logging to empty catches and eliminate test timing delays
Replace empty catch blocks with meaningful log statements in NatsServer,
NatsClient, and Program. Add WaitForReadyAsync() to NatsServer for
deterministic server startup. Replace Task.Delay/Thread.Sleep in tests
with PING/PONG protocol flush and SubscribeCoreAsync for reliable
subscription synchronization.
2026-02-22 21:14:16 -05:00
Joseph Doherty
539b2b7588 feat: add structured logging, Shouldly assertions, CPM, and project documentation
- Add Microsoft.Extensions.Logging + Serilog to NatsServer and NatsClient
- Convert all test assertions from xUnit Assert to Shouldly
- Add NSubstitute package for future mocking needs
- Introduce Central Package Management via Directory.Packages.props
- Add documentation_rules.md with style guide, generation/update rules, component map
- Generate 10 documentation files across 5 component folders (GettingStarted, Protocol, Subscriptions, Server, Configuration/Operations)
- Update CLAUDE.md with logging, testing, porting, agent model, CPM, and documentation guidance
2026-02-22 21:05:53 -05:00
Joseph Doherty
b9f4dec523 docs: update CLAUDE.md with verified build and test commands
Remove template UnitTest1.cs placeholder. Add actual project structure,
run commands for the NATS server host, and update test command examples
to reference the real project paths.
2026-02-22 20:34:42 -05:00
Joseph Doherty
c7fc703d7e feat: add integration tests using NATS.Client.Core NuGet package
Validates the server against the official NATS .NET client library with
tests for basic pub/sub, wildcard (* and >) matching, fan-out to
multiple subscribers, and PING/PONG keepalive. All 5 tests pass without
requiring any server changes.
2026-02-22 20:32:16 -05:00
Joseph Doherty
96e584c382 feat: add NATS.Server.Host console app with basic CLI arguments 2026-02-22 20:29:23 -05:00
Joseph Doherty
1bc6870238 feat: implement NatsServer orchestrator with accept loop and message routing 2026-02-22 20:27:31 -05:00
Joseph Doherty
8db2de37cd feat: implement NatsClient connection handler with read/write pipeline 2026-02-22 20:24:35 -05:00
Joseph Doherty
c78dc67973 feat: implement NATS protocol parser with System.IO.Pipelines
Add NatsParser that reads NATS protocol commands from
ReadOnlySequence<byte>. Identifies commands by first 2 bytes using
case-insensitive bit masking. Handles PUB/HPUB payload reading with
stateful _awaitingPayload for split-packet scenarios. Uses Span<Range>
for zero-allocation argument splitting and ParseSize for ASCII decimal
parsing. Includes CommandType enum, ParsedCommand struct, and
ProtocolViolationException.

14 tests covering PING, PONG, CONNECT, INFO, SUB (with/without queue),
UNSUB (with/without max), PUB (with/without reply, zero payload),
HPUB, multiple commands, and case insensitivity.
2026-02-22 20:19:37 -05:00
Joseph Doherty
bc8fee8e39 fix: address SubList code review findings 2026-02-22 20:14:48 -05:00
Joseph Doherty
afc419ce3f feat: implement SubList trie with wildcard matching and cache 2026-02-22 20:07:35 -05:00
Joseph Doherty
9e36b7c0fc feat: add protocol constants, ServerInfo, ClientOptions, and NatsOptions 2026-02-22 20:00:13 -05:00
Joseph Doherty
270ab27ce3 feat: add Subscription types and subject validation with wildcard matching 2026-02-22 19:53:49 -05:00
Joseph Doherty
05b07407a8 feat: scaffold solution with NATS.Server library, host, and test projects 2026-02-22 19:48:44 -05:00
Joseph Doherty
61824260df feat: add detailed implementation plan for base NATS server port
10 tasks from scaffolding through integration tests, each with
TDD steps, exact file paths, and complete code. Bottom-up order:
SubList → Parser → Client → Server → Integration.
2026-02-22 19:45:53 -05:00
Joseph Doherty
0ea71ace79 Add CLAUDE.md and base server design document
Design covers the minimal NATS server port: pub/sub with wildcards
and queue groups over System.IO.Pipelines, targeting .NET 10.
2026-02-22 19:37:32 -05:00