+ whois: add WHOIS information for a client

+ return WHOIS info in GET /clients response
This commit is contained in:
Simon Zolin
2019-09-18 18:44:27 +03:00
parent f6404ef181
commit fd592b4dc8
10 changed files with 300 additions and 35 deletions

21
home/whois_test.go Normal file
View File

@@ -0,0 +1,21 @@
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")
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")
assert.True(t, m["city"] == "Mountain View")
}