Documentation
¶
Overview ¶
Package svcb deals with all the intricacies of the SVCB/HTTPS RR. All the sub-types ([Pairs]) used in the RR are defined here.
Index ¶
- Constants
- func KeyToPair(k uint16) func() Pair
- func KeyToString(k uint16) string
- func Pack(pairs []Pair, msg []byte, off int) (off1 int, err error)
- func PairToKey(p Pair) uint16
- func Parse(p Pair, b, o string) error
- func StringToKey(s string) uint16
- type ALPN
- type DOHPATH
- type ECHCONFIG
- type IPV4HINT
- type IPV6HINT
- type LOCAL
- type MANDATORY
- type NODEFAULTALPN
- type OHTTP
- type PORT
- type Pair
Constants ¶
const ( KeyMandatory uint16 = iota KeyAlpn KeyNoDefaultALPN KeyPort KeyIPv4Hint KeyEchConfig KeyIPv6Hint KeyDohPath // See RFC 9461 Section 5. KeyOhttp // See RFC 9540 Section 8. KeyReserved uint16 = 65535 )
Keys as defined in RFC 9460.
Variables ¶
This section is empty.
Functions ¶
func KeyToString ¶
KeyToString return the string representation for k. For KeyReserved the empty string is returned. For unknown keys "key"+value is returned, see section 2.1 of RFC 9460.
func StringToKey ¶
StringtoKey is the reverse of KeyToString and takes keyXXXX into account.
Types ¶
type ALPN ¶
type ALPN struct {
Alpn []string
}
ALPN pair is used to list supported connection protocols. The user of this library must ensure that at least one protocol is listed when alpn is present. Protocol IDs can be found at: https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids Basic use pattern for creating an ALPN option, in a SVCB RR called s:
e := svcb.ALPN{Alpn: []string{"h2", "http/1.1"}}
s.Value = append(s.Value, e)
type DOHPATH ¶
type DOHPATH struct {
Template string
}
DOHPATH pair is used to indicate the URI template that the clients may use to construct a DNS over HTTPS URI.
See RFC 9461 (https://datatracker.ietf.org/doc/html/rfc9461) and RFC 9462 (https://datatracker.ietf.org/doc/html/rfc9462).
A basic example of using the dohpath option together with the alpn option to indicate support for DNS over HTTPS on a certain path:
e := &svcb.ALPN{Alpn: []string{"h2", "h3"}}
p := &svcb.DOHPATH{Template: "/dns-query{?dns}"}
s.Value = append(s.Value, e, p)
The parsing currently doesn't validate that Template is a valid RFC 6570 URI template.
type ECHCONFIG ¶
type ECHCONFIG struct {
ECH []byte // Specifically ECHConfigList including the redundant length prefix.
}
ECHCONFIG pair contains the ECHConfig structure defined in draft-ietf-tls-esni [RFC xxxx]. Basic use pattern for creating an ech option:
h := &dns.HTTPS{Hdr: dns.Header{Name: ".", Class: dns.ClassINET}}
e := &svcb.ECHCONFIG{ECH: []byte{0xfe, 0x08, ...}}
h.Value = append(h.Value, e)
type IPV4HINT ¶
IPV4HINT pair suggests an IPv4 address which may be used to open connections if A and AAAA record responses for SVCB's Target domain haven't been received. In that case, optionally, A and AAAA requests can be made, after which the connection to the hinted IP address may be terminated and a new connection may be opened. Basic use pattern for creating an ipv4hint option:
h := &dns.HTTPS{Hdr: dns.Header{Name: ".", Class: dns.ClassINET}}
e := &svcb.IPV4HINT{Hint: []netip.Addr{netip.MustParseAddr("1.1.1.1")}}
Or
e.Hint = []netip.Addr{netip.MustParseAddr("1.1.1.1")}
h.Value = append(h.Value, e)
type IPV6HINT ¶
IPV6HINT pair suggests an IPv6 address which may be used to open connections if A and AAAA record responses for SVCB's Target domain haven't been received. In that case, optionally, A and AAAA requests can be made, after which the connection to the hinted IP address may be terminated and a new connection may be opened. Basic use pattern for creating an ipv6hint option:
h := &dns.HTTPS{Hdr: dns.Header{Name: ".", Class: dns.ClassINET}}
e := &svcb.IPV6HINT{Hint: []netip.Addr{netip.MustParseAddr("2001:db8::1")}}
h.Value = append(h.Value, e)
type LOCAL ¶
type LOCAL struct {
KeyCode uint16 // Just like as in RFC 5559.
Data []byte // All byte sequences are allowed.
}
LOCAL pair is intended for experimental/private use. The key is recommended to be in the range [SVCB_PRIVATE_LOWER, SVCB_PRIVATE_UPPER]. Basic use pattern for creating a keyNNNNN option:
h := &dns.HTTPS{Hdr: dns.Header{Name: ".", Class: dns.ClassINET}}
e := &svcb.LOCAL{KeyCode: 65400, Data: []byte("abc")}
h.Value = append(h.Value, e)
type MANDATORY ¶
type MANDATORY struct {
Key []uint16
}
MANDATORY pair adds to required keys that must be interpreted for the RR to be functional. If ignored, the whole RRSet must be ignored. "port" and "no-default-alpn" are mandatory by default if present, so they shouldn't be included here.
It is incumbent upon the user of this library to reject the RRSet if or avoid constructing such an RRSet that:
- "mandatory" is included as one of the keys of mandatory
- no key is listed multiple times in mandatory
- all keys listed in mandatory are present
- escape sequences are not used in mandatory
- mandatory, when present, lists at least one key
Basic use pattern for creating a mandatory option in a SVCB RR, called s:
s.Value = append(s.Value, &svcb.MANDATORY{})
t := &svcb.ALPN{Alpn: []string{"xmpp-client"}}
s.Value = append(s.Value, t)
type NODEFAULTALPN ¶
type NODEFAULTALPN struct{}
NODEFAULTALPN pair signifies no support for default connection protocols. Should be used in conjunction with alpn. Basic use pattern for creating a no-default-alpn option:
t := &svcb.ALPN{Alpn: []string{"xmpp-client"}}
s.Value = append(s.Value, t)
e := &svcb.NODEFAULTALPN{}
s.Value = append(s.Value, e)
func (*NODEFAULTALPN) Clone ¶ added in v0.5.4
func (*NODEFAULTALPN) Clone() Pair
func (*NODEFAULTALPN) Len ¶
func (*NODEFAULTALPN) Len() int
func (*NODEFAULTALPN) String ¶
func (*NODEFAULTALPN) String() string
type OHTTP ¶
type OHTTP struct{}
The "ohttp" SvcParamKey is used to indicate that a service described in a SVCB RR can be accessed as a target using an associated gateway. Both the presentation and wire-format values for the "ohttp" parameter MUST be empty.
See RFC 9460 (https://datatracker.ietf.org/doc/html/rfc9460/) and RFC 9230 (https://datatracker.ietf.org/doc/html/rfc9230/)
A basic example of using the dohpath option together with the alpn option to indicate support for DNS over HTTPS on a certain path:
e := &dns.ALPN{Alpn: []string{"h2", "h3"}}
p := &svcb.OHTTP{}
s.Value = append(s.Value, e, p)
type PORT ¶
type PORT struct {
Port uint16
}
PORT pair defines the port for connection. Basic use pattern for creating a port option:
s.Value = append(s.Value, &svcb.PORT{Port: 80})
type Pair ¶
type Pair interface {
String() string // String returns the string representation of the value.
Len() int // Len returns the length of value in the wire format.
Clone() Pair // Clone returns a deep copy of the Pair.
}
Pair defines a key=value pair for the SVCB RR type. An SVCB RR can have multiple pairs appended to it. The numerical key code is derived from the type, see PairToKey.