Minimum viable

This commit is contained in:
2020-11-21 21:15:48 +00:00
parent d50afa87e5
commit a32d4bbadf
4 changed files with 105 additions and 16 deletions

26
API.go Normal file
View File

@@ -0,0 +1,26 @@
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]
}