diff --git a/.gitignore b/.gitignore index 8365624..e58d451 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ _testmain.go *.exe *.test +config.json \ No newline at end of file diff --git a/config_sample.json b/config_sample.json new file mode 100644 index 0000000..a789814 --- /dev/null +++ b/config_sample.json @@ -0,0 +1,7 @@ +{ + "email": "", + "password": "", + "domain": "", + "sub_domain": "", + "ip_url": "" +} \ No newline at end of file diff --git a/godns.go b/godns.go new file mode 100644 index 0000000..dc511aa --- /dev/null +++ b/godns.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + fmt.Println("Starting...") + + setting := LoadSettings() + fmt.Println(setting.IP_Url) + + loop := make(chan bool) + go dns_loop(setting, loop) + + ret := <-loop + + if !ret { + fmt.Println("Dns loop exited...") + close(loop) + + os.Exit(1) + } +} + +func dns_loop(setting Settings, loop chan bool) { + +} diff --git a/settings.go b/settings.go new file mode 100644 index 0000000..1efb191 --- /dev/null +++ b/settings.go @@ -0,0 +1,34 @@ +package main + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "os" +) + +const config_path string = "config.json" + +type Settings struct { + Email string + Password string + Domain string + Sub_domain string + IP_Url string +} + +func LoadSettings() Settings { + file, err := ioutil.ReadFile(config_path) + + if err != nil { + fmt.Println("Error occurs while reading config file, please make sure config file exists!") + os.Exit(1) + } + + var setting Settings + json.Unmarshal(file, &setting) + + fmt.Println(setting.Email) + + return setting +}