Match relay rejection prefixes with a label tolerance (#395)
Co-authored-by: Coracle-Bot <npub1klq6260@nostr.local>
This commit is contained in:
parent
cec44ab78b
commit
cffc0acfde
1 changed files with 7 additions and 2 deletions
|
|
@ -13,6 +13,8 @@ import {
|
||||||
isClientClose,
|
isClientClose,
|
||||||
isClientNegOpen,
|
isClientNegOpen,
|
||||||
isClientNegClose,
|
isClientNegClose,
|
||||||
|
matchReason,
|
||||||
|
RelayReasonPrefix,
|
||||||
} from "@welshman/net"
|
} from "@welshman/net"
|
||||||
import {
|
import {
|
||||||
BlockedRelayLists,
|
BlockedRelayLists,
|
||||||
|
|
@ -138,12 +140,15 @@ const mostlyRestrictedPolicy = (socket: Socket) => {
|
||||||
|
|
||||||
// NIP-01 reserves "blocked: " for a ban and "restricted: " for lacking permission.
|
// NIP-01 reserves "blocked: " for a ban and "restricted: " for lacking permission.
|
||||||
const countDetails = (details: string) => {
|
const countDetails = (details: string) => {
|
||||||
if (details.startsWith("auth-required: ")) {
|
if (matchReason(RelayReasonPrefix.AuthRequired, details)) {
|
||||||
total--
|
total--
|
||||||
updateStatus()
|
updateStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (details.startsWith("restricted: ") || details.startsWith("blocked: ")) {
|
if (
|
||||||
|
matchReason(RelayReasonPrefix.Restricted, details) ||
|
||||||
|
matchReason(RelayReasonPrefix.Blocked, details)
|
||||||
|
) {
|
||||||
refused++
|
refused++
|
||||||
updateStatus(details)
|
updateStatus(details)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue