|
@@ -1,6 +1,7 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
+ "flag"
|
|
|
"fmt"
|
|
|
"io/ioutil"
|
|
|
"log"
|
|
@@ -9,17 +10,32 @@ import (
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
+var (
|
|
|
+ verbal = flag.Bool("v", true, "Enable verbal output")
|
|
|
+)
|
|
|
+
|
|
|
func main() {
|
|
|
- //Create a dummy request
|
|
|
+ flag.Parse()
|
|
|
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)
|
|
|
+ if *verbal {
|
|
|
+ fmt.Println("Your public IP address is: ", publicIp)
|
|
|
+ fmt.Println("Your free domain assigned by ISP is: ", domains)
|
|
|
+ } else {
|
|
|
+ if len(domains) > 0 {
|
|
|
+ out := domains[0]
|
|
|
+ if out[len(out)-1:] == "." {
|
|
|
+ out = out[:len(out)-1]
|
|
|
+ }
|
|
|
+ fmt.Println(out)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
func getPublicIP() string {
|
|
|
//http://checkip.amazonaws.com/
|
|
|
- resp, err := http.Get("http://checkip.amazonaws.com/")
|
|
|
+ resp, err := http.Get("https://api.ipify.org/")
|
|
|
if err != nil {
|
|
|
log.Fatalln(err)
|
|
|
}
|