mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-05-22 23:41:44 +03:00
small fixes
This commit is contained in:
@@ -167,10 +167,11 @@ async def _cfproxy_fallback(reader, writer, relay_init, label,
|
|||||||
ws = None
|
ws = None
|
||||||
chosen_domain = None
|
chosen_domain = None
|
||||||
|
|
||||||
|
log.info("[%s] DC%d%s -> trying CF proxy",
|
||||||
|
label, dc, media_tag)
|
||||||
|
|
||||||
for base_domain in ([active] + others):
|
for base_domain in ([active] + others):
|
||||||
domain = f'kws{dc}.{base_domain}'
|
domain = f'kws{dc}.{base_domain}'
|
||||||
log.info("[%s] DC%d%s -> CF proxy wss",
|
|
||||||
label, dc, media_tag)
|
|
||||||
try:
|
try:
|
||||||
ws = await RawWebSocket.connect(domain, domain, timeout=10.0)
|
ws = await RawWebSocket.connect(domain, domain, timeout=10.0)
|
||||||
chosen_domain = base_domain
|
chosen_domain = base_domain
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ class RawWebSocket:
|
|||||||
set_sock_opts(writer.transport, proxy_config.buffer_size)
|
set_sock_opts(writer.transport, proxy_config.buffer_size)
|
||||||
|
|
||||||
ws_key = base64.b64encode(os.urandom(16)).decode()
|
ws_key = base64.b64encode(os.urandom(16)).decode()
|
||||||
|
|
||||||
req = (
|
req = (
|
||||||
f'GET /apiws HTTP/1.1\r\n'
|
f'GET /apiws HTTP/1.1\r\n'
|
||||||
f'Host: {domain}\r\n'
|
f'Host: {domain}\r\n'
|
||||||
@@ -95,7 +96,6 @@ class RawWebSocket:
|
|||||||
f'Sec-WebSocket-Key: {ws_key}\r\n'
|
f'Sec-WebSocket-Key: {ws_key}\r\n'
|
||||||
f'Sec-WebSocket-Version: 13\r\n'
|
f'Sec-WebSocket-Version: 13\r\n'
|
||||||
f'Sec-WebSocket-Protocol: binary\r\n'
|
f'Sec-WebSocket-Protocol: binary\r\n'
|
||||||
f'Origin: https://web.telegram.org\r\n'
|
|
||||||
f'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
|
f'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
|
||||||
f'AppleWebKit/537.36 (KHTML, like Gecko) '
|
f'AppleWebKit/537.36 (KHTML, like Gecko) '
|
||||||
f'Chrome/131.0.0.0 Safari/537.36\r\n'
|
f'Chrome/131.0.0.0 Safari/537.36\r\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user