Browse Source

fix: wait when ipv6 setting up

v1.x.x
dnomd343 2 years ago
parent
commit
49aa36fc99
  1. 5
      cmd/network/main.go
  2. 6
      cmd/process/daemon.go
  3. 0
      cmd/radvd/radvd.go
  4. 11
      cmd/xproxy.go

5
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())
}

6
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)

0
cmd/radvd/main.go → cmd/radvd/radvd.go

11
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)

Loading…
Cancel
Save