alexbers / mtprotoproxy

Async MTProto proxy for Telegram
MIT License
1.59k stars 349 forks source link

Experimental link doesn't work in Telegram desktop beta 1.7.15 #115

Closed FreedomPrevails closed 5 years ago

FreedomPrevails commented 5 years ago

I was trying to test the new experimental proxy method in Telegram desktop beta 1.7.15 but it says the proxy link -which is generated by mtprotoproxy- is invalid. The normal link works fine. Here are the links:

tg: tg://proxy?server=x.x.x.x&port=443&secret=ddc54a3eae90544e68a37cbe41c5d31442
tg: tg://proxy?server=x.x.x.x&port=443&secret=7sVKPq6QVE5oo3y%2BQcXTFEJnb29nbGUuY29t

I see other users have the same issue in other topic https://github.com/alexbers/mtprotoproxy/issues/113

seriyps commented 5 years ago

%2B is urlencoded +, but telegram only understands "urlsafe" version of base64: all + should be replaced with - and all / with _:

https://github.com/seriyps/mtproto_proxy/blob/c31ba04e5681a2991ce495a6c17e5fb94357daa7/src/mtp_fake_tls.erl#L78-L84

But it's better to be fixed in source code than manually later:

https://github.com/alexbers/mtprotoproxy/blob/80062c95bc488b4f5b5dc34833812769eaeee3a4/mtprotoproxy.py#L1423

base64.b64encode(tls_secret) should be replaced with base64.urlsafe_b64encode(tls_secret)

FreedomPrevails commented 5 years ago

@seriyps Thanks ! replacing %2B with - resolved the issue. @alexbers

HirbodBehnam commented 5 years ago

BTW guys they released the version of the telergam that supports the fake TLS! On Android it's version 5.10 On PC it's version 1.8

hookzof commented 5 years ago

BTW guys they released the version of the MTProto proxy that supports the fake TLS! On Android it's version 5.10 On PC it's version 1.8

Confirm! Also works on latest iOS.

pouryare commented 5 years ago

Is this feature need any module? I can't even connect to the default secret.

FreedomPrevails commented 5 years ago

If you are interested I have forked the repo and added TLS_ONLY option and fixed the TLS encoding bug : https://github.com/FreedomPrevails/mtprotoproxy

pouryare commented 5 years ago

@FreedomPrevails I tried it but it doesn't work either.

FreedomPrevails commented 5 years ago

@pouryare May be your IP is blocked or something else, you cant even connect to default secret. Your issue has nothing to do with TLS.

pouryare commented 5 years ago

@FreedomPrevails I can connect to non TLS.

FreedomPrevails commented 5 years ago

@seriyps I found out something interesting, i fixed the function to base64.urlsafe_b64encode and it generates a secret which includes a - character. but ios version of telegram, doesnt accept the secret if it has the - char, I had to change it to + manually so it would accept the secret ! The android and desktop versions accept the secret with - char.

alexbers commented 5 years ago

it seems there is a bug in the ios client. Hope they will fix it

FreedomPrevails commented 5 years ago

Yes, I opened an issue an Telegram-iOS github: https://github.com/TelegramMessenger/Telegram-iOS/issues/118

imedfan commented 5 years ago

After generating the secret and registering the bot in @MTProxybot it worked.

FreedomPrevails commented 5 years ago

This issue is resolved.