Send initial AUTH challenge if admins are configured and clean up leftover ORLY data in relaytester-test.sh.

This commit is contained in:
2025-09-10 14:39:22 +01:00
parent 2385d1f752
commit 5eb192f208
2 changed files with 10 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import (
"strings"
"time"
"encoders.orly/envelopes/authenvelope"
"encoders.orly/hex"
"github.com/coder/websocket"
"lol.mleku.dev/chk"
@@ -70,6 +71,14 @@ whitelist:
chal := make([]byte, 32)
rand.Read(chal)
listener.challenge.Store([]byte(hex.Enc(chal)))
// If admins are configured, immediately prompt client to AUTH (NIP-42)
if len(s.Config.Admins) > 0 {
log.D.F("sending initial AUTH challenge to %s", remote)
if err = authenvelope.NewChallengeWith(listener.challenge.Load()).
Write(listener); chk.E(err) {
return
}
}
ticker := time.NewTicker(DefaultPingWait)
go s.Pinger(ctx, conn, ticker, cancel)
defer func() {