mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-08 11:16:18 +00:00
Update server.go
This commit is contained in:
parent
78aea52745
commit
6153804ce5
1 changed files with 17 additions and 2 deletions
|
@ -74,6 +74,7 @@ type Status struct {
|
||||||
Recv uint64 `json:"recv"`
|
Recv uint64 `json:"recv"`
|
||||||
} `json:"netTraffic"`
|
} `json:"netTraffic"`
|
||||||
PublicIP struct {
|
PublicIP struct {
|
||||||
|
HostName string `json:"hostname"`
|
||||||
IPv4 string `json:"ipv4"`
|
IPv4 string `json:"ipv4"`
|
||||||
IPv6 string `json:"ipv6"`
|
IPv6 string `json:"ipv6"`
|
||||||
} `json:"publicIP"`
|
} `json:"publicIP"`
|
||||||
|
@ -209,8 +210,22 @@ func (s *ServerService) GetStatus(lastStatus *Status) *Status {
|
||||||
logger.Warning("get udp connections failed:", err)
|
logger.Warning("get udp connections failed:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
status.PublicIP.IPv4 = getPublicIP("https://api.ipify.org")
|
status.PublicIP.HostName, _ = os.Hostname()
|
||||||
status.PublicIP.IPv6 = getPublicIP("https://api6.ipify.org")
|
// get ip address
|
||||||
|
netInterfaces, _ := net.Interfaces()
|
||||||
|
for i := 0; i < len(netInterfaces); i++ {
|
||||||
|
if len(netInterfaces[i].Flags) > 2 && netInterfaces[i].Flags[0] == "up" && netInterfaces[i].Flags[1] != "loopback" {
|
||||||
|
addrs := netInterfaces[i].Addrs
|
||||||
|
|
||||||
|
for _, address := range addrs {
|
||||||
|
if strings.Contains(address.Addr, ".") {
|
||||||
|
status.PublicIP.IPv4 += address.Addr + " "
|
||||||
|
} else if address.Addr[0:6] != "fe80::" {
|
||||||
|
status.PublicIP.IPv6 += address.Addr + " "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if s.xrayService.IsXrayRunning() {
|
if s.xrayService.IsXrayRunning() {
|
||||||
status.Xray.State = Running
|
status.Xray.State = Running
|
||||||
|
|
Loading…
Reference in a new issue