| 1 | package dnsscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/" |
| 5 | "encoding/binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/" |
| 6 | "errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/" |
| 7 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 8 | "netscip-go gomod github.com/golang/go/src go1.25.0 net/" |
| 9 | "sortscip-go gomod github.com/golang/go/src go1.25.0 sort/" |
| 10 | "strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/" |
| 11 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 12 | ) |
| 13 | |
| 14 | // SVCBKey is the type of the keys used in the SVCB RR. |
| 15 | type SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# uint16 |
| 16 | |
| 17 | // Keys defined in rfc9460 |
| 18 | const ( |
| 19 | SVCB_MANDATORYscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_MANDATORY. SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# = iota |
| 20 | SVCB_ALPNscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_ALPN. |
| 21 | SVCB_NO_DEFAULT_ALPNscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_NO_DEFAULT_ALPN. |
| 22 | SVCB_PORTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_PORT. |
| 23 | SVCB_IPV4HINTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_IPV4HINT. |
| 24 | SVCB_ECHCONFIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_ECHCONFIG. |
| 25 | SVCB_IPV6HINTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_IPV6HINT. |
| 26 | SVCB_DOHPATHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_DOHPATH. // rfc9461 Section 5 |
| 27 | SVCB_OHTTPscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_OHTTP. // rfc9540 Section 8 |
| 28 | |
| 29 | svcb_RESERVEDscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcb_RESERVED. SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# = 65535 |
| 30 | ) |
| 31 | |
| 32 | var svcbKeyToStringMapscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbKeyToStringMap. = map[SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#]string{ |
| 33 | SVCB_MANDATORYscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_MANDATORY.: "mandatory", |
| 34 | SVCB_ALPNscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_ALPN.: "alpn", |
| 35 | SVCB_NO_DEFAULT_ALPNscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_NO_DEFAULT_ALPN.: "no-default-alpn", |
| 36 | SVCB_PORTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_PORT.: "port", |
| 37 | SVCB_IPV4HINTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_IPV4HINT.: "ipv4hint", |
| 38 | SVCB_ECHCONFIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_ECHCONFIG.: "ech", |
| 39 | SVCB_IPV6HINTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_IPV6HINT.: "ipv6hint", |
| 40 | SVCB_DOHPATHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_DOHPATH.: "dohpath", |
| 41 | SVCB_OHTTPscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_OHTTP.: "ohttp", |
| 42 | } |
| 43 | |
| 44 | var svcbStringToKeyMapscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbStringToKeyMap. = reverseSVCBKeyMapscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/reverseSVCBKeyMap().(svcbKeyToStringMapscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbKeyToStringMap.) |
| 45 | |
| 46 | func reverseSVCBKeyMapscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/reverseSVCBKeyMap().(m map[SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#]string) map[string]SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { |
| 47 | n := make(map[string]SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#, len(m)) |
| 48 | for u, s := range m { |
| 49 | n[s] = u |
| 50 | } |
| 51 | return n |
| 52 | } |
| 53 | |
| 54 | // String takes the numerical code of an SVCB key and returns its name. |
| 55 | // Returns an empty string for reserved keys. |
| 56 | // Accepts unassigned keys as well as experimental/private keys. |
| 57 | func (key SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#String().() string { |
| 58 | if x := svcbKeyToStringMapscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbKeyToStringMap.[key]; x != "" { |
| 59 | return x |
| 60 | } |
| 61 | if key == svcb_RESERVEDscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcb_RESERVED. { |
| 62 | return "" |
| 63 | } |
| 64 | return "key" + strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.FormatUintscip-go gomod github.com/golang/go/src go1.25.0 strconv/FormatUint().(uint64(key), 10) |
| 65 | } |
| 66 | |
| 67 | // svcbStringToKey returns the numerical code of an SVCB key. |
| 68 | // Returns svcb_RESERVED for reserved/invalid keys. |
| 69 | // Accepts unassigned keys as well as experimental/private keys. |
| 70 | func svcbStringToKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbStringToKey().(s string) SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { |
| 71 | if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(s, "key") { |
| 72 | a, err := strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.ParseUintscip-go gomod github.com/golang/go/src go1.25.0 strconv/ParseUint().(s[3:], 10, 16) |
| 73 | // no leading zeros |
| 74 | // key shouldn't be registered |
| 75 | if err != nil || a == 65535 || s[3] == '0' || svcbKeyToStringMapscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbKeyToStringMap.[SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#(a)] != "" { |
| 76 | return svcb_RESERVEDscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcb_RESERVED. |
| 77 | } |
| 78 | return SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#(a) |
| 79 | } |
| 80 | if key, ok := svcbStringToKeyMapscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbStringToKeyMap.[s]; ok { |
| 81 | return key |
| 82 | } |
| 83 | return svcb_RESERVEDscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcb_RESERVED. |
| 84 | } |
| 85 | |
| 86 | func (rr *SVCBscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#parse().(c *zlexerscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#, o string) *ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError# { |
| 87 | l, _ := c.Nextscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#Next().() |
| 88 | i, e := strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.ParseUintscip-go gomod github.com/golang/go/src go1.25.0 strconv/ParseUint().(l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., 10, 16) |
| 89 | if e != nil || l.errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#err. { |
| 90 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "bad SVCB priority", lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 91 | } |
| 92 | rr.Priorityscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Priority. = uint16(i) |
| 93 | |
| 94 | c.Nextscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#Next().() // zBlank |
| 95 | l, _ = c.Nextscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#Next().() // zString |
| 96 | rr.Targetscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Target. = l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token. |
| 97 | |
| 98 | name, nameOk := toAbsoluteNamescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/toAbsoluteName().(l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., o) |
| 99 | if l.errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#err. || !nameOk { |
| 100 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "bad SVCB Target", lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 101 | } |
| 102 | rr.Targetscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Target. = name |
| 103 | |
| 104 | // Values (if any) |
| 105 | l, _ = c.Nextscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#Next().() |
| 106 | var xs []SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# |
| 107 | // Helps require whitespace between pairs. |
| 108 | // Prevents key1000="a"key1001=... |
| 109 | canHaveNextKey := true |
| 110 | for l.valuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#value. != zNewlinescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zNewline. && l.valuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#value. != zEOFscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zEOF. { |
| 111 | switch l.valuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#value. { |
| 112 | case zStringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zString.: |
| 113 | if !canHaveNextKey { |
| 114 | // The key we can now read was probably meant to be |
| 115 | // a part of the last value. |
| 116 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "bad SVCB value quotation", lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 117 | } |
| 118 | |
| 119 | // In key=value pairs, value does not have to be quoted unless value |
| 120 | // contains whitespace. And keys don't need to have values. |
| 121 | // Similarly, keys with an equality signs after them don't need values. |
| 122 | // l.token includes at least up to the first equality sign. |
| 123 | idx := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.IndexBytescip-go gomod github.com/golang/go/src go1.25.0 strings/IndexByte().(l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., '=') |
| 124 | var key, value string |
| 125 | if idx < 0 { |
| 126 | // Key with no value and no equality sign |
| 127 | key = l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token. |
| 128 | } else if idx == 0 { |
| 129 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "bad SVCB key", lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 130 | } else { |
| 131 | key, value = l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token.[:idx], l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token.[idx+1:] |
| 132 | |
| 133 | if value == "" { |
| 134 | // We have a key and an equality sign. Maybe we have nothing |
| 135 | // after "=" or we have a double quote. |
| 136 | l, _ = c.Nextscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#Next().() |
| 137 | if l.valuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#value. == zQuotescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zQuote. { |
| 138 | // Only needed when value ends with double quotes. |
| 139 | // Any value starting with zQuote ends with it. |
| 140 | canHaveNextKey = false |
| 141 | |
| 142 | l, _ = c.Nextscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#Next().() |
| 143 | switch l.valuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#value. { |
| 144 | case zStringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zString.: |
| 145 | // We have a value in double quotes. |
| 146 | value = l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token. |
| 147 | l, _ = c.Nextscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#Next().() |
| 148 | if l.valuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#value. != zQuotescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zQuote. { |
| 149 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "SVCB unterminated value", lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 150 | } |
| 151 | case zQuotescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zQuote.: |
| 152 | // There's nothing in double quotes. |
| 153 | default: |
| 154 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "bad SVCB value", lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | kv := makeSVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/makeSVCBKeyValue().(svcbStringToKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbStringToKey().(key)) |
| 160 | if kv == nil { |
| 161 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "bad SVCB key", lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 162 | } |
| 163 | if err := kv.parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#parse.(value); err != nil { |
| 164 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., wrappedErrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#wrappedErr.: err, lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 165 | } |
| 166 | xs = append(xs, kv) |
| 167 | case zQuotescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zQuote.: |
| 168 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "SVCB key can't contain double quotes", lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 169 | case zBlankscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zBlank.: |
| 170 | canHaveNextKey = true |
| 171 | default: |
| 172 | return &ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#{filescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#file.: l.tokenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/lex#token., errscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#err.: "bad SVCB values", lexscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError#lex.: l} |
| 173 | } |
| 174 | l, _ = c.Nextscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#Next().() |
| 175 | } |
| 176 | |
| 177 | // "In AliasMode, records SHOULD NOT include any SvcParams, and recipients MUST |
| 178 | // ignore any SvcParams that are present." |
| 179 | // However, we don't check rr.Priority == 0 && len(xs) > 0 here |
| 180 | // It is the responsibility of the user of the library to check this. |
| 181 | // This is to encourage the fixing of the source of this error. |
| 182 | |
| 183 | rr.Valuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Value. = xs |
| 184 | return nil |
| 185 | } |
| 186 | |
| 187 | // makeSVCBKeyValue returns an SVCBKeyValue struct with the key or nil for reserved keys. |
| 188 | func makeSVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/makeSVCBKeyValue().(key SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#) SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { |
| 189 | switch key { |
| 190 | case SVCB_MANDATORYscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_MANDATORY.: |
| 191 | return new(SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#) |
| 192 | case SVCB_ALPNscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_ALPN.: |
| 193 | return new(SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#) |
| 194 | case SVCB_NO_DEFAULT_ALPNscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_NO_DEFAULT_ALPN.: |
| 195 | return new(SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#) |
| 196 | case SVCB_PORTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_PORT.: |
| 197 | return new(SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#) |
| 198 | case SVCB_IPV4HINTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_IPV4HINT.: |
| 199 | return new(SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#) |
| 200 | case SVCB_ECHCONFIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_ECHCONFIG.: |
| 201 | return new(SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#) |
| 202 | case SVCB_IPV6HINTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_IPV6HINT.: |
| 203 | return new(SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#) |
| 204 | case SVCB_DOHPATHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_DOHPATH.: |
| 205 | return new(SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#) |
| 206 | case SVCB_OHTTPscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_OHTTP.: |
| 207 | return new(SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#) |
| 208 | case svcb_RESERVEDscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcb_RESERVED.: |
| 209 | return nil |
| 210 | default: |
| 211 | e := new(SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#) |
| 212 | e.KeyCodescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#KeyCode. = key |
| 213 | return e |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | // SVCB RR. See RFC 9460. |
| 218 | type SVCBscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB# struct { |
| 219 | Hdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Hdr. RR_Headerscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header# |
| 220 | Priorityscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Priority. uint16 // If zero, Value must be empty or discarded by the user of this library |
| 221 | Targetscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Target. string `dns:"domain-name"` |
| 222 | Valuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Value. []SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# `dns:"pairs"` |
| 223 | } |
| 224 | |
| 225 | // HTTPS RR. See RFC 9460. Everything valid for SVCB applies to HTTPS as well. |
| 226 | // Except that the HTTPS record is intended for use with the HTTP and HTTPS protocols. |
| 227 | type HTTPSscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HTTPS# struct { |
| 228 | SVCBscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HTTPS#SVCB. |
| 229 | } |
| 230 | |
| 231 | func (rr *HTTPSscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HTTPS#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HTTPS#String().() string { |
| 232 | return rr.SVCBscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HTTPS#SVCB..Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#String().() |
| 233 | } |
| 234 | |
| 235 | func (rr *HTTPSscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HTTPS#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HTTPS#parse().(c *zlexerscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/zlexer#, o string) *ParseErrorscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/ParseError# { |
| 236 | return rr.SVCBscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/HTTPS#SVCB..parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#parse().(c, o) |
| 237 | } |
| 238 | |
| 239 | // SVCBKeyValue defines a key=value pair for the SVCB RR type. |
| 240 | // An SVCB RR can have multiple SVCBKeyValues appended to it. |
| 241 | type SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# interface { |
| 242 | Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#Key.() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# // Key returns the numerical key code. |
| 243 | packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#pack.() ([]byte, error) // pack returns the encoded value. |
| 244 | unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#unpack.([]byte) error // unpack sets the value. |
| 245 | Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#String.() string // String returns the string representation of the value. |
| 246 | parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#parse.(string) error // parse sets the value to the given string representation of the value. |
| 247 | copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#copy.() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# // copy returns a deep-copy of the pair. |
| 248 | lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#len.() int // len returns the length of value in the wire format. |
| 249 | } |
| 250 | |
| 251 | // SVCBMandatory pair adds to required keys that must be interpreted for the RR |
| 252 | // to be functional. If ignored, the whole RRSet must be ignored. |
| 253 | // "port" and "no-default-alpn" are mandatory by default if present, |
| 254 | // so they shouldn't be included here. |
| 255 | // |
| 256 | // It is incumbent upon the user of this library to reject the RRSet if |
| 257 | // or avoid constructing such an RRSet that: |
| 258 | // - "mandatory" is included as one of the keys of mandatory |
| 259 | // - no key is listed multiple times in mandatory |
| 260 | // - all keys listed in mandatory are present |
| 261 | // - escape sequences are not used in mandatory |
| 262 | // - mandatory, when present, lists at least one key |
| 263 | // |
| 264 | // Basic use pattern for creating a mandatory option: |
| 265 | // |
| 266 | // s := &dns.SVCB{Hdr: dns.RR_Header{Name: ".", Rrtype: dns.TypeSVCB, Class: dns.ClassINET}} |
| 267 | // e := new(dns.SVCBMandatory) |
| 268 | // e.Code = []uint16{dns.SVCB_ALPN} |
| 269 | // s.Value = append(s.Value, e) |
| 270 | // t := new(dns.SVCBAlpn) |
| 271 | // t.Alpn = []string{"xmpp-client"} |
| 272 | // s.Value = append(s.Value, t) |
| 273 | type SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory# struct { |
| 274 | Codescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#Code. []SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# |
| 275 | } |
| 276 | |
| 277 | func (*SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return SVCB_MANDATORYscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_MANDATORY. } |
| 278 | |
| 279 | func (s *SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#String().() string { |
| 280 | str := make([]string, len(s.Codescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#Code.)) |
| 281 | for i, e := range s.Codescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#Code. { |
| 282 | str[i] = e.Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#String().() |
| 283 | } |
| 284 | return stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(str, ",") |
| 285 | } |
| 286 | |
| 287 | func (s *SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#pack().() ([]byte, error) { |
| 288 | codes := cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(s.Codescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#Code.) |
| 289 | sortscip-go gomod github.com/golang/go/src go1.25.0 sort/.Slicescip-go gomod github.com/golang/go/src go1.25.0 sort/Slice().(codes, func(i, j int) bool { |
| 290 | return codes[i] < codes[j] |
| 291 | }) |
| 292 | b := make([]byte, 2*len(codes)) |
| 293 | for i, e := range codes { |
| 294 | binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/BigEndian..PutUint16scip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/bigEndian#PutUint16().(b[2*i:], uint16(e)) |
| 295 | } |
| 296 | return b, nil |
| 297 | } |
| 298 | |
| 299 | func (s *SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#unpack().(b []byte) error { |
| 300 | if len(b)%2 != 0 { |
| 301 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbmandatory: value length is not a multiple of 2") |
| 302 | } |
| 303 | codes := make([]SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#, 0, len(b)/2) |
| 304 | for i := 0; i < len(b); i += 2 { |
| 305 | // We assume strictly increasing order. |
| 306 | codes = append(codes, SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#(binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/BigEndian..Uint16scip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/bigEndian#Uint16().(b[i:]))) |
| 307 | } |
| 308 | s.Codescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#Code. = codes |
| 309 | return nil |
| 310 | } |
| 311 | |
| 312 | func (s *SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#parse().(b string) error { |
| 313 | codes := make([]SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#, 0, stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Countscip-go gomod github.com/golang/go/src go1.25.0 strings/Count().(b, ",")+1) |
| 314 | for len(b) > 0 { |
| 315 | var key string |
| 316 | key, b, _ = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Cutscip-go gomod github.com/golang/go/src go1.25.0 strings/Cut().(b, ",") |
| 317 | codes = append(codes, svcbStringToKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbStringToKey().(key)) |
| 318 | } |
| 319 | s.Codescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#Code. = codes |
| 320 | return nil |
| 321 | } |
| 322 | |
| 323 | func (s *SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#len().() int { |
| 324 | return 2 * len(s.Codescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#Code.) |
| 325 | } |
| 326 | |
| 327 | func (s *SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { |
| 328 | return &SVCBMandatoryscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#{cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(s.Codescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBMandatory#Code.)} |
| 329 | } |
| 330 | |
| 331 | // SVCBAlpn pair is used to list supported connection protocols. |
| 332 | // The user of this library must ensure that at least one protocol is listed when alpn is present. |
| 333 | // Protocol IDs can be found at: |
| 334 | // https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids |
| 335 | // Basic use pattern for creating an alpn option: |
| 336 | // |
| 337 | // h := new(dns.HTTPS) |
| 338 | // h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET} |
| 339 | // e := new(dns.SVCBAlpn) |
| 340 | // e.Alpn = []string{"h2", "http/1.1"} |
| 341 | // h.Value = append(h.Value, e) |
| 342 | type SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn# struct { |
| 343 | Alpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Alpn. []string |
| 344 | } |
| 345 | |
| 346 | func (*SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return SVCB_ALPNscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_ALPN. } |
| 347 | |
| 348 | func (s *SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#String().() string { |
| 349 | // An ALPN value is a comma-separated list of values, each of which can be |
| 350 | // an arbitrary binary value. In order to allow parsing, the comma and |
| 351 | // backslash characters are themselves escaped. |
| 352 | // |
| 353 | // However, this escaping is done in addition to the normal escaping which |
| 354 | // happens in zone files, meaning that these values must be |
| 355 | // double-escaped. This looks terrible, so if you see a never-ending |
| 356 | // sequence of backslash in a zone file this may be why. |
| 357 | // |
| 358 | // https://datatracker.ietf.org/doc/html/draft-ietf-dnsop-svcb-https-08#appendix-A.1 |
| 359 | var str stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Builderscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder# |
| 360 | for i, alpn := range s.Alpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Alpn. { |
| 361 | // 4*len(alpn) is the worst case where we escape every character in the alpn as \123, plus 1 byte for the ',' separating the alpn from others |
| 362 | str.Growscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#Grow().(4*len(alpn) + 1) |
| 363 | if i > 0 { |
| 364 | str.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteByte().(',') |
| 365 | } |
| 366 | for j := 0; j < len(alpn); j++ { |
| 367 | e := alpn[j] |
| 368 | if ' ' > e || e > '~' { |
| 369 | str.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteString().(escapeBytescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/escapeByte().(e)) |
| 370 | continue |
| 371 | } |
| 372 | switch e { |
| 373 | // We escape a few characters which may confuse humans or parsers. |
| 374 | case '"', ';', ' ': |
| 375 | str.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteByte().('\\') |
| 376 | str.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteByte().(e) |
| 377 | // The comma and backslash characters themselves must be |
| 378 | // doubly-escaped. We use `\\` for the first backslash and |
| 379 | // the escaped numeric value for the other value. We especially |
| 380 | // don't want a comma in the output. |
| 381 | case ',': |
| 382 | str.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteString().(`\\\044`) |
| 383 | case '\\': |
| 384 | str.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteString().(`\\\092`) |
| 385 | default: |
| 386 | str.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteByte().(e) |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | return str.Stringscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#String().() |
| 391 | } |
| 392 | |
| 393 | func (s *SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#pack().() ([]byte, error) { |
| 394 | // Liberally estimate the size of an alpn as 10 octets |
| 395 | b := make([]byte, 0, 10*len(s.Alpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Alpn.)) |
| 396 | for _, e := range s.Alpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Alpn. { |
| 397 | if e == "" { |
| 398 | return nil, errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbalpn: empty alpn-id") |
| 399 | } |
| 400 | if len(e) > 255 { |
| 401 | return nil, errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbalpn: alpn-id too long") |
| 402 | } |
| 403 | b = append(b, byte(len(e))) |
| 404 | b = append(b, e...) |
| 405 | } |
| 406 | return b, nil |
| 407 | } |
| 408 | |
| 409 | func (s *SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#unpack().(b []byte) error { |
| 410 | // Estimate the size of the smallest alpn as 4 bytes |
| 411 | alpn := make([]string, 0, len(b)/4) |
| 412 | for i := 0; i < len(b); { |
| 413 | length := int(b[i]) |
| 414 | i++ |
| 415 | if i+length > len(b) { |
| 416 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbalpn: alpn array overflowing") |
| 417 | } |
| 418 | alpn = append(alpn, string(b[i:i+length])) |
| 419 | i += length |
| 420 | } |
| 421 | s.Alpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Alpn. = alpn |
| 422 | return nil |
| 423 | } |
| 424 | |
| 425 | func (s *SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#parse().(b string) error { |
| 426 | if len(b) == 0 { |
| 427 | s.Alpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Alpn. = []string{} |
| 428 | return nil |
| 429 | } |
| 430 | |
| 431 | alpn := []string{} |
| 432 | a := []byte{} |
| 433 | for p := 0; p < len(b); { |
| 434 | c, q := nextBytescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/nextByte().(b, p) |
| 435 | if q == 0 { |
| 436 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbalpn: unterminated escape") |
| 437 | } |
| 438 | p += q |
| 439 | // If we find a comma, we have finished reading an alpn. |
| 440 | if c == ',' { |
| 441 | if len(a) == 0 { |
| 442 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbalpn: empty protocol identifier") |
| 443 | } |
| 444 | alpn = append(alpn, string(a)) |
| 445 | a = []byte{} |
| 446 | continue |
| 447 | } |
| 448 | // If it's a backslash, we need to handle a comma-separated list. |
| 449 | if c == '\\' { |
| 450 | dc, dq := nextBytescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/nextByte().(b, p) |
| 451 | if dq == 0 { |
| 452 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbalpn: unterminated escape decoding comma-separated list") |
| 453 | } |
| 454 | if dc != '\\' && dc != ',' { |
| 455 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbalpn: bad escaped character decoding comma-separated list") |
| 456 | } |
| 457 | p += dq |
| 458 | c = dc |
| 459 | } |
| 460 | a = append(a, c) |
| 461 | } |
| 462 | // Add the final alpn. |
| 463 | if len(a) == 0 { |
| 464 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbalpn: last protocol identifier empty") |
| 465 | } |
| 466 | s.Alpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Alpn. = append(alpn, string(a)) |
| 467 | return nil |
| 468 | } |
| 469 | |
| 470 | func (s *SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#len().() int { |
| 471 | var l int |
| 472 | for _, e := range s.Alpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Alpn. { |
| 473 | l += 1 + len(e) |
| 474 | } |
| 475 | return l |
| 476 | } |
| 477 | |
| 478 | func (s *SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { |
| 479 | return &SVCBAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#{cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(s.Alpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBAlpn#Alpn.)} |
| 480 | } |
| 481 | |
| 482 | // SVCBNoDefaultAlpn pair signifies no support for default connection protocols. |
| 483 | // Should be used in conjunction with alpn. |
| 484 | // Basic use pattern for creating a no-default-alpn option: |
| 485 | // |
| 486 | // s := &dns.SVCB{Hdr: dns.RR_Header{Name: ".", Rrtype: dns.TypeSVCB, Class: dns.ClassINET}} |
| 487 | // t := new(dns.SVCBAlpn) |
| 488 | // t.Alpn = []string{"xmpp-client"} |
| 489 | // s.Value = append(s.Value, t) |
| 490 | // e := new(dns.SVCBNoDefaultAlpn) |
| 491 | // s.Value = append(s.Value, e) |
| 492 | type SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn# struct{} |
| 493 | |
| 494 | func (*SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return SVCB_NO_DEFAULT_ALPNscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_NO_DEFAULT_ALPN. } |
| 495 | func (*SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { return &SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#{} } |
| 496 | func (*SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#pack().() ([]byte, error) { return []byte{}, nil } |
| 497 | func (*SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#String().() string { return "" } |
| 498 | func (*SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#len().() int { return 0 } |
| 499 | |
| 500 | func (*SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#unpack().(b []byte) error { |
| 501 | if len(b) != 0 { |
| 502 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbnodefaultalpn: no-default-alpn must have no value") |
| 503 | } |
| 504 | return nil |
| 505 | } |
| 506 | |
| 507 | func (*SVCBNoDefaultAlpnscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBNoDefaultAlpn#parse().(b string) error { |
| 508 | if b != "" { |
| 509 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbnodefaultalpn: no-default-alpn must have no value") |
| 510 | } |
| 511 | return nil |
| 512 | } |
| 513 | |
| 514 | // SVCBPort pair defines the port for connection. |
| 515 | // Basic use pattern for creating a port option: |
| 516 | // |
| 517 | // s := &dns.SVCB{Hdr: dns.RR_Header{Name: ".", Rrtype: dns.TypeSVCB, Class: dns.ClassINET}} |
| 518 | // e := new(dns.SVCBPort) |
| 519 | // e.Port = 80 |
| 520 | // s.Value = append(s.Value, e) |
| 521 | type SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort# struct { |
| 522 | Portscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#Port. uint16 |
| 523 | } |
| 524 | |
| 525 | func (*SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return SVCB_PORTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_PORT. } |
| 526 | func (*SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#len().() int { return 2 } |
| 527 | func (s *SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#String().() string { return strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.FormatUintscip-go gomod github.com/golang/go/src go1.25.0 strconv/FormatUint().(uint64(s.Portscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#Port.), 10) } |
| 528 | func (s *SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { return &SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#{s.Portscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#Port.} } |
| 529 | |
| 530 | func (s *SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#unpack().(b []byte) error { |
| 531 | if len(b) != 2 { |
| 532 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbport: port length is not exactly 2 octets") |
| 533 | } |
| 534 | s.Portscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#Port. = binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/BigEndian..Uint16scip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/bigEndian#Uint16().(b) |
| 535 | return nil |
| 536 | } |
| 537 | |
| 538 | func (s *SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#pack().() ([]byte, error) { |
| 539 | b := make([]byte, 2) |
| 540 | binaryscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/BigEndian..PutUint16scip-go gomod github.com/golang/go/src go1.25.0 `encoding/binary`/bigEndian#PutUint16().(b, s.Portscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#Port.) |
| 541 | return b, nil |
| 542 | } |
| 543 | |
| 544 | func (s *SVCBPortscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#parse().(b string) error { |
| 545 | port, err := strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.ParseUintscip-go gomod github.com/golang/go/src go1.25.0 strconv/ParseUint().(b, 10, 16) |
| 546 | if err != nil { |
| 547 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbport: port out of range") |
| 548 | } |
| 549 | s.Portscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBPort#Port. = uint16(port) |
| 550 | return nil |
| 551 | } |
| 552 | |
| 553 | // SVCBIPv4Hint pair suggests an IPv4 address which may be used to open connections |
| 554 | // if A and AAAA record responses for SVCB's Target domain haven't been received. |
| 555 | // In that case, optionally, A and AAAA requests can be made, after which the connection |
| 556 | // to the hinted IP address may be terminated and a new connection may be opened. |
| 557 | // Basic use pattern for creating an ipv4hint option: |
| 558 | // |
| 559 | // h := new(dns.HTTPS) |
| 560 | // h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET} |
| 561 | // e := new(dns.SVCBIPv4Hint) |
| 562 | // e.Hint = []net.IP{net.IPv4(1,1,1,1).To4()} |
| 563 | // |
| 564 | // Or |
| 565 | // |
| 566 | // e.Hint = []net.IP{net.ParseIP("1.1.1.1").To4()} |
| 567 | // h.Value = append(h.Value, e) |
| 568 | type SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint# struct { |
| 569 | Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint. []netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP# |
| 570 | } |
| 571 | |
| 572 | func (*SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return SVCB_IPV4HINTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_IPV4HINT. } |
| 573 | func (s *SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#len().() int { return 4 * len(s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint.) } |
| 574 | |
| 575 | func (s *SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#pack().() ([]byte, error) { |
| 576 | b := make([]byte, 0, 4*len(s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint.)) |
| 577 | for _, e := range s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint. { |
| 578 | x := e.To4scip-go gomod github.com/golang/go/src go1.25.0 net/IP#To4().() |
| 579 | if x == nil { |
| 580 | return nil, errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv4hint: expected ipv4, hint is ipv6") |
| 581 | } |
| 582 | b = append(b, x...) |
| 583 | } |
| 584 | return b, nil |
| 585 | } |
| 586 | |
| 587 | func (s *SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#unpack().(b []byte) error { |
| 588 | if len(b) == 0 || len(b)%4 != 0 { |
| 589 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv4hint: ipv4 address byte array length is not a multiple of 4") |
| 590 | } |
| 591 | b = cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(b) |
| 592 | x := make([]netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP#, 0, len(b)/4) |
| 593 | for i := 0; i < len(b); i += 4 { |
| 594 | x = append(x, netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP#(b[i:i+4])) |
| 595 | } |
| 596 | s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint. = x |
| 597 | return nil |
| 598 | } |
| 599 | |
| 600 | func (s *SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#String().() string { |
| 601 | str := make([]string, len(s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint.)) |
| 602 | for i, e := range s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint. { |
| 603 | x := e.To4scip-go gomod github.com/golang/go/src go1.25.0 net/IP#To4().() |
| 604 | if x == nil { |
| 605 | return "<nil>" |
| 606 | } |
| 607 | str[i] = x.Stringscip-go gomod github.com/golang/go/src go1.25.0 net/IP#String().() |
| 608 | } |
| 609 | return stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(str, ",") |
| 610 | } |
| 611 | |
| 612 | func (s *SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#parse().(b string) error { |
| 613 | if b == "" { |
| 614 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv4hint: empty hint") |
| 615 | } |
| 616 | if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.25.0 strings/Contains().(b, ":") { |
| 617 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv4hint: expected ipv4, got ipv6") |
| 618 | } |
| 619 | |
| 620 | hint := make([]netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP#, 0, stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Countscip-go gomod github.com/golang/go/src go1.25.0 strings/Count().(b, ",")+1) |
| 621 | for len(b) > 0 { |
| 622 | var e string |
| 623 | e, b, _ = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Cutscip-go gomod github.com/golang/go/src go1.25.0 strings/Cut().(b, ",") |
| 624 | ip := netscip-go gomod github.com/golang/go/src go1.25.0 net/.ParseIPscip-go gomod github.com/golang/go/src go1.25.0 net/ParseIP().(e).To4scip-go gomod github.com/golang/go/src go1.25.0 net/IP#To4().() |
| 625 | if ip == nil { |
| 626 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv4hint: bad ip") |
| 627 | } |
| 628 | hint = append(hint, ip) |
| 629 | } |
| 630 | s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint. = hint |
| 631 | return nil |
| 632 | } |
| 633 | |
| 634 | func (s *SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { |
| 635 | hint := make([]netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP#, len(s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint.)) |
| 636 | for i, ip := range s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint. { |
| 637 | hint[i] = cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(ip) |
| 638 | } |
| 639 | return &SVCBIPv4Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#{Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv4Hint#Hint.: hint} |
| 640 | } |
| 641 | |
| 642 | // SVCBECHConfig pair contains the ECHConfig structure defined in draft-ietf-tls-esni [RFC xxxx]. |
| 643 | // Basic use pattern for creating an ech option: |
| 644 | // |
| 645 | // h := new(dns.HTTPS) |
| 646 | // h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET} |
| 647 | // e := new(dns.SVCBECHConfig) |
| 648 | // e.ECH = []byte{0xfe, 0x08, ...} |
| 649 | // h.Value = append(h.Value, e) |
| 650 | type SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig# struct { |
| 651 | ECHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#ECH. []byte // Specifically ECHConfigList including the redundant length prefix |
| 652 | } |
| 653 | |
| 654 | func (*SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return SVCB_ECHCONFIGscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_ECHCONFIG. } |
| 655 | func (s *SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#String().() string { return toBase64scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/toBase64().(s.ECHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#ECH.) } |
| 656 | func (s *SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#len().() int { return len(s.ECHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#ECH.) } |
| 657 | |
| 658 | func (s *SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#pack().() ([]byte, error) { |
| 659 | return cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(s.ECHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#ECH.), nil |
| 660 | } |
| 661 | |
| 662 | func (s *SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { |
| 663 | return &SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#{cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(s.ECHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#ECH.)} |
| 664 | } |
| 665 | |
| 666 | func (s *SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#unpack().(b []byte) error { |
| 667 | s.ECHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#ECH. = cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(b) |
| 668 | return nil |
| 669 | } |
| 670 | |
| 671 | func (s *SVCBECHConfigscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#parse().(b string) error { |
| 672 | x, err := fromBase64scip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/fromBase64().([]byte(b)) |
| 673 | if err != nil { |
| 674 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbech: bad base64 ech") |
| 675 | } |
| 676 | s.ECHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBECHConfig#ECH. = x |
| 677 | return nil |
| 678 | } |
| 679 | |
| 680 | // SVCBIPv6Hint pair suggests an IPv6 address which may be used to open connections |
| 681 | // if A and AAAA record responses for SVCB's Target domain haven't been received. |
| 682 | // In that case, optionally, A and AAAA requests can be made, after which the |
| 683 | // connection to the hinted IP address may be terminated and a new connection may be opened. |
| 684 | // Basic use pattern for creating an ipv6hint option: |
| 685 | // |
| 686 | // h := new(dns.HTTPS) |
| 687 | // h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET} |
| 688 | // e := new(dns.SVCBIPv6Hint) |
| 689 | // e.Hint = []net.IP{net.ParseIP("2001:db8::1")} |
| 690 | // h.Value = append(h.Value, e) |
| 691 | type SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint# struct { |
| 692 | Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint. []netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP# |
| 693 | } |
| 694 | |
| 695 | func (*SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return SVCB_IPV6HINTscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_IPV6HINT. } |
| 696 | func (s *SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#len().() int { return 16 * len(s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint.) } |
| 697 | |
| 698 | func (s *SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#pack().() ([]byte, error) { |
| 699 | b := make([]byte, 0, 16*len(s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint.)) |
| 700 | for _, e := range s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint. { |
| 701 | if len(e) != netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPv6lenscip-go gomod github.com/golang/go/src go1.25.0 net/IPv6len. || e.To4scip-go gomod github.com/golang/go/src go1.25.0 net/IP#To4().() != nil { |
| 702 | return nil, errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv6hint: expected ipv6, hint is ipv4") |
| 703 | } |
| 704 | b = append(b, e...) |
| 705 | } |
| 706 | return b, nil |
| 707 | } |
| 708 | |
| 709 | func (s *SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#unpack().(b []byte) error { |
| 710 | if len(b) == 0 || len(b)%16 != 0 { |
| 711 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bas svcbipv6hint: ipv6 address byte array length not a multiple of 16") |
| 712 | } |
| 713 | b = cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(b) |
| 714 | x := make([]netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP#, 0, len(b)/16) |
| 715 | for i := 0; i < len(b); i += 16 { |
| 716 | ip := netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP#(b[i : i+16]) |
| 717 | if ip.To4scip-go gomod github.com/golang/go/src go1.25.0 net/IP#To4().() != nil { |
| 718 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv6hint: expected ipv6, got ipv4") |
| 719 | } |
| 720 | x = append(x, ip) |
| 721 | } |
| 722 | s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint. = x |
| 723 | return nil |
| 724 | } |
| 725 | |
| 726 | func (s *SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#String().() string { |
| 727 | str := make([]string, len(s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint.)) |
| 728 | for i, e := range s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint. { |
| 729 | if x := e.To4scip-go gomod github.com/golang/go/src go1.25.0 net/IP#To4().(); x != nil { |
| 730 | return "<nil>" |
| 731 | } |
| 732 | str[i] = e.Stringscip-go gomod github.com/golang/go/src go1.25.0 net/IP#String().() |
| 733 | } |
| 734 | return stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(str, ",") |
| 735 | } |
| 736 | |
| 737 | func (s *SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#parse().(b string) error { |
| 738 | if b == "" { |
| 739 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv6hint: empty hint") |
| 740 | } |
| 741 | |
| 742 | hint := make([]netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP#, 0, stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Countscip-go gomod github.com/golang/go/src go1.25.0 strings/Count().(b, ",")+1) |
| 743 | for len(b) > 0 { |
| 744 | var e string |
| 745 | e, b, _ = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Cutscip-go gomod github.com/golang/go/src go1.25.0 strings/Cut().(b, ",") |
| 746 | ip := netscip-go gomod github.com/golang/go/src go1.25.0 net/.ParseIPscip-go gomod github.com/golang/go/src go1.25.0 net/ParseIP().(e) |
| 747 | if ip == nil { |
| 748 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv6hint: bad ip") |
| 749 | } |
| 750 | if ip.To4scip-go gomod github.com/golang/go/src go1.25.0 net/IP#To4().() != nil { |
| 751 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbipv6hint: expected ipv6, got ipv4-mapped-ipv6") |
| 752 | } |
| 753 | hint = append(hint, ip) |
| 754 | } |
| 755 | s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint. = hint |
| 756 | return nil |
| 757 | } |
| 758 | |
| 759 | func (s *SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { |
| 760 | hint := make([]netscip-go gomod github.com/golang/go/src go1.25.0 net/.IPscip-go gomod github.com/golang/go/src go1.25.0 net/IP#, len(s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint.)) |
| 761 | for i, ip := range s.Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint. { |
| 762 | hint[i] = cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(ip) |
| 763 | } |
| 764 | return &SVCBIPv6Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#{Hintscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBIPv6Hint#Hint.: hint} |
| 765 | } |
| 766 | |
| 767 | // SVCBDoHPath pair is used to indicate the URI template that the |
| 768 | // clients may use to construct a DNS over HTTPS URI. |
| 769 | // |
| 770 | // See RFC 9461 (https://datatracker.ietf.org/doc/html/rfc9461) |
| 771 | // and RFC 9462 (https://datatracker.ietf.org/doc/html/rfc9462). |
| 772 | // |
| 773 | // A basic example of using the dohpath option together with the alpn |
| 774 | // option to indicate support for DNS over HTTPS on a certain path: |
| 775 | // |
| 776 | // s := new(dns.SVCB) |
| 777 | // s.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeSVCB, Class: dns.ClassINET} |
| 778 | // e := new(dns.SVCBAlpn) |
| 779 | // e.Alpn = []string{"h2", "h3"} |
| 780 | // p := new(dns.SVCBDoHPath) |
| 781 | // p.Template = "/dns-query{?dns}" |
| 782 | // s.Value = append(s.Value, e, p) |
| 783 | // |
| 784 | // The parsing currently doesn't validate that Template is a valid |
| 785 | // RFC 6570 URI template. |
| 786 | type SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath# struct { |
| 787 | Templatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#Template. string |
| 788 | } |
| 789 | |
| 790 | func (*SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return SVCB_DOHPATHscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_DOHPATH. } |
| 791 | func (s *SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#String().() string { return svcbParamToStrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbParamToStr().([]byte(s.Templatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#Template.)) } |
| 792 | func (s *SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#len().() int { return len(s.Templatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#Template.) } |
| 793 | func (s *SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#pack().() ([]byte, error) { return []byte(s.Templatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#Template.), nil } |
| 794 | |
| 795 | func (s *SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#unpack().(b []byte) error { |
| 796 | s.Templatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#Template. = string(b) |
| 797 | return nil |
| 798 | } |
| 799 | |
| 800 | func (s *SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#parse().(b string) error { |
| 801 | template, err := svcbParseParamscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbParseParam().(b) |
| 802 | if err != nil { |
| 803 | return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("bad svcbdohpath: %w", err) |
| 804 | } |
| 805 | s.Templatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#Template. = string(template) |
| 806 | return nil |
| 807 | } |
| 808 | |
| 809 | func (s *SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { |
| 810 | return &SVCBDoHPathscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#{ |
| 811 | Templatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#Template.: s.Templatescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBDoHPath#Template., |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | // The "ohttp" SvcParamKey is used to indicate that a service described in a SVCB RR |
| 816 | // can be accessed as a target using an associated gateway. |
| 817 | // Both the presentation and wire-format values for the "ohttp" parameter MUST be empty. |
| 818 | // |
| 819 | // See RFC 9460 (https://datatracker.ietf.org/doc/html/rfc9460/) |
| 820 | // and RFC 9230 (https://datatracker.ietf.org/doc/html/rfc9230/) |
| 821 | // |
| 822 | // A basic example of using the dohpath option together with the alpn |
| 823 | // option to indicate support for DNS over HTTPS on a certain path: |
| 824 | // |
| 825 | // s := new(dns.SVCB) |
| 826 | // s.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeSVCB, Class: dns.ClassINET} |
| 827 | // e := new(dns.SVCBAlpn) |
| 828 | // e.Alpn = []string{"h2", "h3"} |
| 829 | // p := new(dns.SVCBOhttp) |
| 830 | // s.Value = append(s.Value, e, p) |
| 831 | type SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp# struct{} |
| 832 | |
| 833 | func (*SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return SVCB_OHTTPscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB_OHTTP. } |
| 834 | func (*SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { return &SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#{} } |
| 835 | func (*SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#pack().() ([]byte, error) { return []byte{}, nil } |
| 836 | func (*SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#String().() string { return "" } |
| 837 | func (*SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#len().() int { return 0 } |
| 838 | |
| 839 | func (*SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#unpack().(b []byte) error { |
| 840 | if len(b) != 0 { |
| 841 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbotthp: svcbotthp must have no value") |
| 842 | } |
| 843 | return nil |
| 844 | } |
| 845 | |
| 846 | func (*SVCBOhttpscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBOhttp#parse().(b string) error { |
| 847 | if b != "" { |
| 848 | return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad svcbotthp: svcbotthp must have no value") |
| 849 | } |
| 850 | return nil |
| 851 | } |
| 852 | |
| 853 | // SVCBLocal pair is intended for experimental/private use. The key is recommended |
| 854 | // to be in the range [SVCB_PRIVATE_LOWER, SVCB_PRIVATE_UPPER]. |
| 855 | // Basic use pattern for creating a keyNNNNN option: |
| 856 | // |
| 857 | // h := new(dns.HTTPS) |
| 858 | // h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET} |
| 859 | // e := new(dns.SVCBLocal) |
| 860 | // e.KeyCode = 65400 |
| 861 | // e.Data = []byte("abc") |
| 862 | // h.Value = append(h.Value, e) |
| 863 | type SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal# struct { |
| 864 | KeyCodescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#KeyCode. SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# // Never 65535 or any assigned keys. |
| 865 | Datascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#Data. []byte // All byte sequences are allowed. |
| 866 | } |
| 867 | |
| 868 | func (s *SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#) Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#Key().() SVCBKeyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey# { return s.KeyCodescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#KeyCode. } |
| 869 | func (s *SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#String().() string { return svcbParamToStrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbParamToStr().(s.Datascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#Data.) } |
| 870 | func (s *SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#) packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#pack().() ([]byte, error) { return cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(s.Datascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#Data.), nil } |
| 871 | func (s *SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#) lenscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#len().() int { return len(s.Datascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#Data.) } |
| 872 | |
| 873 | func (s *SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#) unpackscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#unpack().(b []byte) error { |
| 874 | s.Datascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#Data. = cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(b) |
| 875 | return nil |
| 876 | } |
| 877 | |
| 878 | func (s *SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#) parsescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#parse().(b string) error { |
| 879 | data, err := svcbParseParamscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbParseParam().(b) |
| 880 | if err != nil { |
| 881 | return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("bad svcblocal: svcb private/experimental key %w", err) |
| 882 | } |
| 883 | s.Datascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#Data. = data |
| 884 | return nil |
| 885 | } |
| 886 | |
| 887 | func (s *SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#) copyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#copy().() SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue# { |
| 888 | return &SVCBLocalscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#{s.KeyCodescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#KeyCode., cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(s.Datascip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBLocal#Data.)} |
| 889 | } |
| 890 | |
| 891 | func (rr *SVCBscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#) Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#String().() string { |
| 892 | s := rr.Hdrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Hdr..Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/RR_Header#String().() + |
| 893 | strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.Itoascip-go gomod github.com/golang/go/src go1.25.0 strconv/Itoa().(int(rr.Priorityscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Priority.)) + " " + |
| 894 | sprintNamescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/sprintName().(rr.Targetscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Target.) |
| 895 | for _, e := range rr.Valuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCB#Value. { |
| 896 | s += " " + e.Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#Key.().Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKey#String().() + "=\"" + e.Stringscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#String.() + "\"" |
| 897 | } |
| 898 | return s |
| 899 | } |
| 900 | |
| 901 | // areSVCBPairArraysEqual checks if SVCBKeyValue arrays are equal after sorting their |
| 902 | // copies. arrA and arrB have equal lengths, otherwise zduplicate.go wouldn't call this function. |
| 903 | func areSVCBPairArraysEqualscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/areSVCBPairArraysEqual().(a []SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#, b []SVCBKeyValuescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#) bool { |
| 904 | a = cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(a) |
| 905 | b = cloneSlicescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/cloneSlice().(b) |
| 906 | sortscip-go gomod github.com/golang/go/src go1.25.0 sort/.Slicescip-go gomod github.com/golang/go/src go1.25.0 sort/Slice().(a, func(i, j int) bool { return a[i].Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#Key.() < a[j].Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#Key.() }) |
| 907 | sortscip-go gomod github.com/golang/go/src go1.25.0 sort/.Slicescip-go gomod github.com/golang/go/src go1.25.0 sort/Slice().(b, func(i, j int) bool { return b[i].Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#Key.() < b[j].Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#Key.() }) |
| 908 | for i, e := range a { |
| 909 | if e.Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#Key.() != b[i].Keyscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#Key.() { |
| 910 | return false |
| 911 | } |
| 912 | b1, err1 := e.packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#pack.() |
| 913 | b2, err2 := b[i].packscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/SVCBKeyValue#pack.() |
| 914 | if err1 != nil || err2 != nil || !bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Equalscip-go gomod github.com/golang/go/src go1.25.0 bytes/Equal().(b1, b2) { |
| 915 | return false |
| 916 | } |
| 917 | } |
| 918 | return true |
| 919 | } |
| 920 | |
| 921 | // svcbParamStr converts the value of an SVCB parameter into a DNS presentation-format string. |
| 922 | func svcbParamToStrscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbParamToStr().(s []byte) string { |
| 923 | var str stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Builderscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder# |
| 924 | str.Growscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#Grow().(4 * len(s)) |
| 925 | for _, e := range s { |
| 926 | if ' ' <= e && e <= '~' { |
| 927 | switch e { |
| 928 | case '"', ';', ' ', '\\': |
| 929 | str.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteByte().('\\') |
| 930 | str.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteByte().(e) |
| 931 | default: |
| 932 | str.WriteBytescip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteByte().(e) |
| 933 | } |
| 934 | } else { |
| 935 | str.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#WriteString().(escapeBytescip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/escapeByte().(e)) |
| 936 | } |
| 937 | } |
| 938 | return str.Stringscip-go gomod github.com/golang/go/src go1.25.0 strings/Builder#String().() |
| 939 | } |
| 940 | |
| 941 | // svcbParseParam parses a DNS presentation-format string into an SVCB parameter value. |
| 942 | func svcbParseParamscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/svcbParseParam().(b string) ([]byte, error) { |
| 943 | data := make([]byte, 0, len(b)) |
| 944 | for i := 0; i < len(b); { |
| 945 | if b[i] != '\\' { |
| 946 | data = append(data, b[i]) |
| 947 | i++ |
| 948 | continue |
| 949 | } |
| 950 | if i+1 == len(b) { |
| 951 | return nil, errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("escape unterminated") |
| 952 | } |
| 953 | if isDigitscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/isDigit().(b[i+1]) { |
| 954 | if i+3 < len(b) && isDigitscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/isDigit().(b[i+2]) && isDigitscip-go gomod github.com/miekg/dns . `github.com/miekg/dns`/isDigit().(b[i+3]) { |
| 955 | a, err := strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.ParseUintscip-go gomod github.com/golang/go/src go1.25.0 strconv/ParseUint().(b[i+1:i+4], 10, 8) |
| 956 | if err == nil { |
| 957 | i += 4 |
| 958 | data = append(data, byte(a)) |
| 959 | continue |
| 960 | } |
| 961 | } |
| 962 | return nil, errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("bad escaped octet") |
| 963 | } else { |
| 964 | data = append(data, b[i+1]) |
| 965 | i += 2 |
| 966 | } |
| 967 | } |
| 968 | return data, nil |
| 969 | } |