Skip to content

Commit

Permalink
allow multiple names to be checked
Browse files Browse the repository at this point in the history
  • Loading branch information
jschauma committed Sep 28, 2023
1 parent 7a1e26f commit 7c05724
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
3 changes: 2 additions & 1 deletion doc/jswhois.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.Dd January 09, 2022
.Dd September 28, 2023
.Dt jswhois 1
.Os
.Sh NAME
Expand All @@ -10,6 +10,7 @@
.Op Fl h Ar host
.Op Fl p Ar port
.Ar domain
.Op Ar ...
.Sh DESCRIPTION
The
.Nm
Expand Down
44 changes: 26 additions & 18 deletions src/jswhois.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

const PROGNAME = "jswhois"
const VERSION = "1.0"
const VERSION = "1.1"

const EXIT_FAILURE = 1
const EXIT_SUCCESS = 0
Expand Down Expand Up @@ -1140,13 +1140,6 @@ func getopts() {

os.Args = os.Args[1:]
}

if len(os.Args) != 1 {
usage(os.Stderr)
os.Exit(EXIT_FAILURE)
}

OUTPUT["query"] = os.Args[0]
}

func hasMarker(list map[string]bool, line string) (yesno bool) {
Expand All @@ -1161,9 +1154,26 @@ func hasMarker(list map[string]bool, line string) (yesno bool) {
}

func lookupWhois() {

var allOutput = []map[string]interface{}{}
verbose(1, "Looking up %d names...", len(os.Args))

for _, q := range os.Args {
OUTPUT = map[string]interface{}{}
OUTPUT["query"] = q
allOutput = append(allOutput, oneLookup())
}

j, _ := json.Marshal(allOutput)
fmt.Printf("%s\n", j)
}


func oneLookup() (rval map[string]interface{}) {
rval = map[string]interface{}{}
query := OUTPUT["query"].(string)

verbose(1, "Looking up %s...", query)
verbose(2, "Looking up %s...", query)

var chain = []string{DEFAULT_WHOIS}
OUTPUT[DEFAULT_WHOIS] = askWhois(DEFAULT_WHOIS, query)
Expand All @@ -1185,20 +1195,18 @@ func lookupWhois() {

OUTPUT["chain"] = chain

var j []byte

if LEAF_ONLY {
leaf := map[string]interface{}{}
leaf["query"] = OUTPUT["query"]
leaf["chain"] = chain
leaf[chain[len(chain)-1]] = data
j, _ = json.Marshal(leaf)
rval["query"] = OUTPUT["query"]
rval["chain"] = chain
rval[chain[len(chain)-1]] = data
} else {
j, _ = json.Marshal(OUTPUT)
rval = OUTPUT
}
fmt.Printf("%s\n", j)

return
}


func printVersion() {
fmt.Printf("%v version %v\n", PROGNAME, VERSION)
}
Expand Down

0 comments on commit 7c05724

Please sign in to comment.