l0.DependencyControl.Host¶
Host ¶
A host — a hostname or IP literal — that reports whether it targets a non-public IP address.
Constructor ¶
| param | type | description |
|---|---|---|
| host | string |
A hostname or IP-literal string. |
| resolver? | fun(host: string): integer[][]? |
Address resolver (default: the class-level resolver). |
Instance methods¶
addresses ¶
Resolves this host to a list of address byte arrays, cached across calls. A literal host yields its own bytes without resolving; a non-literal host is looked up via the resolver (nil when it can't be resolved).
Returns:
addressesinteger[][]?
resolvesToPrivate ¶
Reports whether this host targets a non-public IP address — private, loopback, link-local, or reserved. Resolves a non-literal host on first call; an unresolvable host reads as false.
Returns:
privateboolean— True when the host targets a non-public address.
Class methods¶
fromUrl ¶
Builds a Host from a URL's host component, or nil when the URL carries no host.
| param | type | description |
|---|---|---|
| url | string |
The URL to extract the host from. |
| resolver? | fun(host: string): integer[][]? |
Address resolver (default: the class-level resolver). |
Returns:
hostHost?
isPrivateAddress ¶
Reports whether a resolved IP address is in a non-public range.
| param | type | description |
|---|---|---|
| bytes | integer[] |
The address bytes (length 4 for IPv4, 16 for IPv6). |
Returns:
privateboolean— True when the address is private/loopback/link-local/reserved.
getUrlHostPart ¶
Extracts the host from a URL, dropping protocol, auth, port and unwrapping a bracketed [IPv6].
| param | type | description |
|---|---|---|
| url | string |
The URL to extract the host from. |
Returns:
hoststring? — The host, or nil when none could be extracted.
parseIPv4Literal ¶
Parses an IPv4 literal in inet_aton form (dotted/decimal/octal/hex, 1-4 parts) to a 4-byte array.
Hand-rolled to catch the legacy encodings the fetcher (curl/WinINet) accepts but a resolver's
inet_pton rejects — e.g. decimal 2130706433 (== 127.0.0.1), which could be used to bypass SSRF protection.
IPv6 literals have a single canonical form the resolver parses identically, so they don't need this.
| param | type | description |
|---|---|---|
| host | string |
The host string to parse. |
Returns:
bytesinteger[]? — The 4 address bytes, or nil whenhostisn't an IPv4 literal.