From df9487b5fc5ba5bcf14962e565bf4b4962d8e769 Mon Sep 17 00:00:00 2001 From: naiba Date: Sun, 28 Jul 2024 14:39:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CountryCode=20=E8=A2=AB=E5=86=B2?= =?UTF-8?q?=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/rpc/nezha.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/service/rpc/nezha.go b/service/rpc/nezha.go index 661ccb858a..16bc68553f 100644 --- a/service/rpc/nezha.go +++ b/service/rpc/nezha.go @@ -138,7 +138,6 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece singleton.ServerList[clientID].Host != nil && host.IP != "" && singleton.ServerList[clientID].Host.IP != host.IP { - serverDomain := singleton.ServerList[clientID].DDNSDomain if singleton.Conf.DDNS.Provider == "" { provider, err = singleton.GetDDNSProviderFromProfile(singleton.ServerList[clientID].DDNSProfile) @@ -191,6 +190,11 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece singleton.ServerList[clientID].PrevHourlyTransferOut = singleton.ServerList[clientID].PrevHourlyTransferOut - int64(singleton.ServerList[clientID].State.NetOutTransfer) } + // 不要冲掉国家码 + if singleton.ServerList[clientID].Host != nil { + host.CountryCode = singleton.ServerList[clientID].Host.CountryCode + } + singleton.ServerList[clientID].Host = &host return &pb.Receipt{Proced: true}, nil } @@ -239,7 +243,9 @@ func (s *NezhaHandler) LookupGeoIP(c context.Context, r *pb.GeoIP) (*pb.GeoIP, e // 将地区码写入到 Host singleton.ServerLock.RLock() defer singleton.ServerLock.RUnlock() - singleton.ServerList[clientID].Host.CountryCode = location + if singleton.ServerList[clientID].Host != nil { + singleton.ServerList[clientID].Host.CountryCode = location + } return &pb.GeoIP{Ip: ip, CountryCode: location}, nil }