1 Commits

Author SHA1 Message Date
root 4d63b93edb add nic check 2018-09-10 10:44:23 +08:00
3 changed files with 22 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
interface: eth0
domains:
- name: domain.name
subdomain:
+20
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"regexp"
"time"
@@ -42,6 +43,25 @@ func main() {
newR53()
config = setting.LoadConfig(confpath)
fmt.Println(config)
// wait nic
for {
nics, err := net.Interfaces()
if err != nil {
log.Fatal(err)
}
nicFlag := false
for _, v := range nics {
if v.Name == config.NIC {
nicFlag = true
}
}
if nicFlag == true {
break
}
time.Sleep(time.Second * 5)
}
ip = getMyIP()
if ok, err := checkIP(ip); err != nil || !ok {
println("ip check fail")
+1
View File
@@ -11,6 +11,7 @@ import (
)
type Config struct {
NIC string `yaml:"interface"`
Domains []struct {
Name string `yaml:"name"`
Sub []string `yaml:"subdomain,flow"`