Skip to content

Commit

Permalink
improve: Handle case when host is not found in LookupGeoIP
Browse files Browse the repository at this point in the history
  • Loading branch information
naiba committed Jul 28, 2024
1 parent df9487b commit fe234f4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions service/rpc/nezha.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,10 @@ func (s *NezhaHandler) LookupGeoIP(c context.Context, r *pb.GeoIP) (*pb.GeoIP, e
// 将地区码写入到 Host
singleton.ServerLock.RLock()
defer singleton.ServerLock.RUnlock()
if singleton.ServerList[clientID].Host != nil {
singleton.ServerList[clientID].Host.CountryCode = location
if singleton.ServerList[clientID].Host == nil {
return nil, fmt.Errorf("host not found")
}
singleton.ServerList[clientID].Host.CountryCode = location

return &pb.GeoIP{Ip: ip, CountryCode: location}, nil
}

0 comments on commit fe234f4

Please sign in to comment.