Commit 51c0754
authored
DNS: add the SVCB/HTTPS resource records (#4217)
https://www.rfc-editor.org/rfc/rfc9460.html
```
>>> p = dns_resolve('_dns.one.one.one.one', 'SVCB', raw=True)
>>> p.an[0].show()
rrname = b'_dns.one.one.one.one.'
type = SVCB
rclass = IN
ttl = 300
rdlen = None
svc_priority= 1
target_name= b'one.one.one.one.'
\svc_params\
|###[ SvcParam ]###
| key = alpn
| len = 6
| value = [b'h3', b'h2']
|###[ SvcParam ]###
| key = dohpath
| len = 16
| value = b'/dns-query{?dns}'
>>> p.an[1].show()
rrname = b'_dns.one.one.one.one.'
type = SVCB
rclass = IN
ttl = 300
rdlen = None
svc_priority= 2
target_name= b'one.one.one.one.'
\svc_params\
|###[ SvcParam ]###
| key = alpn
| len = 4
| value = [b'dot']
```
The patch was also cross-checked with Wireshark:
```
>>> alpn = SvcParam(key='alpn', value=['h3', 'h2'])
>>> ipv4hint = SvcParam(key='ipv4hint', value=['104.16.132.229', '104.16.133.229'])
>>> ipv6hint = SvcParam(key='ipv6hint', value=['2606:4700::6810:84e5', '2606:4700::6810:85e5'])
>>> httpsrr = DNSRRHTTPS(rrname='cloudflare.com', svc_priority=1, ttl=62, target_name='.', svc_params=[alpn, ipv4hint, ipv6hint])
>>> tdecode(Ether()/IP()/UDP()/DNS(qd=[], an=[httpsrr]))
...
Type: HTTPS (HTTPS Specific Service Endpoints) (65)
Class: IN (0x0001)
Time to live: 62 (1 minute, 2 seconds)
Data length: 61
SvcPriority: 1
TargetName: <Root>
SvcParam: alpn=h3,h2
SvcParamKey: alpn (1)
SvcParamValue length: 6
ALPN length: 2
ALPN: h3
ALPN length: 2
ALPN: h2
SvcParam: ipv4hint=104.16.132.229,104.16.133.229
SvcParamKey: ipv4hint (4)
SvcParamValue length: 8
IP: 104.16.132.229
IP: 104.16.133.229
SvcParam: ipv6hint=2606:4700::6810:84e5,2606:4700::6810:85e5
SvcParamKey: ipv6hint (6)
SvcParamValue length: 32
IP: 2606:4700::6810:84e5
IP: 2606:4700::6810:85e5
```
This patch was prompted by systemd/systemd#30661 (comment)
and was used to parse SVCB/HTTPS RRs produced by an upstream fuzz target and also build
packets sent by another fuzzer to resolved.1 parent 084400f commit 51c0754
2 files changed
+148
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
887 | 887 | | |
888 | 888 | | |
889 | 889 | | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
890 | 964 | | |
891 | 965 | | |
892 | 966 | | |
| |||
976 | 1050 | | |
977 | 1051 | | |
978 | 1052 | | |
| 1053 | + | |
| 1054 | + | |
979 | 1055 | | |
980 | 1056 | | |
981 | 1057 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
246 | 318 | | |
247 | 319 | | |
248 | 320 | | |
| |||
0 commit comments