Skip to content

Commit

Permalink
Resolveの戻り値を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
harakeishi committed Feb 1, 2022
1 parent 016e22a commit eb4acf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var rootCmd = &cobra.Command{
fmt.Println(err)
os.Exit(1)
}
if err := whris.Resolve(domain, v); err != nil {
if _, err := whris.Resolve(domain, v); err != nil {
fmt.Println(err)
os.Exit(1)
}
Expand Down
10 changes: 5 additions & 5 deletions whris/whris.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@ type Summary struct {
ParseResult []NetworkAdmin
}

func Resolve(domain string, verbose bool) error {
func Resolve(domain string, verbose bool) (Summary, error) {
var summary Summary
summary.WhoisResponseServer = "whois.apnic.net"
summary.TargetDomain = domain
addr, err := net.ResolveIPAddr("ip", domain)
if err != nil {
return err
return Summary{}, err
}
summary.TargetIp = addr.String()
summary.WhoisResponse, err = whois.Whois(summary.TargetIp, "whois.iana.org")
if err != nil {
return err
return Summary{}, err
}
summary.SetWhoisResponseServerFromWhoisResponse()
summary.ParseWhoisResponse()
if !summary.ParseCheck() {
summary.ParseResult = summary.ParseResult[1:]
summary.WhoisResponse, err = whois.Whois(summary.TargetIp, summary.WhoisResponseServer)
if err != nil {
return err
return Summary{}, err
}
summary.ParseWhoisResponse()
}
summary.EchoResult(verbose)
return nil
return summary, nil
}

func (s *Summary) ParseWhoisResponse() error {
Expand Down

0 comments on commit eb4acf8

Please sign in to comment.