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

IPv8: OSError: illegal IP address string passed to inet_aton #7903

Open
Mario-o-o-o opened this issue Feb 15, 2024 · 5 comments
Open

IPv8: OSError: illegal IP address string passed to inet_aton #7903

Mario-o-o-o opened this issue Feb 15, 2024 · 5 comments

Comments

@Mario-o-o-o
Copy link

Mario-o-o-o commented Feb 15, 2024

Hello here :-)

Here are logs:

curl --silent -X GET http://127.0.0.1:20100/downloads
{"error": {"handled": false, "code": "TypeError", "message": "Traceback (most recent call last):\n  File \"/home/user/tribler/src/tribler/core/components/restapi/rest/rest_manager.py\", line 53, in error_middleware\n    response = await handler(request)\n  File \"/home/user/.local/lib/python3.8/site-packages/aiohttp/web_middlewares.py\", line 114, in impl\n    return await handler(request)\n  File \"/home/user/tribler/src/tribler/core/components/libtorrent/restapi/downloads_endpoint.py\", line 378, in get_downloads\n    return RESTResponse({\"downloads\": downloads_json, \"checkpoints\": checkpoints})\n  File \"/home/user/tribler/src/tribler/core/components/restapi/rest/rest_endpoint.py\", line 66, in __init__\n    body = json.dumps(body)\n  File \"/usr/lib/python3.8/json/__init__.py\", line 231, in dumps\n    return _default_encoder.encode(obj)\n  File \"/usr/lib/python3.8/json/encoder.py\", line 199, in encode\n    chunks = self.iterencode(o, _one_shot=True)\n  File \"/usr/lib/python3.8/json/encoder.py\", line 257, in iterencode\n    return _iterencode(o, 0)\n  File \"/usr/lib/python3.8/json/encoder.py\", line 179, in default\n    raise TypeError(f'Object of type {o.__class__.__name__} '\nTypeError: Object of type bytes is not JSON serializable\n"}}

Stacktrace

