Pulls from relays that send an unsolicited AUTH challenge no longer fail; only a CLOSED with an auth-required or restricted reason stops the pull, and that reason is surfaced in the job error.
- commit
- 54bb70e9819f25c49b2eeff42b7fbf2c28a3f573
- parent
- a17b474809e2f2c6e2ee31fe66119b8f46adb553
- author
- Dami <dami.etoile@gmail.com>
| M | internal/ | 14 | ++++++++++++-- |
@@ -585,7 +585,10 @@ func (t *NostrTransport) QueryNegentropy(ctx context.Context, target string, fil
585585 _ = json.Unmarshal(raw[2], &body)586586 }587587 if kind == "AUTH" {588- return nil, errors.New("replication: remote relay requires authentication")588+ // An unsolicited NIP-42 challenge is informational; the relay still589+ // answers public queries. A CLOSED with an auth-required reason is590+ // the actual refusal.591+ continue589592 }590593 if messageID != id {591594 continue@@ -812,10 +815,17 @@ func readEvents(ctx context.Context, socket Socket, subscription string, timeout
812815 }813816 case "CLOSED":814817 if id == subscription {818+ reason := ""819+ if len(raw) > 2 {820+ _ = json.Unmarshal(raw[2], &reason)821+ }822+ if strings.HasPrefix(reason, "auth-required:") || strings.HasPrefix(reason, "restricted:") {823+ return items, errors.New("replication: remote relay requires authentication: " + reason)824+ }815825 return items, errors.New("replication: remote query closed")816826 }817827 case "AUTH":818- return items, errors.New("replication: remote relay requires authentication")828+ // See the negentropy reader: the challenge alone is not a refusal.819829 }820830 }821831 }