on master help sign in
Remove endpoints for setting parameters; all parameters are set via CLI flags
3ed706fiko
server.knot+3−24
@@ -358,8 +358,9 @@ type ActivePoll = {pubkey: PubkeyHex, startedAt: Timestamp}
358-- any mismatch means the server restarted and the client must reset its cursor.
358-- any mismatch means the server restarted and the client must reset its cursor.
359*serverGeneration : Int
359*serverGeneration : Int
360
360
361−-- Bearer secret accepted on /maintenance/* endpoints. Rotated via /maintenance/rotate-secret;
361+-- Bearer secret accepted on /maintenance/* endpoints. Set via the
362+-- `runtimeMaintenanceSecret` CLI flag at startup; empty value disables
362−-- empty value disables maintenance entirely (every check returns false).
363+-- maintenance entirely (every check returns false).
363*runtimeMaintenanceSecret : Text
364*runtimeMaintenanceSecret : Text
364
365
365-- Ed25519 federation keypair (hex). Generated on first startup if blank, then persisted.
366-- Ed25519 federation keypair (hex). Generated on first startup if blank, then persisted.
@@ -420,13 +421,11 @@ route MaintenanceApi where
420 POST {ip: Text} /maintenance/sessions/revoke-ip headers {authorization: Text} -> {ok: Bool, revokedCount: Int, affectedKeys: Int} = AdminRevokeIp
421 POST {ip: Text} /maintenance/sessions/revoke-ip headers {authorization: Text} -> {ok: Bool, revokedCount: Int, affectedKeys: Int} = AdminRevokeIp
421 POST {limit: Int} /maintenance/sessions/list headers {authorization: Text} -> {sessions: [{pubkey: PubkeyHex, count: Int, ips: [Text], latestExpiry: Timestamp}], ok: Bool, total: Int} = AdminListAllSessions
422 POST {limit: Int} /maintenance/sessions/list headers {authorization: Text} -> {sessions: [{pubkey: PubkeyHex, count: Int, ips: [Text], latestExpiry: Timestamp}], ok: Bool, total: Int} = AdminListAllSessions
422 GET /maintenance/rate-limits headers {authorization: Text} -> {ok: Bool, globalRequest: Int, ipRate: Int, sendRate: Int, federationRate: Int, authGlobal: Int, recvRate: Int, challengeRate: Int, pairRate: Int, lookupRate: Int} = GetRateLimits
423 GET /maintenance/rate-limits headers {authorization: Text} -> {ok: Bool, globalRequest: Int, ipRate: Int, sendRate: Int, federationRate: Int, authGlobal: Int, recvRate: Int, challengeRate: Int, pairRate: Int, lookupRate: Int} = GetRateLimits
423− POST {globalRequest: Int, ipRate: Int, sendRate: Int, federationRate: Int, authGlobal: Int, recvRate: Int, challengeRate: Int, pairRate: Int, lookupRate: Int} /maintenance/rate-limits headers {authorization: Text} -> {ok: Bool} = SetRateLimits
424 POST /maintenance/nonces/flush headers {authorization: Text} -> {ok: Bool, flushedCount: Int} = FlushNonces
424 POST /maintenance/nonces/flush headers {authorization: Text} -> {ok: Bool, flushedCount: Int} = FlushNonces
425 POST {server: ServerName} /maintenance/allow headers {authorization: Text} -> {ok: Bool, allowed: Int} = AllowPeer
425 POST {server: ServerName} /maintenance/allow headers {authorization: Text} -> {ok: Bool, allowed: Int} = AllowPeer
426 POST {server: ServerName} /maintenance/unallow headers {authorization: Text} -> {ok: Bool, removed: Bool} = UnallowPeer
426 POST {server: ServerName} /maintenance/unallow headers {authorization: Text} -> {ok: Bool, removed: Bool} = UnallowPeer
427 GET /maintenance/allowed headers {authorization: Text} -> {peers: [Text], ok: Bool} = ListAllowed
427 GET /maintenance/allowed headers {authorization: Text} -> {peers: [Text], ok: Bool} = ListAllowed
428 POST /maintenance/reconcile headers {authorization: Text} -> {ok: Bool, messageDrift: Int, presenceDrift: Int, sessionDrift: Int} = Reconcile
428 POST /maintenance/reconcile headers {authorization: Text} -> {ok: Bool, messageDrift: Int, presenceDrift: Int, sessionDrift: Int} = Reconcile
429− POST {newSecret: Text} /maintenance/rotate-secret headers {authorization: Text} -> {ok: Bool, error: Text} = RotateSecret
430 GET /maintenance/config headers {authorization: Text} -> {ok: Bool, pollTimeoutMs: Int, ackGracePeriod: Int} = GetConfig
429 GET /maintenance/config headers {authorization: Text} -> {ok: Bool, pollTimeoutMs: Int, ackGracePeriod: Int} = GetConfig
431
430
432route HealthApi where
431route HealthApi where
@@ -1862,13 +1861,6 @@ handleGetRateLimits = \authorization -> do
1862 lookupRate: v maxLookupRatePerKey
1861 lookupRate: v maxLookupRatePerKey
1863 }
1862 }
1864
1863
1865−-- POST /maintenance/rate-limits: stub. Rate ceilings are compile-time constants
1866−-- in this simplified server, so this just authorizes and returns ok=true.
1867−handleSetRateLimits : a -> b -> c -> d -> e -> f -> g -> h -> i -> Text -> IO {r *runtimeMaintenanceSecret} {ok: Bool}
1868−handleSetRateLimits = \globalRequest ipRate sendRate federationRate authGlobal recvRate challengeRate pairRate lookupRate authorization -> do
1869− authorized <- verifyMaintenanceAuth authorization
1870− yield {ok: authorized}
1871−
1872-- POST /maintenance/nonces/flush: stub. Nonce caches were removed; the
1864-- POST /maintenance/nonces/flush: stub. Nonce caches were removed; the
1873-- endpoint is preserved so older operator tooling keeps working.
1865-- endpoint is preserved so older operator tooling keeps working.
1874handleFlushNonces : Text -> IO {r *runtimeMaintenanceSecret} {flushedCount: Int, ok: Bool}
1866handleFlushNonces : Text -> IO {r *runtimeMaintenanceSecret} {flushedCount: Int, ok: Bool}
@@ -1876,17 +1868,6 @@ handleFlushNonces = \authorization -> do
1876 authorized <- verifyMaintenanceAuth authorization
1868 authorized <- verifyMaintenanceAuth authorization
1877 yield {ok: authorized, flushedCount: 0}
1869 yield {ok: authorized, flushedCount: 0}
1878
1870
1879−-- POST /maintenance/rotate-secret: replace the maintenance Bearer secret.
1880−-- The old secret authenticates the rotation; subsequent calls must use the
1881−-- new value.
1882−handleRotateSecret : Text -> Text -> IO {rw *runtimeMaintenanceSecret} {error: Text, ok: Bool}
1883−handleRotateSecret = \newSecret authorization -> withMaintAuth authorization (yield {
1884− ok: False {},
1885− error: "unauthorized"
1886−}) (do
1887− atomic *runtimeMaintenanceSecret = newSecret
1888− yield {ok: True {}, error: ""})
1889−
1890-- GET /maintenance/config: expose a small set of operationally-relevant
1871-- GET /maintenance/config: expose a small set of operationally-relevant
1891-- compile-time constants (poll timeout, ack grace).
1872-- compile-time constants (poll timeout, ack grace).
1892handleGetConfig : Text -> IO {r *runtimeMaintenanceSecret} {ackGracePeriod: Int, ok: Bool, pollTimeoutMs: Int}
1873handleGetConfig : Text -> IO {r *runtimeMaintenanceSecret} {ackGracePeriod: Int, ok: Bool, pollTimeoutMs: Int}
@@ -2259,13 +2240,11 @@ api = serve Api where
2259 AdminPurgeMessages = \{pubkey, authorization} -> handleAdminPurgeMessages pubkey authorization
2240 AdminPurgeMessages = \{pubkey, authorization} -> handleAdminPurgeMessages pubkey authorization
2260 AdminRevokeIp = \{ip, authorization} -> handleAdminRevokeIp ip authorization
2241 AdminRevokeIp = \{ip, authorization} -> handleAdminRevokeIp ip authorization
2261 GetRateLimits = \{authorization} -> handleGetRateLimits authorization
2242 GetRateLimits = \{authorization} -> handleGetRateLimits authorization
2262− SetRateLimits = \{globalRequest, ipRate, sendRate, federationRate, authGlobal, recvRate, challengeRate, pairRate, lookupRate, authorization} -> handleSetRateLimits globalRequest ipRate sendRate federationRate authGlobal recvRate challengeRate pairRate lookupRate authorization
2263 FlushNonces = \{authorization} -> handleFlushNonces authorization
2243 FlushNonces = \{authorization} -> handleFlushNonces authorization
2264 AllowPeer = \{server, authorization} -> handleAllowPeer server authorization
2244 AllowPeer = \{server, authorization} -> handleAllowPeer server authorization
2265 UnallowPeer = \{server, authorization} -> handleUnallowPeer server authorization
2245 UnallowPeer = \{server, authorization} -> handleUnallowPeer server authorization
2266 ListAllowed = \{authorization} -> handleListAllowed authorization
2246 ListAllowed = \{authorization} -> handleListAllowed authorization
2267 Reconcile = \{authorization} -> handleReconcile authorization
2247 Reconcile = \{authorization} -> handleReconcile authorization
2268− RotateSecret = \{newSecret, authorization} -> handleRotateSecret newSecret authorization
2269 GetConfig = \{authorization} -> handleGetConfig authorization
2248 GetConfig = \{authorization} -> handleGetConfig authorization
2270 Health = \{authorization} -> handleHealth authorization
2249 Health = \{authorization} -> handleHealth authorization
2271 Stats = \{authorization} -> handleStats authorization
2250 Stats = \{authorization} -> handleStats authorization