xelaj / mtproto

🦋 Full-native go implementation of Telegram API
MIT License
1.23k stars 133 forks source link

[BUG]: Recreation Connection fails with IPv6 parsing error #86

Closed MJDrgn closed 3 years ago

MJDrgn commented 3 years ago

Description

When running in WSL2 (Ubuntu 20.04), upon first request (in my case AuthSendCode) a reconnection is attempted to an invalid address. I'm not exactly sure why that IP is invalid, or where it comes from - presumably it's a telegram DC?

panic: failed AuthSendCode: sending AuthSendCode: recreating connection: can't connect: setup connection: resolving tcp: address 2001:0b28:f23d:f003:0000:0000:0000:000a: too many colons in address

The exact same code works on Windows past this point. It appears this may be related to the system just having v6 in general - although not sure why it doesn't occur on Windows.

Failed snippet

    config := telegram.ClientConfig{
        SessionFile: sessFile,
        ServerHost: "149.154.167.50:443",
        PublicKeysFile: publicKeys,
        AppID: snip,
        AppHash: "snip",
        InitWarnChannel: true,
    }
    client, err := telegram.NewClient(config)
    signedIn, err := client.IsSessionRegistred()
    setCode, err := client.AuthSendCode(
        phone, int32(config.AppID), config.AppHash, &telegram.CodeSettings{},
    )

Expected behavior

AuthSendCode completes without error

Additional context

MJDrgn commented 3 years ago

Minor addition: I have now reproduced this on Windows as well, although only once and it seems intermittent as I haven't got it again even re-running the same code.

MJDrgn commented 3 years ago

This is a duplicate of #82