fetch-node: ensure unicast checks allow psl domains (#3379)
This commit is contained in:
parent
4ab7075fde
commit
9c01281931
5
.changeset/silver-birds-run.md
Normal file
5
.changeset/silver-birds-run.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@atproto-labs/fetch-node": patch
|
||||
---
|
||||
|
||||
Unicast checks should permit PSL domains.
|
@ -9,7 +9,7 @@ import {
|
||||
FetchRequestError,
|
||||
} from '@atproto-labs/fetch'
|
||||
import ipaddr from 'ipaddr.js'
|
||||
import { isValid as isValidDomain } from 'psl'
|
||||
import { parse as pslParse } from 'psl'
|
||||
import { Agent, Client } from 'undici'
|
||||
|
||||
import { isUnicastIp } from './util.js'
|
||||
@ -185,6 +185,14 @@ export function unicastLookup(
|
||||
})
|
||||
}
|
||||
|
||||
// see lupomontero/psl#258 for context on psl usage.
|
||||
// in short, this ensures a structurally valid domain
|
||||
// plus a "listed" tld.
|
||||
function isValidDomain(domain: string) {
|
||||
const parsed = pslParse(domain)
|
||||
return !parsed.error && parsed.listed
|
||||
}
|
||||
|
||||
function isNotUnicast(ip: ipaddr.IPv4 | ipaddr.IPv6): boolean {
|
||||
return ip.range() !== 'unicast'
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user