mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
fix and improve
This commit is contained in:
parent
c0f1a926e5
commit
d40e61fc45
4 changed files with 21 additions and 24 deletions
|
@ -145,12 +145,7 @@ func (a *InboundController) getClientIps(c *gin.Context) {
|
|||
email := c.Param("email")
|
||||
|
||||
ips, err := a.inboundService.GetInboundClientIps(email)
|
||||
if err != nil {
|
||||
jsonObj(c, "Failed to get client IPs", nil)
|
||||
return
|
||||
}
|
||||
|
||||
if ips == "" {
|
||||
if err != nil || ips == "" {
|
||||
jsonObj(c, "No IP Record", nil)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -124,12 +124,14 @@
|
|||
try {
|
||||
const msg = await HttpUtil.post(`/panel/inbound/clientIps/${email}`);
|
||||
if (!msg.success) {
|
||||
document.getElementById("clientIPs").value = msg.obj;
|
||||
return;
|
||||
}
|
||||
const ips = JSON.parse(msg.obj).join(",\n");
|
||||
const ips = Array.isArray(msg.obj) ? msg.obj.join(",\n") : msg.obj;
|
||||
document.getElementById("clientIPs").value = ips;
|
||||
} catch (error) {
|
||||
document.getElementById("clientIPs").value = msg.obj;
|
||||
console.error(error);
|
||||
document.getElementById("clientIPs").value = 'An error occurred while making the request';
|
||||
}
|
||||
},
|
||||
async clearDBClientIps(email) {
|
||||
|
|
|
@ -449,9 +449,13 @@
|
|||
this.loadingTip = tip;
|
||||
},
|
||||
async getStatus() {
|
||||
const msg = await HttpUtil.post('/server/status');
|
||||
if (msg.success) {
|
||||
this.setStatus(msg.obj);
|
||||
try {
|
||||
const msg = await HttpUtil.post('/server/status');
|
||||
if (msg.success) {
|
||||
this.setStatus(msg.obj);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to get status:", e);
|
||||
}
|
||||
},
|
||||
setStatus(data) {
|
||||
|
@ -560,11 +564,14 @@
|
|||
},
|
||||
},
|
||||
async mounted() {
|
||||
while (true) {
|
||||
let retries = 0;
|
||||
while (retries < 5) {
|
||||
try {
|
||||
await this.getStatus();
|
||||
retries = 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
console.error("Error occurred while fetching status:", e);
|
||||
retries++;
|
||||
}
|
||||
await PromiseUtil.sleep(2000);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue