Browse Source

remove lock, change run one time

master
Jay 3 years ago
parent
commit
e525ac65fe
  1. 1
      config.default.yml
  2. 35
      main.go
  3. 1
      modules/setting.go

1
config.default.yml

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

35
main.go

@ -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()
}
time.Sleep(time.Minute * 5)
}
}()
for _, it := range domains {
it.updateRecord()
}
<-mainLoc
}
func newR53() {

1
modules/setting.go

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

Loading…
Cancel
Save