Match relay rejection prefixes with a label tolerance (#395)

Co-authored-by: Coracle-Bot <npub1klq6260@nostr.local>
This commit is contained in:
Coracle-Bot 2026-09-02 00:27:29 +00:00 committed by hodlbod
parent cec44ab78b
commit cffc0acfde

View file

@ -13,6 +13,8 @@ import {
isClientClose,
isClientNegOpen,
isClientNegClose,
matchReason,
RelayReasonPrefix,
} from "@welshman/net"
import {
BlockedRelayLists,
@ -138,12 +140,15 @@ const mostlyRestrictedPolicy = (socket: Socket) => {
// NIP-01 reserves "blocked: " for a ban and "restricted: " for lacking permission.
const countDetails = (details: string) => {
if (details.startsWith("auth-required: ")) {
if (matchReason(RelayReasonPrefix.AuthRequired, details)) {
total--
updateStatus()
}
if (details.startsWith("restricted: ") || details.startsWith("blocked: ")) {
if (
matchReason(RelayReasonPrefix.Restricted, details) ||
matchReason(RelayReasonPrefix.Blocked, details)
) {
refused++
updateStatus(details)
}