-
Notifications
You must be signed in to change notification settings - Fork 231
/
whois.go
47 lines (41 loc) · 877 Bytes
/
whois.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Package whois tries to get information about
// IP address / Prefix / Domain (todo)
package whois
import (
"github.com/mehrdadrad/mylg/ripe"
)
// whois represents whois providers
type whois interface {
Set(r string)
GetData() bool
PrettyPrint()
}
var (
w = map[string]whois{"asn": new(ripe.ASN), "prefix": new(ripe.Prefix)}
)
// Lookup tries to get whois information
// ASN and prefix/ip information
func Lookup(args string) {
if ripe.IsASN(args) {
w["asn"].Set(args)
w["asn"].GetData()
w["asn"].PrettyPrint()
} else if ripe.IsIP(args) || ripe.IsPrefix(args) {
w["prefix"].Set(args)
w["prefix"].GetData()
w["prefix"].PrettyPrint()
} else {
help()
}
}
// help represents whois help
func help() {
println(`
usage:
whois ASN/CIDR/IPAddress
Example:
whois 8.8.8.8
whois 8.0.0.0/8
whois 577
`)
}