Compatibilité elvish 0.17
This commit is contained in:
parent
be84588373
commit
87eb82a791
43 changed files with 323 additions and 322 deletions
|
|
@ -1,11 +1,11 @@
|
|||
edit:add-var ipof~ [@argv]{
|
||||
edit:add-var ipof~ {|@argv|
|
||||
use str
|
||||
use moi/util/condition
|
||||
use moi/util/ip
|
||||
|
||||
fn less [cmp e1 e2]{ < ($cmp $e1 $e2) 0 }
|
||||
fn less {|cmp e1 e2| < ($cmp $e1 $e2) 0 }
|
||||
|
||||
fn sort-ip [e1 e2]{
|
||||
fn sort-ip {|e1 e2|
|
||||
var i1 = (condition:cset (ip:is-ipv4 $e1) 0 (condition:cset (ip:is-ipv6 $e1) 1 2))
|
||||
var i2 = (condition:cset (ip:is-ipv4 $e2) 0 (condition:cset (ip:is-ipv6 $e2) 1 2))
|
||||
if (!= $i1 $i2) {
|
||||
|
|
@ -19,18 +19,18 @@ edit:add-var ipof~ [@argv]{
|
|||
}
|
||||
}
|
||||
|
||||
fn dnssolve [d]{
|
||||
fn dnssolve {|d|
|
||||
var result = [
|
||||
&ips=[&]
|
||||
&resolvers=''
|
||||
&txt=''
|
||||
]
|
||||
e:dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml -resolve (idn -a $d) | peach [l]{
|
||||
e:dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml -resolve (idn -a $d) | peach {|l|
|
||||
var ll = $l
|
||||
var idx = (+ (str:index $ll :) 1)
|
||||
var value = (str:trim-space $ll[$idx".."])
|
||||
if (or (str:has-prefix $ll 'IPv4 addresses') (str:has-prefix $ll 'IPv6 addresses')) {
|
||||
str:split ', ' $value | peach [e]{
|
||||
str:split ', ' $value | peach {|e|
|
||||
var ee = $e
|
||||
if (ip:is-ip $ee) {
|
||||
set result[ips][$ee] = $nil
|
||||
|
|
@ -48,13 +48,13 @@ edit:add-var ipof~ [@argv]{
|
|||
}
|
||||
|
||||
var hosts = [&]
|
||||
cat /etc/hosts | peach [l]{
|
||||
cat /etc/hosts | peach {|l|
|
||||
var ll = (str:trim-space $l)
|
||||
if (and (not-eq $ll '') (not-eq $ll[0] '#')) {
|
||||
put $ll
|
||||
}
|
||||
} | eawk [_ ip @domains]{
|
||||
peach [d]{
|
||||
} | eawk {|_ ip @domains|
|
||||
peach {|d|
|
||||
var dd = $d
|
||||
if (has-key $hosts $dd) {
|
||||
set hosts[$dd][$ip] = $nil
|
||||
|
|
@ -65,7 +65,7 @@ edit:add-var ipof~ [@argv]{
|
|||
}
|
||||
|
||||
var remote = [&]
|
||||
peach [d]{
|
||||
peach {|d|
|
||||
var dd = $d
|
||||
var solve = (dnssolve $dd)
|
||||
if (> (keys $solve[ips] | count) 0) {
|
||||
|
|
@ -73,14 +73,14 @@ edit:add-var ipof~ [@argv]{
|
|||
}
|
||||
} $argv
|
||||
|
||||
each [d]{
|
||||
each {|d|
|
||||
var exists = $false
|
||||
echo (styled 'Resolving '$d'…' bright-green)
|
||||
echo
|
||||
if (has-key $hosts $d) {
|
||||
set exists = $true
|
||||
echo (styled ' local:' bright-yellow)
|
||||
keys $hosts[$d] | order &less-than=$sort-ip~ | each [ip]{
|
||||
keys $hosts[$d] | order &less-than=$sort-ip~ | each {|ip|
|
||||
echo ' - '$ip
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ edit:add-var ipof~ [@argv]{
|
|||
var info = $remote[$d]
|
||||
echo (styled ' remote:' bright-yellow)
|
||||
echo ' IPs:'
|
||||
keys $info[ips] | order &less-than=$sort-ip~ | each [ip]{
|
||||
keys $info[ips] | order &less-than=$sort-ip~ | each {|ip|
|
||||
echo ' - '$ip
|
||||
}
|
||||
echo ' Resolvers: '$info[resolvers]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue