mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-11-24 00:16:30 +03:00
Move CF-proxy websocket connection to a separate file
This commit is contained in:
+2
-1
@@ -13,7 +13,8 @@ from proxy.cf_h2 import (
|
||||
CfH2Pool, MAX_CHANNEL_REQUESTS, MAX_PACKET, _HttpChannel, _HttpLane,
|
||||
_ReplayPacket, _encode_reply, _read_packet, bridge_h2,
|
||||
)
|
||||
from proxy.raw_websocket import RawWebSocket, connect_cf_domains, reset_cf_timeouts
|
||||
from proxy.cf_websocket import connect_cf_domains, reset_cf_timeouts
|
||||
from proxy.raw_websocket import RawWebSocket
|
||||
from proxy.utils import PROTO_TAG_ABRIDGED, PROTO_TAG_INTERMEDIATE, PROTO_TAG_SECURE
|
||||
|
||||
class _IdentityCipher:
|
||||
|
||||
@@ -6,8 +6,9 @@ from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
from proxy import bridge, tg_ws_proxy
|
||||
from proxy.balancer import _Balancer
|
||||
from proxy.cf_websocket import reset_cf_timeouts
|
||||
from proxy.config import proxy_config
|
||||
from proxy.raw_websocket import RawWebSocket, reset_cf_timeouts
|
||||
from proxy.raw_websocket import RawWebSocket
|
||||
from proxy.utils import PROTO_TAG_INTERMEDIATE
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import asyncio
|
||||
import unittest
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
from proxy import raw_websocket
|
||||
from proxy import cf_websocket
|
||||
from proxy.raw_websocket import RawWebSocket, WsHandshakeError, _xor_mask
|
||||
|
||||
|
||||
@@ -314,11 +314,11 @@ class HandshakeCleanupTest(unittest.IsolatedAsyncioTestCase):
|
||||
|
||||
class CfDomainTimeoutTest(unittest.IsolatedAsyncioTestCase):
|
||||
def setUp(self):
|
||||
raw_websocket.reset_cf_timeouts()
|
||||
self.addCleanup(raw_websocket.reset_cf_timeouts)
|
||||
cf_websocket.reset_cf_timeouts()
|
||||
self.addCleanup(cf_websocket.reset_cf_timeouts)
|
||||
|
||||
async def connect(self, *hosts, secure=True):
|
||||
return await raw_websocket.connect_cf_domains(((h, h) for h in hosts), secure=secure, label='test')
|
||||
return await cf_websocket.connect_cf_domains(((h, h) for h in hosts), secure=secure, label='test')
|
||||
|
||||
async def test_clients_dial_in_parallel_and_http_responses_do_not_throttle(self):
|
||||
statuses = iter((101, 429, 101, 503, 429))
|
||||
@@ -389,7 +389,7 @@ class CfDomainTimeoutTest(unittest.IsolatedAsyncioTestCase):
|
||||
[True, True, False, False])
|
||||
|
||||
async def test_timeout_retry_skips_to_other_front_without_waiting(self):
|
||||
with patch.object(raw_websocket, 'CF_TIMEOUT_COOLDOWN', 0), \
|
||||
with patch.object(cf_websocket, 'CF_TIMEOUT_COOLDOWN', 0), \
|
||||
patch.object(RawWebSocket, 'connect', side_effect=asyncio.TimeoutError()):
|
||||
self.assertIsNone(await self.connect('a', secure=False))
|
||||
|
||||
@@ -419,7 +419,7 @@ class CfDomainTimeoutTest(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertEqual((await self.connect('a', secure=False))[1], 'a')
|
||||
|
||||
async def test_cancelling_timeout_retry_releases_it_for_next_client(self):
|
||||
with patch.object(raw_websocket, 'CF_TIMEOUT_COOLDOWN', 0), \
|
||||
with patch.object(cf_websocket, 'CF_TIMEOUT_COOLDOWN', 0), \
|
||||
patch.object(RawWebSocket, 'connect', side_effect=asyncio.TimeoutError()):
|
||||
await self.connect('a')
|
||||
started = asyncio.Event()
|
||||
|
||||
Reference in New Issue
Block a user