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

Fix network name is no longer available error on 7.13 #7912

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,4 @@ def close(self, reason='unspecified'):

if self.transport:
self.transport.close()
self.transport = None
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_invalid_version(connection):
Test passing an invalid version to the socks5 server
"""
connection.data_received(unhexlify('040100'))
assert not connection.transport.connected
assert not connection.transport


def test_method_request(connection):
Expand Down
8 changes: 6 additions & 2 deletions src/tribler/core/components/tunnel/community/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ async def on_socks5_tcp_data(self, tcp_connection, destination, request):
self._logger.info('Failed to get HTTP response using tunnels: %s', e)
return

transport = tcp_connection.transport
if not transport:
return

if response:
tcp_connection.transport.write(response)
tcp_connection.transport.close()
transport.write(response)
transport.close()

def select_circuit(self, connection, request):
if request.destination[1] == CIRCUIT_ID_PORT:
Expand Down
8 changes: 8 additions & 0 deletions src/tribler/core/components/tunnel/tests/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ async def test_on_socks_in_tcp(dispatcher):
tcp_connection.transport.write.assert_called_once_with(b'test')


async def test_on_socks5_tcp_data_with_transport_none(dispatcher):
tcp_connection = Mock(transport=None)
dispatcher.set_socks_servers([tcp_connection.socksserver])

dispatcher.tunnels.perform_http_request = Mock(return_value=succeed(b'test'))
await dispatcher.on_socks5_tcp_data(tcp_connection, ("0.0.0.0", 1024), b'')


def test_circuit_dead(dispatcher, mock_circuit):
"""
Test whether the correct peers are removed when a circuit breaks
Expand Down
Loading