remove lock, change run one time

This commit is contained in:
Jay 2018-09-26 19:42:38 +08:00
parent 4d63b93edb
commit e525ac65fe
3 changed files with 3 additions and 34 deletions

View File

@ -1,4 +1,3 @@
interface: eth0
domains:
- name: domain.name
subdomain:

35
main.go
View File

@ -5,10 +5,8 @@ import (
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"regexp"
"time"
"git.trj.tw/golang/go-aws-dns/modules"
@ -44,31 +42,12 @@ func main() {
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")
checkErr(err)
}
println(ip)
mainLoc := make(chan bool)
var tmp []string
for _, it := range config.Domains {
@ -100,18 +79,10 @@ func main() {
fmt.Println(domains[0])
go func() {
for {
println("run loop")
for _, it := range domains {
it.updateRecord()
}
for _, it := range domains {
it.updateRecord()
}
time.Sleep(time.Minute * 5)
}
}()
<-mainLoc
}
func newR53() {

View File

@ -11,7 +11,6 @@ import (
)
type Config struct {
NIC string `yaml:"interface"`
Domains []struct {
Name string `yaml:"name"`
Sub []string `yaml:"subdomain,flow"`