From 49aa36fc991caf01978fe0017f709f92a820f704 Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Thu, 18 Aug 2022 18:51:35 +0800 Subject: [PATCH] fix: wait when ipv6 setting up --- cmd/network/main.go | 5 ++--- cmd/process/daemon.go | 6 +++--- cmd/radvd/{main.go => radvd.go} | 0 cmd/xproxy.go | 11 +++++------ 4 files changed, 10 insertions(+), 12 deletions(-) rename cmd/radvd/{main.go => radvd.go} (100%) diff --git a/cmd/network/main.go b/cmd/network/main.go index 6c5fff8..d85633a 100644 --- a/cmd/network/main.go +++ b/cmd/network/main.go @@ -17,13 +17,12 @@ type Config struct { var run = common.RunCommand func Load(dns []string, ipv4 Config, ipv6 Config) { - var delay time.Duration = 1 loadDns(dns) // init dns server flushNetwork() // clear network settings loadV4Network(ipv4) loadV6Network(ipv6) - log.Infof("Wait %ds for IPv6 setting up", delay) - time.Sleep(delay * time.Second) // wait for ipv6 setting up (ND protocol) + log.Info("Wait 1s for IPv6 setting up") + time.Sleep(time.Second) // wait for ipv6 setting up (ND protocol) -> RA should reply less than 0.5s loadV4TProxy(ipv4, getV4Cidr()) loadV6TProxy(ipv6, getV6Cidr()) } diff --git a/cmd/process/daemon.go b/cmd/process/daemon.go index d2221c5..19fe324 100644 --- a/cmd/process/daemon.go +++ b/cmd/process/daemon.go @@ -10,8 +10,8 @@ func daemonSub(sub *Process) { sub.Wait() } log.Warningf("Catch process %s exit", sub.name) - time.Sleep(100 * time.Millisecond) // delay 100ms - if !exitFlag { // not in exit process + time.Sleep(3 * time.Second) // delay 3s + if !exitFlag { // not in exit process sub.Run(true) log.Infof("Process %s restart success", sub.name) daemonSub(sub) @@ -23,7 +23,7 @@ func (p *Process) Daemon() { log.Infof("Process %s disabled -> skip daemon", p.name) return } - log.Infof("Start daemon of process %s", p.name) + log.Infof("Daemon of process %s start", p.name) go func() { daemonSub(p) // start daemon process log.Infof("Process %s exit daemon mode", p.name) diff --git a/cmd/radvd/main.go b/cmd/radvd/radvd.go similarity index 100% rename from cmd/radvd/main.go rename to cmd/radvd/radvd.go diff --git a/cmd/xproxy.go b/cmd/xproxy.go index 70a579f..4bcf55d 100644 --- a/cmd/xproxy.go +++ b/cmd/xproxy.go @@ -3,14 +3,13 @@ package main import ( "XProxy/cmd/config" "XProxy/cmd/process" - "fmt" log "github.com/sirupsen/logrus" "os" "os/signal" "syscall" ) -var version = "dev" +var version = "0.0.9" var v4RouteTable = 100 var v6RouteTable = 106 @@ -53,12 +52,12 @@ func main() { }() log.SetLevel(log.DebugLevel) - fmt.Println("XProxy start -> version =", version) + log.Infof("XProxy %s start", version) settings := config.Load(configFile) - //loadNetwork(&settings) - //loadProxy(&settings) - //loadAsset(&settings) + loadNetwork(&settings) + loadProxy(&settings) + loadAsset(&settings) loadRadvd(&settings) runScript(&settings)