106 lines
2.0 KiB
Plaintext
106 lines
2.0 KiB
Plaintext
edit:add-var digall~ [@argv]{
|
|
use moi/util/list
|
|
use moi/util/strutil
|
|
use str
|
|
|
|
var default_records = [
|
|
A
|
|
AAAA
|
|
CNAME
|
|
PTR
|
|
TXT
|
|
MX
|
|
SRV
|
|
NAPTR
|
|
NS
|
|
SOA
|
|
]
|
|
var cols = [
|
|
[&min=24]
|
|
[&min=8]
|
|
[&min=10]
|
|
]
|
|
var records servers = [] []
|
|
var flags = [
|
|
+noall
|
|
+answer
|
|
]
|
|
var domains use_dig = [] $true
|
|
|
|
fn init []{
|
|
if (and (> (count $argv) 0) (is $argv[0] -d)) {
|
|
use_dig = $false
|
|
argv = $argv[1:]
|
|
}
|
|
each [e]{
|
|
if (is $e[0] '+') {
|
|
flags = [ (all $flags) $e ]
|
|
} elif (is $e[0] @) {
|
|
servers = [ (all $servers) $e ]
|
|
} elif (list:includes $e $default_records) {
|
|
records = [ (all $records) $e ]
|
|
} else {
|
|
domains = [ (all $domains) $e ]
|
|
}
|
|
} $argv
|
|
if (== (count $records) 0) {
|
|
records = $default_records
|
|
}
|
|
}
|
|
|
|
fn format [results]{
|
|
eawk [_ @args]{
|
|
put [ $args[0] (all $args[2..]) ]
|
|
} $results | list:remove-duplicate | list:sort [l1 l2]{
|
|
var c = (str:compare $l1[0] $l2[0])
|
|
if (== $c 0) {
|
|
c = (str:compare $l1[2] $l2[2])
|
|
}
|
|
} | strutil:format &col=$cols | str:join "\n"
|
|
}
|
|
|
|
fn drillr [d @args]{
|
|
var results = [ (peach [r]{
|
|
e:drill $@args $r $d | list:filter [e]{
|
|
and (> (count $e) 2) (not (is $e[:2] ';;'))
|
|
}
|
|
} $records) ]
|
|
format $results
|
|
}
|
|
|
|
fn digr [d @args]{
|
|
var results = [ (peach [r]{
|
|
e:dig $@args $r $d $@flags
|
|
} $records) ]
|
|
format $results
|
|
}
|
|
|
|
fn req [d @args]{
|
|
if $use_dig {
|
|
digr $d $@args
|
|
} else {
|
|
drillr $d $@args
|
|
}
|
|
}
|
|
|
|
fn digs [s d]{
|
|
put (echo (styled $s bright-yellow))
|
|
req $d $s
|
|
}
|
|
|
|
fn digd [d]{
|
|
var results = [ (echo (styled 'Domaine: '$d bright-green)) ]
|
|
if (> (count $servers) 0) {
|
|
each [s]{
|
|
@results = $@results (digs $s $d)
|
|
} $servers
|
|
} else {
|
|
@results = $@results (req $d)
|
|
}
|
|
echo (str:join "\n" $results)
|
|
}
|
|
|
|
init
|
|
peach $digd~ $domains
|
|
}
|