Correction du script addbadips
This commit is contained in:
parent
f5bcaaf2ec
commit
1edc58d67b
|
@ -4,31 +4,30 @@ edit:add-var addbadips~ {|@argv|
|
||||||
use framagit.org/benjamin.vaudour/elv-lib/mods/list
|
use framagit.org/benjamin.vaudour/elv-lib/mods/list
|
||||||
use framagit.org/benjamin.vaudour/elv-lib/mods/map
|
use framagit.org/benjamin.vaudour/elv-lib/mods/map
|
||||||
|
|
||||||
fn add {|f cmp ips|
|
fn add {|f cmp ips t|
|
||||||
var @cips = (cat $f)
|
var @cips = (cat $f)
|
||||||
var m c = (map:to-set $cips) 0
|
var m c = (map:to-set $cips) 0
|
||||||
each {|e|
|
each {|e|
|
||||||
if (not (has-key $m $e)) {
|
if (not (has-key $m $e)) {
|
||||||
echo $e ajoutée
|
|
||||||
set c = (+ $c 1)
|
|
||||||
set m[$e] = $nil
|
set m[$e] = $nil
|
||||||
set @cips = $@cips $e
|
set @cips = $@cips $e
|
||||||
|
set c = (+ $c 1)
|
||||||
|
echo $e ajoutée
|
||||||
}
|
}
|
||||||
} $ips
|
} $ips
|
||||||
if (> $c 0) {
|
if (> $c 0) {
|
||||||
set @cips = (list:sort $cmp $cips)
|
set @cips = (list:sort $cmp $cips)
|
||||||
echo (str:join "\n" $cips) > $f
|
echo (str:join "\n" $cips) > $f
|
||||||
}
|
}
|
||||||
put $c (count $cips)
|
printf "%d %s ajoutées (%d au total)\n" $c $t (count $cips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var ip4 ip6 = (list:filter $ip:is-ip~ $argv | list:unzip {|_ ip| ip:is-ipv4 $ip})
|
var ip4 ip6 = (list:filter $ip:is-ip~ $argv | list:unzip {|_ ip| ip:is-ipv4 $ip})
|
||||||
if (list:is-not-empty $ip4) {
|
if (list:is-not-empty $ip4) {
|
||||||
var c t = (add $E:HOME/bad_ips.txt $ip:comp4~ $ip4)
|
add $E:HOME/bad_ips.txt $ip:comp4~ $ip4 IPv4s
|
||||||
printf "%d IPv4s ajoutées (%d au total)\n" $c $t
|
|
||||||
}
|
}
|
||||||
if (list:is-not-empty $ip6) {
|
if (list:is-not-empty $ip6) {
|
||||||
var c t = (add $E:HOME/bad_ipsv6.txt $ip:comp6~ $ip6)
|
add $E:HOME/bad_ipsv6.txt $ip:comp6~ $ip6 IPv6s
|
||||||
printf "%d IPv6s ajoutées (%d au total)\n" $c $t
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue