mirror of
https://github.com/daeuniverse/dae.git
synced 2024-12-22 20:54:41 +07:00
optimize: add a new link for network check
This commit is contained in:
parent
300cb6928a
commit
6e1401e9a0
2
Makefile
2
Makefile
@ -20,7 +20,7 @@ ifeq ($(strip $(NOSTRIP)),y)
|
||||
else ifeq ($(wildcard $(STRIP_PATH)),)
|
||||
STRIP_FLAG := -no-strip
|
||||
else
|
||||
STRIP_FLAG := -strip=$(STRIP)
|
||||
STRIP_FLAG := -strip=$(STRIP_PATH)
|
||||
endif
|
||||
|
||||
# Get version from .git.
|
||||
|
16
cmd/run.go
16
cmd/run.go
@ -12,6 +12,7 @@ import (
|
||||
"github.com/okzk/sdnotify"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
@ -27,10 +28,21 @@ const (
|
||||
PidFilePath = "/var/run/dae.pid"
|
||||
)
|
||||
|
||||
var (
|
||||
CheckNetworkLinks = []string{
|
||||
"http://www.msftconnecttest.com/connecttest.txt",
|
||||
"http://www.qualcomm.cn/generate_204",
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
runCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file")
|
||||
runCmd.PersistentFlags().BoolVarP(&disableTimestamp, "disable-timestamp", "", false, "disable timestamp")
|
||||
runCmd.PersistentFlags().BoolVarP(&disableTimestamp, "disable-pidfile", "", false, "not generate /var/run/dae.pid")
|
||||
|
||||
rand.Shuffle(len(CheckNetworkLinks), func(i, j int) {
|
||||
CheckNetworkLinks[i], CheckNetworkLinks[j] = CheckNetworkLinks[j], CheckNetworkLinks[i]
|
||||
})
|
||||
}
|
||||
|
||||
var (
|
||||
@ -217,8 +229,8 @@ func newControlPlane(log *logrus.Logger, bpf interface{}, dnsCache map[string]*c
|
||||
resolvingfailed := false
|
||||
if !conf.Global.DisableWaitingNetwork && len(conf.Subscription) > 0 {
|
||||
log.Infoln("Waiting for network...")
|
||||
for {
|
||||
resp, err := http.Get("http://www.msftconnecttest.com/connecttest.txt")
|
||||
for i := 0; ; i++ {
|
||||
resp, err := http.Get(CheckNetworkLinks[i%len(CheckNetworkLinks)])
|
||||
if err != nil {
|
||||
time.Sleep(5 * time.Second)
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user