mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
optimize: add a page prompt when waiting for the network connected
This commit is contained in:
1 parent
6aca90267b
commit
daa7168ba1
1 file changed
+19
-1
+19
-1
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
jsonIteratorExtra "github.com/json-iterator/go/extra"
|
||||
"github.com/v2rayA/v2rayA/common/netTools/ports"
|
||||
"github.com/v2rayA/v2rayA/common/resolv"
|
||||
@@ -89,14 +90,31 @@ func initDBValue() {
|
||||
func initConfigure() {
|
||||
//等待网络连通
|
||||
v2ray.CheckAndStopTransparentProxy()
|
||||
var l net.Listener
|
||||
for {
|
||||
addrs, err := resolv.LookupHost("www.apple.com")
|
||||
if err == nil && len(addrs) > 0 {
|
||||
break
|
||||
}
|
||||
log.Alert("waiting for network connected")
|
||||
if l == nil {
|
||||
if l, err = net.Listen("tcp", conf.GetEnvironmentConfig().Address); err != nil {
|
||||
log.Fatal("%v", err)
|
||||
}
|
||||
e := gin.New()
|
||||
e.GET("/", func(c *gin.Context) {
|
||||
c.Header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate")
|
||||
c.Header("Pragma", "no-cache")
|
||||
c.Header("Expires", "0")
|
||||
c.String(200, "Waiting for the network connected; refresh the page later.\n正在等待网络连接,请稍后刷新页面。")
|
||||
})
|
||||
go e.RunListener(l)
|
||||
}
|
||||
log.Alert("waiting for the network connected")
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
if l != nil {
|
||||
l.Close()
|
||||
}
|
||||
log.Alert("network is connected")
|
||||
//初始化配置
|
||||
jsonIteratorExtra.RegisterFuzzyDecoders()
|
||||
|
||||
Reference in new issue
Block a user