Skip to content

fix(gateway): keep DoH-confirmed Telegram IPs that match system DNS (#14520)#17043

Closed
0xsir0000 wants to merge 1 commit into
NousResearch:mainfrom
0xsir0000:fix/telegram-network-doh-system-dns-overlap
Closed

fix(gateway): keep DoH-confirmed Telegram IPs that match system DNS (#14520)#17043
0xsir0000 wants to merge 1 commit into
NousResearch:mainfrom
0xsir0000:fix/telegram-network-doh-system-dns-overlap

Conversation

@0xsir0000

Copy link
Copy Markdown
Contributor

Summary

discover_fallback_ips() in gateway/platforms/telegram_network.py filtered out any DoH-resolved IP that also appeared in the local system resolver's answer set, on the assumption that the system IP was unreachable. When DoH and system DNS agreed (a common case), the function returned the hardcoded _SEED_FALLBACK_IPS list instead — and on networks where those seed addresses are not routable, the Telegram fallback transport had no usable retry target and polling failed.

This drops the system_ips exclusion so DoH-confirmed IPs are preserved regardless of system-DNS overlap. TelegramFallbackTransport already tries the primary path first (via system DNS), then falls through to the IP-rewrite path on connect failure; including the same IP in both lanes lets a transient primary failure recover via the explicit IP route instead of escalating to seed addresses that may not route.

The two existing tests that codified the old exclusion are updated to reflect the new inclusion-by-default behaviour and renamed for clarity.

Fixes #14520

Behavior change

Scenario Before After
DoH returns [sys_ip, X], system resolves [sys_ip] [X] [sys_ip, X]
DoH returns [sys_ip], system resolves [sys_ip] _SEED_FALLBACK_IPS (e.g. 149.154.167.220) [sys_ip]
DoH returns [X, Y], system resolves [sys_ip] [X, Y] [X, Y] (unchanged)
DoH unavailable _SEED_FALLBACK_IPS (unchanged) _SEED_FALLBACK_IPS (unchanged)

The third and fourth rows are unchanged, so users on networks where the seed list is reachable retain the existing safety net.

Test plan

  • tests/gateway/test_telegram_network.py — 46 tests pass (12 in TestDiscoverFallbackIps)
  • tests/gateway/test_telegram_network_reconnect.py — 9 tests pass
  • Two existing tests updated:
    • test_system_dns_ip_excludedtest_system_dns_ip_kept_when_doh_confirms
    • test_all_doh_ips_same_as_system_dns_uses_seedtest_all_doh_ips_same_as_system_dns_kept

…ousResearch#14520)

discover_fallback_ips() filtered out any DoH-resolved IP that also appeared
in the system resolver's answer set, on the assumption that the system IP
was unreachable. When DoH and system DNS agreed (a common case), the
function returned the hardcoded _SEED_FALLBACK_IPS list instead — and on
networks where those seed addresses are not routable, the Telegram fallback
transport had nothing usable to retry against and polling failed.

Drop the system_ips exclusion so DoH-confirmed IPs are preserved regardless
of system DNS overlap. The TelegramFallbackTransport already tries the
primary path first via system DNS, then falls through to the IP-rewrite
path on connect failure; including the same IP in both lanes lets a
transient primary failure recover via the explicit IP route instead of
escalating to seed addresses.

Update the two tests that codified the old exclusion to reflect the new,
inclusion-by-default behaviour.

Fixes NousResearch#14520
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels Apr 28, 2026
Sldark23 pushed a commit to Sldark23/hermes-agent that referenced this pull request Apr 28, 2026
- Fix issue NousResearch#17139: Handle deliver as list in cron scheduler (fixes telegram delivery)
- Fix issue NousResearch#17086: custom endpoint URL rewrite preserves /anthropic path when api_mode=anthropic_messages
- Fix issue NousResearch#17054: slack manifest uses "version" instead of broken major/minor_version
- Fix issue NousResearch#17049: wmic subprocess uses encoding='utf-8' with errors='replace' on Windows
- Fix issue NousResearch#17043: DoH resolved IPs no longer excluded when overlapping with system DNS
- Fix issue NousResearch#17140: TTS tools use get_env_value() instead of os.getenv() for API keys
- Fix: hermes_cli/config.py _sanitize_env_lines detects KEY= at non-identifier positions

Files modified:
- agent/auxiliary_client.py
- cron/scheduler.py
- gateway/platforms/telegram_network.py
- hermes_cli/config.py
- hermes_cli/gateway.py
- hermes_cli/slack_cli.py
- tools/tts_tool.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram polling fails when DoH returns same IP as system DNS

2 participants