Skip to content

Commit

Permalink
fix: CountryCode 被冲掉
Browse files Browse the repository at this point in the history
  • Loading branch information
naiba committed Jul 28, 2024
1 parent 26d81f6 commit df9487b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions service/rpc/nezha.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

0 comments on commit df9487b

Please sign in to comment.