feat(batch17): port lifecycle, tls, and rate-limited logging features
This commit is contained in:
@@ -97,7 +97,7 @@ public sealed partial class ClientConnection
|
||||
// Connection kind and server references.
|
||||
internal ClientKind Kind; // mirrors c.kind
|
||||
internal INatsServer? Server; // mirrors c.srv
|
||||
internal INatsAccount? Account; // mirrors c.acc
|
||||
internal INatsAccount? _account; // mirrors c.acc
|
||||
internal ClientPermissions? Perms; // mirrors c.perms
|
||||
internal MsgDeny? MPerms; // mirrors c.mperms
|
||||
|
||||
@@ -439,15 +439,15 @@ public sealed partial class ClientConnection
|
||||
if (!acc.IsValid) throw new BadAccountException();
|
||||
|
||||
// Deregister from previous account.
|
||||
if (Account is not null)
|
||||
if (_account is not null)
|
||||
{
|
||||
var prev = Account.RemoveClient(this);
|
||||
var prev = _account.RemoveClient(this);
|
||||
if (prev == 1) Server?.DecActiveAccounts();
|
||||
}
|
||||
|
||||
lock (_mu)
|
||||
{
|
||||
Account = acc;
|
||||
_account = acc;
|
||||
ApplyAccountLimits();
|
||||
}
|
||||
|
||||
@@ -503,7 +503,7 @@ public sealed partial class ClientConnection
|
||||
/// </summary>
|
||||
internal void ApplyAccountLimits()
|
||||
{
|
||||
if (Account is null || (Kind != ClientKind.Client && Kind != ClientKind.Leaf))
|
||||
if (_account is null || (Kind != ClientKind.Client && Kind != ClientKind.Leaf))
|
||||
return;
|
||||
|
||||
Volatile.Write(ref _mpay, JwtNoLimit);
|
||||
@@ -1111,7 +1111,7 @@ public sealed partial class ClientConnection
|
||||
|
||||
internal void SetAccount(INatsAccount? acc)
|
||||
{
|
||||
lock (_mu) { Account = acc; }
|
||||
lock (_mu) { _account = acc; }
|
||||
}
|
||||
|
||||
internal void SetAccount(Account? acc) => SetAccount(acc as INatsAccount);
|
||||
@@ -1360,25 +1360,29 @@ public sealed partial class ClientConnection
|
||||
// Account / server helpers (features 540-545)
|
||||
// =========================================================================
|
||||
|
||||
internal INatsAccount? GetAccount()
|
||||
internal INatsAccount? Account()
|
||||
{
|
||||
lock (_mu) { return Account; }
|
||||
lock (_mu) { return _account; }
|
||||
}
|
||||
|
||||
internal INatsAccount? GetAccount() => Account();
|
||||
|
||||
// =========================================================================
|
||||
// TLS handshake helpers (features 546-548)
|
||||
// =========================================================================
|
||||
|
||||
internal async Task<bool> DoTlsServerHandshakeAsync(SslServerAuthenticationOptions opts, CancellationToken ct = default)
|
||||
{
|
||||
// Deferred: full TLS flow will be completed with server integration.
|
||||
return false;
|
||||
_ = ct;
|
||||
return await Task.FromResult(
|
||||
DoTLSServerHandshake("client", opts, Server?.Options.TlsTimeout ?? 2, Server?.Options.TlsPinnedCerts) is null);
|
||||
}
|
||||
|
||||
internal async Task<bool> DoTlsClientHandshakeAsync(SslClientAuthenticationOptions opts, CancellationToken ct = default)
|
||||
{
|
||||
// Deferred: full TLS flow will be completed with server integration.
|
||||
return false;
|
||||
_ = ct;
|
||||
var (_, err) = DoTLSClientHandshake("route", null, opts, opts.TargetHost ?? string.Empty, Server?.Options.TlsTimeout ?? 2, null);
|
||||
return await Task.FromResult(err is null);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
@@ -1759,9 +1763,8 @@ public sealed partial class ClientConnection
|
||||
// features 477-496 and 487-503: see ClientConnection.SubscriptionsAndDelivery.cs
|
||||
|
||||
// features 497-515 and 520: see ClientConnection.InboundAndHeaders.cs
|
||||
// feature 534-535: swapAccountAfterReload, processSubsOnConfigReload
|
||||
// feature 537: reconnect
|
||||
// feature 569: setFirstPingTimer
|
||||
// features 521-522, 534-535, 537, 540-548, 553, 565-569:
|
||||
// see ClientConnection.LifecycleAndTls.cs
|
||||
|
||||
// =========================================================================
|
||||
// IsMqtt / IsWebSocket helpers (used by clientType, not separately tracked)
|
||||
|
||||
Reference in New Issue
Block a user