mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-16 01:55:01 +03:00
fix(tgbot): build a client's individual links in-process
The bot's "individual links" and QR actions fetched the client's own subscription over HTTP from the public URL it builds for display. With no sub or web domain set that URL falls back to the machine's hostname, which usually does not resolve (`lookup exhausted-reply: no such host`), and even a resolvable name fails behind NAT, a firewall or a disabled sub server. Both actions now ask InboundService.GetSubLinks, the in-process provider the panel's links API already uses, with the host taken from that same URL so the link addresses are unchanged. The now-unused pooled HTTP client goes too. Closes #6597
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"crypto/rand"
|
||||
"embed"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
@@ -48,8 +47,7 @@ var (
|
||||
EventBus *eventbus.Bus
|
||||
|
||||
// Performance improvements
|
||||
messageWorkerPool chan struct{} // Semaphore for limiting concurrent message processing
|
||||
optimizedHTTPClient *http.Client // HTTP client with connection pooling and timeouts
|
||||
messageWorkerPool chan struct{} // Semaphore for limiting concurrent message processing
|
||||
|
||||
// Simple cache for frequently accessed data
|
||||
statusCache struct {
|
||||
@@ -306,17 +304,6 @@ func (t *Tgbot) Start(i18nFS embed.FS) error {
|
||||
// Initialize worker pool for concurrent message processing (max 10 concurrent handlers)
|
||||
messageWorkerPool = make(chan struct{}, 10)
|
||||
|
||||
// Initialize optimized HTTP client with connection pooling
|
||||
optimizedHTTPClient = &http.Client{
|
||||
Timeout: 15 * time.Second,
|
||||
Transport: &http.Transport{
|
||||
MaxIdleConns: 100,
|
||||
MaxIdleConnsPerHost: 10,
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
DisableKeepAlives: false,
|
||||
},
|
||||
}
|
||||
|
||||
t.SetHostname()
|
||||
|
||||
// Get Telegram bot token
|
||||
|
||||
Reference in New Issue
Block a user