Skip to content

fix: allow binding to localhost and all RFC 1918 addresses#33

Merged
dvershinin merged 2 commits intomasterfrom
fix/localhost-bind
Mar 17, 2026
Merged

fix: allow binding to localhost and all RFC 1918 addresses#33
dvershinin merged 2 commits intomasterfrom
fix/localhost-bind

Conversation

@dvershinin
Copy link

Summary

  • Expand PID validation in engine/engine.c to accept all private/loopback ranges (127.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) in addition to 10.0.0.0/8
  • Skip binding outgoing connections to loopback in net/net-events.c so Telegram DC traffic uses the default interface

Test plan

  • Build passes in CI
  • --address 127.0.0.1 no longer prints "Bad binded IP address" warning
  • Outgoing connections to Telegram DCs work when bound to loopback
  • Existing --address 10.x.x.x behavior unchanged

Closes #32

Expand PID validation to accept 127.0.0.0/8, 172.16.0.0/12, and
192.168.0.0/16 in addition to 10.0.0.0/8. Skip binding outgoing
connections to loopback so Telegram DC traffic uses the default
interface.

Closes #32
)

The /stats HTTP endpoint was hardcoded to only respond to 127.0.0.1.
When running in Docker, host requests arrive via the bridge network
(172.17.0.1), causing the stats endpoint to reject them. Replace the
localhost-only check with an is_private_ip() helper that accepts all
RFC 1918 ranges (10/8, 172.16/12, 192.168/16) plus loopback (127/8).
@dvershinin dvershinin merged commit eab5096 into master Mar 17, 2026
3 checks passed
@dvershinin dvershinin deleted the fix/localhost-bind branch March 17, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MTProxy cannot bind to localhost (127.0.0.1)

1 participant