Correction problème des peach

This commit is contained in:
Benjamin VAUDOUR 2021-08-28 10:58:07 +02:00
parent ec1c063802
commit f8a35a9da3
4 changed files with 23 additions and 28 deletions

View file

@ -31,9 +31,9 @@ edit:add-var ipof~ [@argv]{
var value = (str:trim-space $l[$idx".."])
if (or (str:has-prefix $l 'IPv4 addresses') (str:has-prefix $l 'IPv6 addresses')) {
str:split ', ' $value | peach [e]{
var e = $e
if (ip:is-ip $e) {
result[ips][$e] = $nil
var ee = $e
if (ip:is-ip $ee) {
result[ips][$ee] = $nil
}
}
} elif (str:has-prefix $l 'TXT records') {
@ -49,28 +49,27 @@ edit:add-var ipof~ [@argv]{
var hosts = [&]
cat /etc/hosts | peach [l]{
var l = $l
l = (str:trim-space $l)
if (and (not-eq $l '') (not-eq $l[0] '#')) {
put $l
var ll = (str:trim-space $l)
if (and (not-eq $ll '') (not-eq $ll[0] '#')) {
put $ll
}
} | eawk [_ ip @domains]{
peach [d]{
var d = $d
if (has-key $hosts $d) {
hosts[$d][$ip] = $nil
var dd = $d
if (has-key $hosts $dd) {
hosts[$dd][$ip] = $nil
} else {
hosts[$d] = [&$ip=$nil]
hosts[$dd] = [&$ip=$nil]
}
} $domains
}
var remote = [&]
peach [d]{
var d = $d
var solve = (dnssolve $d)
var dd = $d
var solve = (dnssolve $dd)
if (> (keys $solve[ips] | count) 0) {
remote[$d] = $solve
remote[$dd] = $solve
}
} $argv