mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Guard pairing token renewal against concurrent edits and cap pairing names
This commit is contained in:
1 parent
3c7bc80988
commit
12dab07b87
4 files changed
+65
-3
No files matched your search
@@ -321,9 +321,22 @@ export class OpenCodeServerRegistry {
|
||||
if (expiry === null) return
|
||||
|
||||
const remaining = expiry - Date.now()
|
||||
if (remaining <= 0 || remaining > TOKEN_RENEWAL_WINDOW_MS) return
|
||||
if (remaining <= 0) {
|
||||
logger.warn(`The pairing token for OpenCode server ${serverId} has expired; pair the server again`)
|
||||
return
|
||||
}
|
||||
if (remaining > TOKEN_RENEWAL_WINDOW_MS) return
|
||||
|
||||
const renewed = await this.pairWithToken(server.baseUrl, token)
|
||||
const current = this.get(serverId)
|
||||
if (
|
||||
current === null ||
|
||||
current.baseUrl !== server.baseUrl ||
|
||||
readOpenCodeServerPassword(this.db, serverId) !== token
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
updateOpenCodeServer(this.db, serverId, { password: renewed })
|
||||
this.invalidateClient(serverId)
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user