* whois: use whois.arin.net

+ robust redirect mechanism
* decrease timeout 30sec -> 5sec
* faster response parsing
* don't use likexian/whois-go package
This commit is contained in:
Simon Zolin
2019-10-07 19:13:06 +03:00
parent d75620fdc0
commit 37fe3c148f
7 changed files with 122 additions and 40 deletions

View File

@@ -1,19 +1,15 @@
package home
import (
"strings"
"testing"
whois "github.com/likexian/whois-go"
"github.com/stretchr/testify/assert"
)
func TestWhois(t *testing.T) {
resp, err := whois.Whois("8.8.8.8")
w := Whois{timeoutMsec: 5000}
resp, err := w.queryAll("8.8.8.8")
assert.True(t, err == nil)
assert.True(t, strings.Index(resp, "OrgName: Google LLC") != -1)
assert.True(t, strings.Index(resp, "City: Mountain View") != -1)
assert.True(t, strings.Index(resp, "Country: US") != -1)
m := whoisParse(resp)
assert.True(t, m["orgname"] == "Google LLC")
assert.True(t, m["country"] == "US")