Browse Source

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

main
mleku 4 months ago
parent
commit
5eb192f208
No known key found for this signature in database
  1. 9
      app/handle-websocket.go
  2. 1
      scripts/relaytester-test.sh

9
app/handle-websocket.go

@ -7,6 +7,7 @@ import (
"strings" "strings"
"time" "time"
"encoders.orly/envelopes/authenvelope"
"encoders.orly/hex" "encoders.orly/hex"
"github.com/coder/websocket" "github.com/coder/websocket"
"lol.mleku.dev/chk" "lol.mleku.dev/chk"
@ -70,6 +71,14 @@ whitelist:
chal := make([]byte, 32) chal := make([]byte, 32)
rand.Read(chal) rand.Read(chal)
listener.challenge.Store([]byte(hex.Enc(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) ticker := time.NewTicker(DefaultPingWait)
go s.Pinger(ctx, conn, ticker, cancel) go s.Pinger(ctx, conn, ticker, cancel)
defer func() { defer func() {

1
scripts/relaytester-test.sh

@ -7,6 +7,7 @@ if ! command -v "relay-tester" &> /dev/null; then
echo "./scripts/relaytester-install.sh" echo "./scripts/relaytester-install.sh"
exit exit
fi fi
rm -rf ~/.local/share/ORLY
export ORLY_LOG_LEVEL=off export ORLY_LOG_LEVEL=off
export ORLY_LISTEN=127.0.0.1 export ORLY_LISTEN=127.0.0.1
export ORLY_PORT=3334 export ORLY_PORT=3334

Loading…
Cancel
Save