telegram icon indicating copy to clipboard operation
telegram copied to clipboard

Bridge Setup with IPv6 only

Open LiohMoeller opened this issue 3 years ago • 3 comments

We are trying to setup the Bridge on a IPv6-only VM (no IPv4 available at all). We have noticed that it always tries to connect to IPv4 addresses from Telegram, even if a custom server is defined like that:

    # Custom server to connect to.
    server:
        # Set to true to use these server settings. If false, will automatically
        # use production server assigned by Telegram. Set to false in production.
        enabled: true
        # The DC ID to connect to.
        dc: 2
        # The IP to connect to.
        ip: 2001:067c:04e8:f002:0000:0000:0000:000d

The IP address from above is retreived like curl -s https://core.telegram.org/getProxyConfigV6

The messages in the log look like this:

[[email protected]] Attempt 3 at connecting failed: OSError: [Errno 101] Connect call failed ('149.154.167.51', 443)

LiohMoeller avatar Jul 17 '21 13:07 LiohMoeller

telethon_sessions always contains an IPv4 address:

SELECT * FROM telethon_sessions;
session_id  dc_id  server_address  port  auth_key
----------  -----  --------------  ----  --------
bot         2      149.154.167.51  443 

LiohMoeller avatar Jul 17 '21 13:07 LiohMoeller

I fixed this by editing telethon/client/telegrambaseclient.py

When you change: use_ipv6: bool = False, to use_ipv6: bool = True,

IPv6 starts working right away without any modifications to mautrix-telegram config or code.

I'll try to tidy up this fix and submit a patch when I have the time.

jellekaufmann avatar Aug 18 '21 14:08 jellekaufmann

Any news on that?

frederictobiasc avatar Apr 05 '22 11:04 frederictobiasc