on master help sign in
Remove POST /maintenance/config (SetConfig) endpoint
commitd946df5b9746f341c9cda7fcd00bad1e0bd59994 authoriko <mail@iko.soy> dateSun 26 Apr 2026, 23:20 (6 months ago) parent3a92fc8
1 file changed−23
server.knot−23
server.knot−23
@@ -1310,11 +1310,6 @@ route MaintenanceApi where
13101310 GET /maintenance/config headers {authorization: Text}
13111311 -> {ok: Bool, maxMessagesPerRecipient: Int, maxGossipHops: Int, pollTimeoutMs: Int, ackGracePeriod: Int}
13121312 = GetConfig
1313− -- Update operational config at runtime (0 = reset to compile-time default)
1314− POST {maxMessagesPerRecipient: Int, maxGossipHops: Int, pollTimeoutMs: Int, ackGracePeriod: Int} /maintenance/config headers {authorization: Text}
1315− -> {ok: Bool}
1316− = SetConfig
1317−
13181313route HealthApi where
13191314 GET /health headers {authorization: Text} -> {ok: Bool, version: Text, pruneHealthy: Bool, heartbeatHealthy: Bool, capacityHealthy: Bool, capacityWarning: Bool, federationHealthy: Bool, watchdogHealthy: Bool, nonceHealthy: Bool, forwardQueueHealthy: Bool, requestPressureHealthy: Bool, draining: Bool, degradedPeers: Int} = Health
13201315
@@ -8832,21 +8827,6 @@ handleGetConfig = \authorization respond -> do
88328827 yield {maxMessagesPerRecipient: mpr, maxGossipHops: mgh, pollTimeoutMs: ptm, ackGracePeriod: agp}
88338828 yield (respond {ok: True {}, maxMessagesPerRecipient: result.maxMessagesPerRecipient, maxGossipHops: result.maxGossipHops, pollTimeoutMs: result.pollTimeoutMs, ackGracePeriod: result.ackGracePeriod})
88348829
8835−-- POST /maintenance/config: Update operational parameters at runtime. 0 = reset to compile-time default.
8836−-- Changes take effect immediately for new requests. Existing long-polls continue with old values.
8837−handleSetConfig = \newMaxMessagesPerRecipient newMaxGossipHops newPollTimeoutMs newAckGracePeriod authorization respond -> do
8838− authorized <- verifyMaintenanceAuth authorization
8839− if not authorized then yield (respond {ok: False {}})
8840− else do
8841− logEvent "audit" "set_config" ("maxMessagesPerRecipient=" ++ show newMaxMessagesPerRecipient ++ " maxGossipHops=" ++ show newMaxGossipHops ++ " pollTimeoutMs=" ++ show newPollTimeoutMs ++ " ackGracePeriod=" ++ show newAckGracePeriod)
8842− atomic do
8843− set *configOverrideMaxMessagesPerRecipient = max 0 newMaxMessagesPerRecipient
8844− set *configOverrideMaxGossipHops = max 0 newMaxGossipHops
8845− set *configOverridePollTimeoutMs = max 0 newPollTimeoutMs
8846− set *configOverrideAckGracePeriod = max 0 newAckGracePeriod
8847− logInfo ("config: updated — maxMessagesPerRecipient=" ++ show newMaxMessagesPerRecipient ++ " maxGossipHops=" ++ show newMaxGossipHops ++ " pollTimeoutMs=" ++ show newPollTimeoutMs ++ " ackGracePeriod=" ++ show newAckGracePeriod ++ " (0 = default)")
8848− yield (respond {ok: True {}})
8849−
88508830-- Extract request path for access logging (excludes poll to reduce log volume)
88518831requestPath = \req -> case req of
88528832 ReqChallenge {} -> "POST /auth/challenge"
@@ -8895,7 +8875,6 @@ requestPath = \req -> case req of
88958875 Reconcile {} -> "POST /maintenance/reconcile"
88968876 RotateSecret {} -> "POST /maintenance/rotate-secret"
88978877 GetConfig {} -> "GET /maintenance/config"
8898− SetConfig {} -> "POST /maintenance/config"
88998878 Health {} -> "GET /health"
89008879 Stats {} -> "GET /stats"
89018880 StatsPeers {} -> "GET /stats/peers"
@@ -8986,7 +8965,6 @@ serveInner = \req -> case req of
89868965 Reconcile {authorization, respond} -> handleReconcile authorization respond
89878966 RotateSecret {newSecret, authorization, respond} -> handleRotateSecret newSecret authorization respond
89888967 GetConfig {authorization, respond} -> handleGetConfig authorization respond
8989− SetConfig {maxMessagesPerRecipient, maxGossipHops, pollTimeoutMs, ackGracePeriod, authorization, respond} -> handleSetConfig maxMessagesPerRecipient maxGossipHops pollTimeoutMs ackGracePeriod authorization respond
89908968 Health {authorization, respond} -> handleHealth authorization respond
89918969 Stats {authorization, respond} -> handleStats authorization respond
89928970 StatsPeers {authorization, respond} -> handleStatsPeers authorization respond
@@ -9069,7 +9047,6 @@ serveOverloaded = \req -> case req of
90699047 ListAllowed {respond} -> respond {peers: [], ok: False {}}
90709048 RotateSecret {respond} -> respond {ok: False {}, error: "overloaded"}
90719049 GetConfig {respond} -> respond {ok: False {}, maxMessagesPerRecipient: 0, maxGossipHops: 0, pollTimeoutMs: 0, ackGracePeriod: 0}
9072− SetConfig {respond} -> respond {ok: False {}}
90739050 Metrics {respond} -> respond {metrics: "", ok: False {}}
90749051 -- Exempt routes handled by isOverloadExempt; this branch is unreachable
90759052 _ -> yield {}