Skip to content

Commit fdac4f3

Browse files
authored
Merge pull request #2 from dc-holdings-spa/fix/revocation-poll
feat(client): poll server every 60s — detect peer revocation and exit
2 parents 681c174 + 42e1690 commit fdac4f3

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

client/main.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,35 @@ func runConnect(ctx context.Context, rf *rootFlags, cfg *Config) int {
542542
wsURL := (&url.URL{Scheme: "wss", Host: host, Path: "/tunnel"}).String()
543543
go runShovel(shovelCtx, udpConn, wsURL)
544544

545-
<-ctx.Done()
545+
// Poll server every 60 s to detect server-side revocation. If the peer
546+
// is revoked (admin action, re-pair replace, etc.) while the tunnel is
547+
// running, shut down cleanly so the student knows to re-pair rather than
548+
// sitting on a zombie tunnel that silently drops all traffic.
549+
if cfg.ArenaBaseURL != "" && cfg.PrivateKey != "" {
550+
go func() {
551+
ticker := time.NewTicker(60 * time.Second)
552+
defer ticker.Stop()
553+
for {
554+
select {
555+
case <-ticker.C:
556+
status, err := fetchPeerStatus(shovelCtx, cfg.ArenaBaseURL, cfg.PrivateKey)
557+
if err != nil {
558+
// transient — ignore, try next tick
559+
continue
560+
}
561+
if status == "revoked" {
562+
log.Println("[!] peer revoked server-side — shutting down. Run `arena-byoc pair` to re-pair.")
563+
cancel()
564+
return
565+
}
566+
case <-shovelCtx.Done():
567+
return
568+
}
569+
}
570+
}()
571+
}
572+
573+
<-shovelCtx.Done()
546574
log.Println("[!] shutdown requested")
547575
cancel()
548576
dev.Close()

0 commit comments

Comments
 (0)