improve: Handle case when host is not found in LookupGeoIP
This commit is contained in:
parent
df9487b5fc
commit
fe234f4f38
@ -243,9 +243,10 @@ func (s *NezhaHandler) LookupGeoIP(c context.Context, r *pb.GeoIP) (*pb.GeoIP, e
|
|||||||
// 将地区码写入到 Host
|
// 将地区码写入到 Host
|
||||||
singleton.ServerLock.RLock()
|
singleton.ServerLock.RLock()
|
||||||
defer singleton.ServerLock.RUnlock()
|
defer singleton.ServerLock.RUnlock()
|
||||||
if singleton.ServerList[clientID].Host != nil {
|
if singleton.ServerList[clientID].Host == nil {
|
||||||
singleton.ServerList[clientID].Host.CountryCode = location
|
return nil, fmt.Errorf("host not found")
|
||||||
}
|
}
|
||||||
|
singleton.ServerList[clientID].Host.CountryCode = location
|
||||||
|
|
||||||
return &pb.GeoIP{Ip: ip, CountryCode: location}, nil
|
return &pb.GeoIP{Ip: ip, CountryCode: location}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user