2021-12-11 21:09:02 +00:00
|
|
|
edit:add-var digall~ {|@argv|
|
2020-07-22 09:24:43 +00:00
|
|
|
use moi/util/list
|
2021-08-24 18:44:01 +00:00
|
|
|
use moi/util/strutil
|
2020-07-22 09:24:43 +00:00
|
|
|
use str
|
|
|
|
|
2021-08-27 19:45:39 +00:00
|
|
|
var default_records = [
|
2020-07-22 09:24:43 +00:00
|
|
|
A
|
|
|
|
AAAA
|
|
|
|
CNAME
|
|
|
|
PTR
|
|
|
|
TXT
|
|
|
|
MX
|
|
|
|
SRV
|
|
|
|
NAPTR
|
|
|
|
NS
|
|
|
|
SOA
|
|
|
|
]
|
2021-08-27 19:45:39 +00:00
|
|
|
var cols = [
|
2020-07-22 14:35:25 +00:00
|
|
|
[&min=24]
|
|
|
|
[&min=8]
|
|
|
|
[&min=10]
|
|
|
|
]
|
2021-08-27 19:45:39 +00:00
|
|
|
var records servers = [] []
|
2021-10-13 18:43:40 +00:00
|
|
|
var flags = [
|
2020-07-22 09:24:43 +00:00
|
|
|
+noall
|
|
|
|
+answer
|
|
|
|
]
|
2021-08-27 19:45:39 +00:00
|
|
|
var domains use_dig = [] $true
|
2020-07-22 09:24:43 +00:00
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn init {||
|
2021-08-24 18:44:01 +00:00
|
|
|
if (and (> (count $argv) 0) (is $argv[0] -d)) {
|
2021-10-13 18:43:40 +00:00
|
|
|
set use_dig = $false
|
|
|
|
set argv = $argv[1:]
|
2020-07-22 10:41:38 +00:00
|
|
|
}
|
2021-12-11 21:09:02 +00:00
|
|
|
each {|e|
|
2020-07-22 09:24:43 +00:00
|
|
|
if (is $e[0] '+') {
|
2021-10-13 18:43:40 +00:00
|
|
|
set flags = [ (all $flags) $e ]
|
2020-07-22 09:24:43 +00:00
|
|
|
} elif (is $e[0] @) {
|
2021-10-13 18:43:40 +00:00
|
|
|
set servers = [ (all $servers) $e ]
|
2020-07-22 09:24:43 +00:00
|
|
|
} elif (list:includes $e $default_records) {
|
2021-10-13 18:43:40 +00:00
|
|
|
set records = [ (all $records) $e ]
|
2020-07-22 09:24:43 +00:00
|
|
|
} else {
|
2021-10-13 18:43:40 +00:00
|
|
|
set domains = [ (all $domains) $e ]
|
2020-07-22 09:24:43 +00:00
|
|
|
}
|
2021-08-24 18:44:01 +00:00
|
|
|
} $argv
|
2020-07-22 09:24:43 +00:00
|
|
|
if (== (count $records) 0) {
|
2021-10-13 18:43:40 +00:00
|
|
|
set records = $default_records
|
2020-07-22 09:24:43 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-22 14:35:25 +00:00
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn format {|results|
|
|
|
|
eawk {|_ @args|
|
2021-08-24 18:44:01 +00:00
|
|
|
put [ $args[0] (all $args[2..]) ]
|
2021-12-11 21:09:02 +00:00
|
|
|
} $results | list:remove-duplicate | list:sort {|l1 l2|
|
2021-08-27 19:45:39 +00:00
|
|
|
var c = (str:compare $l1[0] $l2[0])
|
2020-07-22 14:35:25 +00:00
|
|
|
if (== $c 0) {
|
2021-10-13 18:43:40 +00:00
|
|
|
set c = (str:compare $l1[2] $l2[2])
|
2020-07-22 14:35:25 +00:00
|
|
|
}
|
|
|
|
} | strutil:format &col=$cols | str:join "\n"
|
|
|
|
}
|
2020-07-22 10:41:38 +00:00
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn drillr {|d @args|
|
|
|
|
var results = [ (peach {|r|
|
|
|
|
e:drill $@args $r $d | list:filter {|e|
|
2020-07-22 10:41:38 +00:00
|
|
|
and (> (count $e) 2) (not (is $e[:2] ';;'))
|
|
|
|
}
|
2020-07-22 14:35:25 +00:00
|
|
|
} $records) ]
|
|
|
|
format $results
|
2020-07-22 10:41:38 +00:00
|
|
|
}
|
2020-07-22 09:24:43 +00:00
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn digr {|d @args|
|
|
|
|
var results = [ (peach {|r|
|
2020-07-22 09:24:43 +00:00
|
|
|
e:dig $@args $r $d $@flags
|
2020-07-22 14:35:25 +00:00
|
|
|
} $records) ]
|
|
|
|
format $results
|
2020-07-22 09:24:43 +00:00
|
|
|
}
|
2020-07-22 10:41:38 +00:00
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn req {|d @args|
|
2020-07-22 10:41:38 +00:00
|
|
|
if $use_dig {
|
|
|
|
digr $d $@args
|
|
|
|
} else {
|
|
|
|
drillr $d $@args
|
|
|
|
}
|
|
|
|
}
|
2020-07-22 09:24:43 +00:00
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn digs {|s d|
|
2020-07-22 14:35:25 +00:00
|
|
|
put (echo (styled $s bright-yellow))
|
2020-07-22 10:41:38 +00:00
|
|
|
req $d $s
|
2020-07-22 09:24:43 +00:00
|
|
|
}
|
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
fn digd {|d|
|
2021-08-27 19:45:39 +00:00
|
|
|
var results = [ (echo (styled 'Domaine: '$d bright-green)) ]
|
2020-07-22 09:24:43 +00:00
|
|
|
if (> (count $servers) 0) {
|
2021-12-11 21:09:02 +00:00
|
|
|
each {|s|
|
2021-10-13 18:43:40 +00:00
|
|
|
set @results = $@results (digs $s $d)
|
2020-07-22 09:24:43 +00:00
|
|
|
} $servers
|
|
|
|
} else {
|
2021-10-13 18:43:40 +00:00
|
|
|
set @results = $@results (req $d)
|
2020-07-22 09:24:43 +00:00
|
|
|
}
|
2020-07-22 14:35:25 +00:00
|
|
|
echo (str:join "\n" $results)
|
2020-07-22 09:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
init
|
2020-07-22 14:35:25 +00:00
|
|
|
peach $digd~ $domains
|
2020-07-22 09:24:43 +00:00
|
|
|
}
|