diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..03ff754 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,15 @@ +stages: + - build + - test + +build-my-project: + stage: build + script: + - cd $CURRENT_BUILD_PATH + - go build + +test-my-project: + stage: test + script: + - cd $CURRENT_BUILD_PATH + - go test \ No newline at end of file diff --git a/dns_handler_test.go b/dns_handler_test.go new file mode 100644 index 0000000..1f4dc8e --- /dev/null +++ b/dns_handler_test.go @@ -0,0 +1,13 @@ +package main + +import ( + "testing" +) + +func Test_get_current_IP(t *testing.T) { + ip, _ := get_currentIP("http://members.3322.org/dyndns/getip") + + if ip == "" { + t.Error("Cannot get IP...") + } +} diff --git a/godns.go b/godns.go index 6ab13e3..c358971 100644 --- a/godns.go +++ b/godns.go @@ -5,10 +5,7 @@ import ( "log" "runtime/debug" "strings" - "syscall" "time" - - "bitbucket.org/abotoo/gonohup" ) const ( @@ -37,35 +34,7 @@ func main() { Configuration = LoadSettings(*optConf) - ctx := gonohup.Context{ - Hash: "godns", - User: Configuration.User, - Group: Configuration.Group, - Command: *optCommand, - } - sig, err := gonohup.Daemonize(ctx) - if err != nil { - log.Println("Daemonize:", err) - return - } - - err = gonohup.InitLogger(Configuration.Log_Path, Configuration.Log_Size, Configuration.Log_Num) - if err != nil { - log.Println("InitLogger error:", err) - return - } - go dns_loop() - - for s := range sig { - switch s { - case syscall.SIGHUP, syscall.SIGUSR2: - // do some custom jobs while reload/hotupdate - case syscall.SIGTERM: - // do some clean up and exit - return - } - } } func dns_loop() {