Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket transport support #90

Open
robin98 opened this issue Jan 31, 2023 · 4 comments
Open

Websocket transport support #90

robin98 opened this issue Jan 31, 2023 · 4 comments

Comments

@robin98
Copy link

robin98 commented Jan 31, 2023

Is there any chance this script will support WS or Websocket transport for MTProto? as CloudFlare CDN don't allow TCP traffic pass through their CDN and I can only use WS of grpc.

https://core.telegram.org/mtproto
https://core.telegram.org/mtproto/transports#websocket

@seriyps
Copy link
Owner

seriyps commented Jan 31, 2023

Hi. Websocket a telegram app transport, not MTProto proxy transport. You can't create mtproto proxy like https://t.me/proxy?...websocket....

You can proxy websocket protocol with smth like HAProxy or Nginx, but you can't instruct Telegram app to use websocket transport...

@robin98
Copy link
Author

robin98 commented Feb 1, 2023

Hi. Websocket a telegram app transport, not MTProto proxy transport. You can't create mtproto proxy like https://t.me/proxy?...websocket....

You can proxy websocket protocol with smth like HAProxy or Nginx, but you can't instruct Telegram app to use websocket transport...

Thank you for your responding. Actually the main reason for me that I want to do this, is to using the CloudFlare's CDN Protection for my actual MTProto server.

As I know so far, you can only use the WS, gRPC and maybe QUIC transport models to communicate with your origin server (when it is proxied by CloudFlare), So based on my ideas, if the MTProto uses the TCP transport model it is not possible to use their protection; and the only available option is to share and use my real VPS IP so there is a high chance it'll be blocked by a few days or so.

Also I'm not familiar with HAProxy or Nginx and I have no idea if they can help me with my scenario.
What do you think about this? is there any solution?

@seriyps
Copy link
Owner

seriyps commented Feb 1, 2023

Telegram client can only use following protocols as proxy:

  1. socks5
  2. MTProto proxy, which has 3 variations: plain mtproto (32 char secret), random padding mtproto (dd - secret) and fake-tls which is random-padding wrapped into fake TLS frames to PRETEND that it is HTTPS traffic (ee - secret)

So it is only possible to tell Telegram client to use one of those protocols as proxy (unless you create your own version of Telegram app). It's not possible to tell it to use WebSocket.

WebSocket transport exists, but it is NOT proxy protocol. Mobile clients don't use it, it is used by WEB telegram clients like https://web.telegram.org/. The only way you can use WebSocket/CloudFlare is:

  1. create your own version of telegram app and make it use WebSocket
  2. install web version of telegram (eg https://github.com/Ajaxy/telegram-tt or https://github.com/morethanwords/tweb) to your server and use it through the browser

@robin98
Copy link
Author

robin98 commented Feb 1, 2023

It's a good idea if Telegram made this protocol (MTProto) and it's own APP compatible with websockets transport.
Here in Iran due to high censorship level, one of the our limited options to deploy a proxy server, is to use scripts and panels like x-ui (v2ray), in that way you can run your proxy based on various transports like tcp, kcp, ws, quic and gRPC. by using grpc or ws the user be able to tunnel the traffic through CDNs like CloudFlare.

Also thank you for mentioning MTProto security options. the dd - secret method is unstable here, specially on the mobile data, but the ee - secret seems fine so far. In the other hand, on DSL and Cable providers both methods are available.

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

No branches or pull requests

2 participants