mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
init repos
This commit is contained in:
parent
d2ade8d7f8
commit
02d450edcd
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,3 +21,4 @@ _testmain.go
|
|||||||
|
|
||||||
*.exe
|
*.exe
|
||||||
*.test
|
*.test
|
||||||
|
config.json
|
7
config_sample.json
Normal file
7
config_sample.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"email": "",
|
||||||
|
"password": "",
|
||||||
|
"domain": "",
|
||||||
|
"sub_domain": "",
|
||||||
|
"ip_url": ""
|
||||||
|
}
|
29
godns.go
Normal file
29
godns.go
Normal 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
34
settings.go
Normal 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
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user