1
0
mirror of https://github.com/taigrr/godns synced 2025-01-18 04:03:25 -08:00

init repos

This commit is contained in:
Timothy 2014-05-12 13:04:29 +08:00
parent d2ade8d7f8
commit 02d450edcd
4 changed files with 71 additions and 0 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ _testmain.go
*.exe *.exe
*.test *.test
config.json

7
config_sample.json Normal file
View File

@ -0,0 +1,7 @@
{
"email": "",
"password": "",
"domain": "",
"sub_domain": "",
"ip_url": ""
}

29
godns.go Normal file
View File

@ -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) {
}

34
settings.go Normal file
View File

@ -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
}