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:
MHSanaei
2026-09-27 18:07:33 +02:00
parent 3308c816db
commit 4df570b3b0
3 changed files with 125 additions and 116 deletions
+1 -14
View File
@@ -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