🚸 improve: 优化agent取双栈IP、服务状态页面展示策略

This commit is contained in:
naiba
2021-01-16 11:23:42 +08:00
parent a41c792577
commit 345511e90f
7 changed files with 75 additions and 17 deletions

View File

@@ -26,7 +26,7 @@ var SortedServerList []*model.Server
var ServerLock sync.RWMutex
var Version = "v0.2.0"
var Version = "v0.2.1"
func ReSortServer() {
SortedServerList = []*model.Server{}

View File

@@ -43,6 +43,14 @@ func GetHost() *model.Host {
body, _ := ioutil.ReadAll(resp.Body)
json.Unmarshal(body, &ip)
}
resp, err = http.Get("https://api-ipv6.ip.sb/ip")
if err == nil {
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
ip.IP = fmt.Sprintf("ip(v4: %s, v6: %s)", ip.IP, body)
}
return &model.Host{
Platform: hi.OS,
PlatformVersion: hi.PlatformVersion,

View File

@@ -87,7 +87,8 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece
host := model.PB2Host(r)
dao.ServerLock.RLock()
defer dao.ServerLock.RUnlock()
if dao.ServerList[clientID].Host != nil &&
if dao.Conf.EnableIPChangeNotification &&
dao.ServerList[clientID].Host != nil &&
dao.ServerList[clientID].Host.IP != "" &&
host.IP != "" &&
dao.ServerList[clientID].Host.IP != host.IP {