forked from navilg/namecheap-ddns-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
34 lines (28 loc) · 877 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"flag"
"fmt"
"os"
)
func main() {
fmt.Println("Namecheap Dynamic DNS client Version", version)
fmt.Println("Git Repo:", gitrepo)
domain := flag.String("domain", "", "Domain name e.g. example.com")
host := flag.String("host", "", "Subdomain or hostname e.g. www")
password := flag.String("password", "", "Dynamic DNS Password from Namecheap")
flag.Parse()
if *domain == "" || *host == "" || *password == "" {
fmt.Println("ERROR domain, host and Dynamic DDNS password are mandatory")
fmt.Printf("\nUsage of %s:\n", os.Args[1])
flag.PrintDefaults()
os.Exit(1)
}
pubIp, err := getPubIP()
if err != nil {
DDNSLogger(ErrorLog, *host, *domain, err.Error())
} else {
setDNSRecord(*host, *domain, *password, pubIp)
DDNSLogger(InformationLog, *host, *domain, "Record updated. "+pubIp)
}
updateRecord(*domain, *host, *password)
}