refactor: fallback agent ip to connecting ip

This commit is contained in:
naiba
2024-12-19 23:21:31 +08:00
parent 1827963a8b
commit 8b959b213f
6 changed files with 38 additions and 26 deletions

View File

@@ -201,9 +201,18 @@ func (s *NezhaHandler) ReportGeoIP(c context.Context, r *pb.GeoIP) (*pb.GeoIP, e
}
geoip := model.PB2GeoIP(r)
joinedIP := geoip.IP.Join()
use6 := r.GetUse6()
if geoip.IP.IPv4Addr == "" && geoip.IP.IPv6Addr == "" {
ip, _ := c.Value(model.CtxKeyRealIP{}).(string)
if ip == "" {
ip, _ = c.Value(model.CtxKeyConnectingIP{}).(string)
}
geoip.IP.IPv4Addr = ip
}
joinedIP := geoip.IP.Join()
singleton.ServerLock.RLock()
// 检查并更新DDNS
if singleton.ServerList[clientID].EnableDDNS && joinedIP != "" &&

View File

@@ -9,10 +9,10 @@
name: "Official"
repository: "https://github.com/hamster1963/nezha-dash-v1"
author: "hamster1963"
version: "v1.4.5"
version: "v1.6.1"
isofficial: true
- path: "nazhua-dist"
name: "Nazhua"
repository: "https://github.com/hi2shark/nazhua"
author: "hi2hi"
version: "v0.4.20"
version: "v0.4.22"