TL;DR
mtg (version 2.2.8) causes 90%+ CPU usage and accumulates thousands of ESTABLISHED connections when running on a host where IPv6 is partially unavailable (ICMP works, but specific Telegram IPv6 prefixes are unreachable). The issue persists even after disabling IPv6 via sysctl and ip6tables.
Environment
- mtg version: 2.2.8 (also reproducible on 2.2.7)
- Deployment: Docker with
--network=host
- Host OS: Ubuntu 22.04 (VPS provider)
- Network: IPv6 partially available (server has IPv6, can ping google.com IPv6, but specific Telegram IPv6 prefixes are unreachable)
Config (sanitized)
debug = false
secret = "<YOUR_SECRET>"
bind-to = "0.0.0.0:443"
concurrency = 2000
ad_tag = "<YOUR_TAG>"
tolerate-time-skewness = "10s"
prefer-ip = "prefer-ipv4"
ipv6 = false
ipv6-only = false
[network]
doh-ip = "9.9.9.9"
ipv4-only = true
prefer-ipv4 = true
[network.timeout]
tcp = "5s"
http = "10s"
idle = "1m"
[defense.anti-replay]
enabled = true
max-size = "1mib"
error-rate = 0.001
Symptoms
- CPU spikes to 90%+ with only a few dozen active users
- Thousands of
ESTABLISHED connections from a single IP (Docker host 172.17.0.1)
- Persistent IPv6 connection attempts despite all configuration flags:
{"level":"warn","dc":203,"logger":"proxy","error":"no addresses to call: dial tcp6 [2a0a:f280:203:a:5000::100]:443: connect: cannot assign requested address","message":"cannot dial to telegram"}
ss shows active IPv6 connections even after ip6tables -P OUTPUT DROP and sysctl net.ipv6.conf.all.disable_ipv6=1
What I've tried (none worked)
- Setting
ipv6 = false, ipv4-only = true, prefer-ipv4 = true
- System-level IPv6 disable:
sysctl -w net.ipv6.conf.all.disable_ipv6=1
- Firewall block:
ip6tables -P OUTPUT DROP and ip6tables -P INPUT DROP
- Environment variables:
GODEBUG=netdns=go, MTG_IPV6=false
- Custom DNS with
options inet4
The issue only temporarily resolves after docker restart, but connections gradually accumulate again.
Hypothesis
The issue likely started after commit "Change IP address set priority" (around v2.2.7). Version 2.2.5 appears stable (need confirmation). It seems mtg ignores both system-level and application-level IPv6 disable flags when the host has partial IPv6 connectivity (ICMP works, but specific prefixes are unreachable). This creates a loop of failed connection attempts, leaking file descriptors and consuming CPU.
Expected behavior
When ipv6 = false or ipv4-only = true is set, mtg should never attempt to dial IPv6 addresses, regardless of DNS responses or system capabilities.
Additional context
- The proxy works fine for actual clients (messages are delivered)
- The issue is not about client IPs (all traffic goes through Docker NAT)
- This happens on a specific VPS provider; may affect other providers with similar IPv6 routing
Request
Please investigate why mtg ignores ipv6 = false and ipv4-only = true settings on hosts with partial IPv6 connectivity. The ability to completely disable IPv6 is critical for deployments on networks where IPv6 is unreliable.
TL;DR
mtg(version 2.2.8) causes 90%+ CPU usage and accumulates thousands ofESTABLISHEDconnections when running on a host where IPv6 is partially unavailable (ICMP works, but specific Telegram IPv6 prefixes are unreachable). The issue persists even after disabling IPv6 viasysctlandip6tables.Environment
--network=hostConfig (sanitized)
Symptoms
ESTABLISHEDconnections from a single IP (Docker host172.17.0.1){"level":"warn","dc":203,"logger":"proxy","error":"no addresses to call: dial tcp6 [2a0a:f280:203:a:5000::100]:443: connect: cannot assign requested address","message":"cannot dial to telegram"}ssshows active IPv6 connections even afterip6tables -P OUTPUT DROPandsysctl net.ipv6.conf.all.disable_ipv6=1What I've tried (none worked)
ipv6 = false,ipv4-only = true,prefer-ipv4 = truesysctl -w net.ipv6.conf.all.disable_ipv6=1ip6tables -P OUTPUT DROPandip6tables -P INPUT DROPGODEBUG=netdns=go,MTG_IPV6=falseoptions inet4The issue only temporarily resolves after
docker restart, but connections gradually accumulate again.Hypothesis
The issue likely started after commit "Change IP address set priority" (around v2.2.7). Version 2.2.5 appears stable (need confirmation). It seems
mtgignores both system-level and application-level IPv6 disable flags when the host has partial IPv6 connectivity (ICMP works, but specific prefixes are unreachable). This creates a loop of failed connection attempts, leaking file descriptors and consuming CPU.Expected behavior
When
ipv6 = falseoripv4-only = trueis set,mtgshould never attempt to dial IPv6 addresses, regardless of DNS responses or system capabilities.Additional context
Request
Please investigate why
mtgignoresipv6 = falseandipv4-only = truesettings on hosts with partial IPv6 connectivity. The ability to completely disable IPv6 is critical for deployments on networks where IPv6 is unreliable.