Skip to content

Commit

Permalink
impl ipv4/6hint
Browse files Browse the repository at this point in the history
  • Loading branch information
nna774 committed Nov 29, 2023
1 parent 4515509 commit 6f790b6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dns/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@ func parseSVCParams(data []byte) map[int]string {
val = "apln=" + strings.Join(ss, ",")
case 3: // port
val = fmt.Sprintf("port=%v", int(binary.BigEndian.Uint16(valData)))
case 4: // ipv4hint
if len(valData)%4 != 0 {
panic("what's??")
}
addrs := []string{}
for i := 0; i < len(valData); i += 4 {
addrs = append(addrs, fmt.Sprintf("%v", net.IP(valData[i:i+4])))
}
val = fmt.Sprintf("ipv4hint='%v'", strings.Join(addrs, ", "))
case 6: // ipv6hint
if len(valData)%16 != 0 {
panic("what's??")
}
addrs := []string{}
for i := 0; i < len(valData); i += 16 {
addrs = append(addrs, fmt.Sprintf("%v", net.IP(valData[i:i+16])))
}
val = fmt.Sprintf("ipv6hint='%v'", strings.Join(addrs, ", "))
case 7: // dohpath
val = "dohpath=" + string(valData)
default:
Expand Down

0 comments on commit 6f790b6

Please sign in to comment.