Skip to content

Commit

Permalink
Merge pull request #11 from harakeishi/fix/whois-parse
Browse files Browse the repository at this point in the history
fix whois parse
  • Loading branch information
harakeishi authored Jan 29, 2022
2 parents 521aed7 + 46b6be3 commit a8e82c6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions whereis/whereis.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@ func Resolve(domain string, verbose bool) error {
}

func (s *Summary) ParseWhoisResponse() error {
paragraph := strings.Split(s.WhoisResponse, "\n\n")
var paragraph []string
whoisHost := "whois.apnic.net"
t := strings.Split(s.WhoisResponse, "\n")
col := strings.Split(t[10], ":")
whoisHost = strings.TrimSpace(col[1])
switch whoisHost {
case "whois.apnic.net":
paragraph = strings.Split(s.WhoisResponse, "\n\n")
case "whois.arin.net":
paragraph = strings.Split(s.WhoisResponse, "# start")
default:
paragraph = strings.Split(s.WhoisResponse, "\n\n")
}
for _, v := range paragraph {
tmp := NetworkAdomin{}
row := strings.Split(v, "\n")
Expand All @@ -51,7 +63,7 @@ func (s *Summary) ParseWhoisResponse() error {
tmp.IpRange = strings.TrimSpace(col[1])
case "netname", "NetName":
tmp.NetName = strings.TrimSpace(col[1])
case "country":
case "country", "Country":
tmp.Country = strings.TrimSpace(col[1])
case "descr", "Organization", "organisation":
if tmp.Admin == "" {
Expand Down

0 comments on commit a8e82c6

Please sign in to comment.