Пример #1
0
func (k *Klient) PublicIP() (net.IP, error) {
	if k.publicIP == nil {
		ip, err := publicip.PublicIP()
		if err != nil {
			return nil, err
		}

		k.publicIP = ip
	}

	return k.publicIP, nil
}
Пример #2
0
	defer conn.Close()

	// Query the whois server with the ip or domain given to this func,
	// as per Whois spec.
	_, err = conn.Write([]byte(fmt.Sprintf("%s\r\n", query)))
	if err != nil {
		return "", err
	}

	// After the query, the server will respond with the unformatted data.
	// Read it all and return it.
	b, err := ioutil.ReadAll(conn)
	if err != nil {
		return "", err
	}

	return string(b), nil
}

// DefaultWhoisChecker is used for all whois based checkers
var DefaultWhoisChecker WhoisFunc = func() (string, error) {
	// Get the IP of this machine, to whois against
	ip, err := publicip.PublicIP()
	if err != nil {
		return "", err
	}

	// Get the whois of the current vm's IP
	return WhoisQuery(ip.String(), whoisServer, whoisTimeout)
}