Traceback (most recent call last): 
  File '/home/user/tribler/src/tribler/core/components/restapi/rest/rest_manager.py', line 53, in error_middleware 
    response = await handler(request) 
  File '/home/user/.local/lib/python3.8/site-packages/aiohttp/web_middlewares.py', line 114, in impl 
    return await handler(request) 
  File '/home/user/tribler/src/tribler/core/components/libtorrent/restapi/downloads_endpoint.py', line 378, in get_downloads 
    return RESTResponse({'downloads': downloads_json, 'checkpoints': checkpoints}) 
  File '/home/user/tribler/src/tribler/core/components/restapi/rest/rest_endpoint.py', line 66, in __init__ 
    body = json.dumps(body) 
  File '/usr/lib/python3.8/json/__init__.py', line 231, in dumps 
    return _default_encoder.encode(obj) 
  File '/usr/lib/python3.8/json/encoder.py', line 199, in encode 
    chunks = self.iterencode(o, _one_shot=True) 
  File '/usr/lib/python3.8/json/encoder.py', line 257, in iterencode 
    return _iterencode(o, 0) 
  File '/usr/lib/python3.8/json/encoder.py', line 179, in default 
    raise TypeError(f'Object of type {o.__class__.__name__} ' 
TypeError: Object of type bytes is not JSON serializable

Other logs

less /..../.tribler/tribler-core-error.log
[tribler-core PID:15] 2024-02-15 13:11:14,096 - ERROR <community:767> TriblerTunnelCommunity.on_packet_from_circuit(): Exception occurred while handling packet!
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/ipv8/messaging/serialization.py", line 468, in pack_serializable
    packed += self._packers[packable[0]].pack(*packable[1:])
  File "/home/user/tribler/src/tribler/core/components/socks_servers/socks5/conversion.py", line 73, in pack
    return struct.pack('>B4sH', ADDRESS_TYPE_IPV4, socket.inet_aton(data[0]), data[1])
OSError: illegal IP address string passed to inet_aton

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/ipv8/messaging/anonymization/community.py", line 761, in on_packet_from_circuit
    result = handler(source_address, data, circuit_id)
  File "/home/user/.local/lib/python3.8/site-packages/ipv8/messaging/anonymization/community.py", line 970, in on_data
    self.on_raw_data(circuit, origin, data)
  File "/home/user/tribler/src/tribler/core/components/tunnel/community/tunnel_community.py", line 242, in on_raw_data
    self.dispatcher.on_incoming_from_tunnel(self, circuit, origin, data)
  File "/home/user/tribler/src/tribler/core/components/tunnel/community/dispatcher.py", line 60, in on_incoming_from_tunnel
    packet = socks5_serializer.pack_serializable(UdpPacket(0, 0, origin, data))
  File "/home/user/.local/lib/python3.8/site-packages/ipv8/messaging/serialization.py", line 471, in pack_serializable
    raise PackError(msg) from e
ipv8.messaging.serialization.PackError: Could not pack item: ('socks5_address', UDPv6Address(ip='2a0f:e586:f:f::81', port=6969))
OSError: illegal IP address string passed to inet_aton
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/ipv8/messaging/serialization.py", line 468, in pack_serializable
    packed += self._packers[packable[0]].pack(*packable[1:])
  File "/home/user/tribler/src/tribler/core/components/socks_servers/socks5/conversion.py", line 73, in pack
    return struct.pack('>B4sH', ADDRESS_TYPE_IPV4, socket.inet_aton(data[0]), data[1])
OSError: illegal IP address string passed to inet_aton

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/ipv8/messaging/anonymization/community.py", line 761, in on_packet_from_circuit
    result = handler(source_address, data, circuit_id)
  File "/home/user/.local/lib/python3.8/site-packages/ipv8/messaging/anonymization/community.py", line 970, in on_data
    self.on_raw_data(circuit, origin, data)
  File "/home/user/tribler/src/tribler/core/components/tunnel/community/tunnel_community.py", line 242, in on_raw_data
    self.dispatcher.on_incoming_from_tunnel(self, circuit, origin, data)
  File "/home/user/tribler/src/tribler/core/components/tunnel/community/dispatcher.py", line 60, in on_incoming_from_tunnel
    packet = socks5_serializer.pack_serializable(UdpPacket(0, 0, origin, data))
  File "/home/user/.local/lib/python3.8/site-packages/ipv8/messaging/serialization.py", line 471, in pack_serializable
    raise PackError(msg) from e
ipv8.messaging.serialization.PackError: Could not pack item: ('socks5_address', UDPv6Address(ip='2a0f:e586:f:f::81', port=6969))
OSError: illegal IP address string passed to inet_aton

No idea how this happened, but tribler seems to have crashed due to a non-compliant IP6.

Desktop (please complete the following information):

  • Linux 6.1.0-0.deb11.13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1~bpo11+1 (2023-10-08) x86_64 GNU/Linux
  • Docker with triblercore/triblercore:latest
  • I don't know how to display the tribler version on the command line.

Thanx for your help!

@Mario-o-o-o Mario-o-o-o changed the title ERROR: ERROR: illegal IP address string passed to inet_aton Feb 15, 2024
@xoriole xoriole changed the title ERROR: illegal IP address string passed to inet_aton DownloadsEndpoint: TypeError: Object of type bytes is not JSON serializable Feb 16, 2024
@xoriole
Copy link
Contributor

xoriole commented Feb 16, 2024

@Mario-o-o-o Thank you for your issue report. I have updated your issue description a bit to make it more readable for us. It is possible that we might already have a fix for the issue and the docker image might not be the latest. Otherwise, we might need some additional info from you, for which we'll comment here to notify you later.

@xoriole xoriole added this to the 7.14.0 milestone Feb 16, 2024
@Tribler Tribler deleted a comment from sentry-for-tribler bot Mar 26, 2024
Copy link

Sentry issue: TRIBLER-1K4

@drew2a drew2a changed the title DownloadsEndpoint: TypeError: Object of type bytes is not JSON serializable IPv8: OSError: illegal IP address string passed to inet_aton Mar 26, 2024
@drew2a
Copy link
Collaborator

drew2a commented Mar 26, 2024

I've updated the description of this issue in light of the linked Sentry event and the provided logs.

@qstokkink
Copy link
Contributor

Why exactly is IPv8 being mentioned? The only thing I see in both OP and Sentry - that is even related to IPv8 - is that the log message is generated in the general try .. except of IPv8.

  • The issue of OP is a bytes value being passed to json.dumps in the Tribler download endpoint.
  • The issue in Sentry is a ConnectionRefusedError to the Tribler REST interface.

The cause of the log message itself is the lack of IPv6 support in the Tribler socks server.

Copy link

This issue has not seen activity for 60 days. It is now marked as stale. Please provide additional information or this issue may be closed in the future. We value your contribution and would love to hear more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants