mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-03-14 07:03:09 +00:00
Improve telego client robustness and retries
Add a createRobustFastHTTPClient helper to configure fasthttp.Client with better timeouts, connection limits, retries and optional SOCKS5 proxy dialing. Validate and sanitize proxy and API server URLs instead of returning early on invalid values, and build telego.Bot options dynamically. Reduce long-polling timeout to detect connection issues faster and adjust update retrieval comments. Implement exponential-backoff retry logic for SendMessage calls to handle transient connection/timeouts and improve delivery reliability; also reduce inter-message delay for better throughput.
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -719,25 +719,25 @@ func (s *SettingService) GetDefaultXrayConfig() (any, error) {
|
||||
}
|
||||
|
||||
func extractHostname(host string) string {
|
||||
h, _, err := net.SplitHostPort(host)
|
||||
// Err is not nil means host does not contain port
|
||||
if err != nil {
|
||||
h = host
|
||||
}
|
||||
h, _, err := net.SplitHostPort(host)
|
||||
// Err is not nil means host does not contain port
|
||||
if err != nil {
|
||||
h = host
|
||||
}
|
||||
|
||||
ip := net.ParseIP(h)
|
||||
// If it's not an IP, return as is
|
||||
if ip == nil {
|
||||
return h
|
||||
}
|
||||
ip := net.ParseIP(h)
|
||||
// If it's not an IP, return as is
|
||||
if ip == nil {
|
||||
return h
|
||||
}
|
||||
|
||||
// If it's an IPv4, return as is
|
||||
if ip.To4() != nil {
|
||||
return h
|
||||
}
|
||||
// If it's an IPv4, return as is
|
||||
if ip.To4() != nil {
|
||||
return h
|
||||
}
|
||||
|
||||
// IPv6 needs bracketing
|
||||
return "[" + h + "]"
|
||||
// IPv6 needs bracketing
|
||||
return "[" + h + "]"
|
||||
}
|
||||
|
||||
func (s *SettingService) GetDefaultSettings(host string) (any, error) {
|
||||
|
||||
Reference in New Issue
Block a user