summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--whois.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/whois.go b/whois.go
index a7d49c4..8fb7be3 100644
--- a/whois.go
+++ b/whois.go
@@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net"
+ "strings"
"time"
)
@@ -14,13 +15,30 @@ const (
RETRIES = 1
)
+type asnipPair struct {
+ asNum string
+ ipAdr string
+}
+
func main() {
domains := []string{"109.105.104.100", "123.123.123.123"}
res, err := whois(domains, WHOIS_SERVER)
if err != nil {
return
}
- fmt.Println(res)
+
+ lines := strings.Split(res, "\n")
+ asip := make([]asnipPair, 0, len(lines)-2)
+ for _, line := range lines[1 : len(lines)-1] {
+ content := strings.Split(line, "|")
+ as := strings.TrimSpace(content[0])
+ ip := strings.TrimSpace(content[2])
+ asip = append(asip, asnipPair{
+ asNum: as,
+ ipAdr: ip,
+ })
+ }
+ fmt.Println("cap:", cap(asip), ", len:", len(asip), ", content:", asip)
}
/* implements the whois protocal described at https://en.wikipedia.org/wiki/Whois#Protocol */