TC vor 3 Jahren
Ursprung
Commit
4821469127
3 geänderte Dateien mit 42 neuen und 0 gelöschten Zeilen
  1. 3 0
      go.mod
  2. BIN
      go.sum
  3. 39 0
      main.go

+ 3 - 0
go.mod

@@ -0,0 +1,3 @@
+module adnex
+
+go 1.17

BIN
go.sum


+ 39 - 0
main.go

@@ -0,0 +1,39 @@
+package main
+
+import (
+	"fmt"
+	"io/ioutil"
+	"log"
+	"net"
+	"net/http"
+	"strings"
+)
+
+func main() {
+	//Create a dummy request
+	publicIp := strings.TrimSpace(getPublicIP())
+	fmt.Println("Your public IP address is: ", publicIp)
+	domains := GetFreeDomain(publicIp)
+	fmt.Println("Your free domain assigned by ISP is: ", domains)
+}
+
+func getPublicIP() string {
+	//http://checkip.amazonaws.com/
+	resp, err := http.Get("http://checkip.amazonaws.com/")
+	if err != nil {
+		log.Fatalln(err)
+	}
+	//We Read the response body on the line below.
+	body, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		log.Fatalln(err)
+	}
+	//Convert the body to type string
+	sb := string(body)
+	return sb
+}
+
+func GetFreeDomain(ipaddr string) []string {
+	ptr, _ := net.LookupAddr(ipaddr)
+	return ptr
+}