Files
iPilot/API.go
2020-11-21 21:15:48 +00:00

27 lines
435 B
Go

package main
import (
"io/ioutil"
"net"
"net/http"
)
func getLocalIP() string {
resp, _ := http.Get("https://api.ipify.org")
body, _ := ioutil.ReadAll(resp.Body)
return string(body[:])
}
func checkIPSyntax(ipaddress string) bool {
addr := net.ParseIP(ipaddress)
if addr == nil {
return false
}
return true
}
func resolveDNSHostname(hostname string) string {
address, _ := net.LookupHost(hostname)
return address[0]
}