mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-04-02 05:23:21 +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]))/,
|
/(([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 {
|
export class LocalBinding {
|
||||||
constructor(readonly localHost: string, readonly ipHosts: string[]) {}
|
constructor(readonly localHost: string, readonly ipHosts: string[]) {}
|
||||||
createOrigins(protocol: string) {
|
createOrigins(protocol: string) {
|
||||||
const ipHosts = this.ipHosts
|
const ipHosts = this.ipHosts
|
||||||
return {
|
return {
|
||||||
local: new Origin(protocol, this.localHost),
|
local: new Origin(protocol, this.localHost),
|
||||||
|
get all() {
|
||||||
|
return [this.local, ...this.ip]
|
||||||
|
},
|
||||||
get 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() {
|
get ipv4() {
|
||||||
return ipHosts
|
return ipHosts
|
||||||
|
|||||||
Reference in New Issue
Block a user