mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
feat: Local binding now has all
This commit is contained in:
@@ -14,14 +14,23 @@ export const ipv6 = once(
|
||||
() =>
|
||||
/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/,
|
||||
)
|
||||
/**
|
||||
* Some addresses are local
|
||||
*/
|
||||
export const local = once(() => /\.local/)
|
||||
export class LocalBinding {
|
||||
constructor(readonly localHost: string, readonly ipHosts: string[]) {}
|
||||
createOrigins(protocol: string) {
|
||||
const ipHosts = this.ipHosts
|
||||
return {
|
||||
local: new Origin(protocol, this.localHost),
|
||||
get all() {
|
||||
return [this.local, ...this.ip]
|
||||
},
|
||||
get ip() {
|
||||
return ipHosts.map((x) => new Origin(protocol, x))
|
||||
return ipHosts
|
||||
.filter((x) => !local().test(x))
|
||||
.map((x) => new Origin(protocol, x))
|
||||
},
|
||||
get ipv4() {
|
||||
return ipHosts
|
||||
|
||||
Reference in New Issue
Block a user