fix and improve

This commit is contained in:
MHSanaei
2023-06-14 19:50:19 +03:30
parent c0f1a926e5
commit d40e61fc45
4 changed files with 21 additions and 24 deletions

View File

@@ -86,31 +86,24 @@ type ServerService struct {
inboundService InboundService
}
const DebugMode = false // Set to true during development
func getPublicIP(url string) string {
resp, err := http.Get(url)
if err != nil {
if DebugMode {
logger.Warning("get public IP failed:", err)
}
return "N/A"
}
defer resp.Body.Close()
ip, err := io.ReadAll(resp.Body)
if err != nil {
if DebugMode {
logger.Warning("read public IP failed:", err)
}
return "N/A"
}
if string(ip) == "" {
return "N/A" // default value
ipString := string(ip)
if ipString == "" {
return "N/A"
}
return string(ip)
return ipString
}
func (s *ServerService) GetStatus(lastStatus *Status) *Status {