DNS Stamps is a specification that aims to encode all the data needed to access a DNS server in a single string (URI).
The implementation is based on the specifications contained here.
Basic Use
Creating a StampObj for Google's public DNS resolver and turning it into a string:
import dnsstamps2 let stamp = initPlainDNSStamp("8.8.8.8", Port(53), {StampProps.DNSSEC}) echo toStamp(stamp)
Parsing a DNS Stamp string to get all the specifications of a DNS resolver inside a StampObj:
import dnsstamps2 const strStamp = "sdns://AAEAAAAAAAAABzguOC44Ljg" let stamp = parseStamp(strStamp) echo stamp
Types
StampObj = object address*: string ## It's the IP address. In some protocols it can contain the port, when the resolver (server) ## does not use the default port. IPv6 must be enclosed in square brackets [IPv6]. props*: set[StampProps] ## It is a set with all the informal properties about the resolver (server).
- Object with the information of a given resolver (server) Source Edit
StampProps {.pure, size: 8.} = enum DNSSEC, ## The server supports DNSSEC. NoLog, ## The server doesn’t keep logs. NoFilter ## The server doesn’t intentionally block domains.
- Informal properties about the resolver (server). It is a combination of the following values: Source Edit
StampProto {.pure, size: 1.} = enum PlainDNS = 0, ## Plain DNS. DNSCrypt = 1, ## DNSCrypt. DoH = 2, ## DNS-over-HTTPS. DoT = 3, ## DNS-over-TLS. DoQ = 4, ## DNS-over-QUIC. ODoHTarget = 5, ## Oblivious DoH target. DNSCryptRelay = 129, ## Anonymized DNSCrypt relay. ODoHRelay = 133 ## Oblivious DoH relay.
- Is the protocol identifier for: Source Edit
Procs
proc initDNSCryptRelayStamp(ip: string; port: Port = Port(443)): StampObj {. ...raises: [ValueError], tags: [], forbids: [].}
-
Initializes a StampObj for Anonymized DNSCrypt relay (StampProto.DNSCryptRelay).
Parameters
- ip is the IPv4 or IPv6 of the relay server.
- port is the relay server port.
proc initDNSCryptStamp(ip: string; providerName: string; pk: array[32, byte]; port: Port = Port(443); props: set[StampProps] = {}): StampObj {. ...raises: [ValueError], tags: [], forbids: [].}
-
Initializes a StampObj for DNSCrypt (StampProto.DNSCrypt).
Parameters
- ip is the IPv4 or IPv6 address of the server.
- providerName is the DNSCrypt provider name.
- pk is the provider's Ed25519 public key.
- port is the server port.
- props is a set that represents informal properties about the resolver. See StampProps.
proc initDoHStamp(ip: string = ""; hostname: string; hashes: seq[array[32, byte]]; port: Port = Port(443); path: string = "/dns-query"; bootstrapIps: seq[string] = @[]; props: set[StampProps] = {}): StampObj {....raises: [ValueError], tags: [], forbids: [].}
-
Initializes a StampObj for DNS-over-HTTPS (StampProto.DoH).
Parameters
- ip is the IPv4 or IPv6 address of the server. It can be an empty string, in which case the hostname will be resolved to get the IP address of the server.
- hostname is the hostname of the server.
- hashes is a seq with one or more SHA256 digest of one of the TBS certificate found in the validation chain, typically the certificate used to sign the resolver’s certificate.
- port is the server port.
- path is the absolute URI path.
- bootstrapIps is a seq with recommended IP addresses to resolve hostname via standard DNS. It is optional and can be empty.
- props is a set that represents informal properties about the resolver. See StampProps.
proc initDoQStamp(ip: string = ""; hostname: string; hashes: seq[array[32, byte]]; port: Port = Port(443); bootstrapIps: seq[string] = @[]; props: set[StampProps] = {}): StampObj {. ...raises: [ValueError], tags: [], forbids: [].}
-
Initializes a StampObj for DNS-over-QUIC (StampProto.DoQ).
Parameters
- ip is the IPv4 or IPv6 address of the server. It can be an empty string, in which case the hostname will be resolved to get the IP address of the server.
- hostname is the hostname of the server.
- hashes is a seq with one or more SHA256 digest of one of the TBS certificate found in the validation chain, typically the certificate used to sign the resolver’s certificate.
- port is the server port.
- bootstrapIps is a seq with recommended IP addresses to resolve hostname via standard DNS. It is optional and can be empty.
- props is a set that represents informal properties about the resolver. See StampProps.
proc initDoTStamp(ip: string = ""; hostname: string; hashes: seq[array[32, byte]]; port: Port = Port(443); bootstrapIps: seq[string] = @[]; props: set[StampProps] = {}): StampObj {. ...raises: [ValueError], tags: [], forbids: [].}
-
Initializes a StampObj for DNS-over-TLS (StampProto.DoT).
Parameters
- ip is the IPv4 or IPv6 address of the server. It can be an empty string, in which case the hostname will be resolved to get the IP address of the server.
- hostname is the hostname of the server.
- hashes is a seq with one or more SHA256 digest of one of the TBS certificate found in the validation chain, typically the certificate used to sign the resolver’s certificate.
- port is the server port.
- bootstrapIps is a seq with recommended IP addresses to resolve hostname via standard DNS. It is optional and can be empty.
- props is a set that represents informal properties about the resolver. See StampProps.
proc initODoHRelayStamp(ip: string = ""; hostname: string; hashes: seq[array[32, byte]]; port: Port = Port(443); path: string = "/dns-query"; bootstrapIps: seq[string] = @[]; props: set[StampProps] = {}): StampObj {. ...raises: [ValueError], tags: [], forbids: [].}
-
Initializes a StampObj for Oblivious DoH relay (StampProto.ODoHRelay).
Parameters
- ip is the IPv4 or IPv6 address of the relay server. It can be an empty string, in which case the hostname will be resolved to get the IP address of the relay server.
- hostname is the hostname of the relay server.
- hashes is a seq with one or more SHA256 digest of one of the TBS certificate found in the validation chain, typically the certificate used to sign the resolver’s certificate.
- port is the relay server port.
- path is the absolute URI path.
- bootstrapIps is a seq with recommended IP addresses to resolve hostname via standard DNS. It is optional and can be empty.
- props is a set that represents informal properties about the resolver. See StampProps.
proc initODoHTargetStamp(hostname: string; port: Port = Port(443); path: string = "/dns-query"; props: set[StampProps] = {}): StampObj {....raises: [], tags: [], forbids: [].}
-
Initializes a StampObj for Oblivious DoH target (StampProto.ODoHTarget).
Parameters
- hostname is the hostname of the server.
- port is the server port.
- path is the absolute URI path.
- props is a set that represents informal properties about the resolver. See StampProps.
proc initPlainDNSStamp(ip: string; port: Port = Port(53); props: set[StampProps] = {}): StampObj {. ...raises: [ValueError], tags: [], forbids: [].}
-
Initializes a StampObj for Plain DNS (StampProto.PlainDNS).
Parameters
- ip is the IPv4 or IPv6 address of the server.
- port is the server port.
- props is a set that represents informal properties about the resolver. See StampProps.
proc parseStamp(uri: string): StampObj {....raises: [ValueError, IOError, OSError], tags: [ReadIOEffect, WriteIOEffect], forbids: [].}
- Parses a string representation of a DNS Stamp contained in uri. Source Edit