nu: Fix ipv6 dns lookups

This commit is contained in:
2025-09-03 12:57:00 +02:00
parent 18a93fe079
commit 96f80a024a

View File

@ -53,17 +53,10 @@ def dns [
# HACK: turn the optional argument into a list. not sure how to pass it to nslookup otherwise. # HACK: turn the optional argument into a list. not sure how to pass it to nslookup otherwise.
let server = ([$server] | compact) let server = ([$server] | compact)
nslookup $name ...$server | let ipv4 = (dig $name A | lines | skip until {|l| $l =~ "ANSWER SECTION" } | skip 1 | take until { |l| $l == "" } | split column "\t" -c | rename host ttl _ type addr) | reject _
lines | let ipv6 = (dig $name AAAA | lines | skip until {|l| $l =~ "ANSWER SECTION" } | skip 1 | take until { |l| $l == "" } | split column "\t" -c | rename host ttl _ type addr) | reject _
skip until { |line| $line =~ answer } |
parse -r "Address:\\s(?<ipv4>\\d+\\.\\d+\\.\\d+\\.\\d+)|Address:\\s(?<ipv6>[\\d:a-z]+)" | $ipv4 | append $ipv6
each { |row|
if $row.ipv4 != "" {
{ kind: ipv4, addr: $row.ipv4 }
} else {
{ kind: ipv6, addr: $row.ipv6 }
}
}
} }
@ -86,7 +79,7 @@ def "m daemon" [
$cargo_flags ++= [--features api-override] $cargo_flags ++= [--features api-override]
$envs ++= [ $envs ++= [
MULLVAD_API_HOST=api.stagemole.eu MULLVAD_API_HOST=api.stagemole.eu
MULLVAD_API_ADDR=(dns api.stagemole.eu | where kind == ipv4 | get 0.addr):443 MULLVAD_API_ADDR=(dns api.stagemole.eu | where type == A | get 0.addr):443
] ]
} }