From 99be6bbf732621ed547dba7eb3d560d51ca5b4ad Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Tue, 30 Aug 2022 15:27:54 +0300 Subject: [PATCH] Detect onion services in protocol in the same way as everythere --- src/protocol.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocol.py b/src/protocol.py index 4cab2dd6..f402526f 100644 --- a/src/protocol.py +++ b/src/protocol.py @@ -101,7 +101,7 @@ MAX_VALID_STREAM = 2**63 - 1 def encodeHost(host): """Encode a given host to be used in low-level socket operations""" - if host.find('.onion') > -1: + if host.endswith('.onion'): return b'\xfd\x87\xd8\x7e\xeb\x43' + base64.b32decode( host.split(".")[0], True) elif host.find(':') == -1: @@ -112,7 +112,7 @@ def encodeHost(host): def networkType(host): """Determine if a host is IPv4, IPv6 or an onion address""" - if host.find('.onion') > -1: + if host.endswith('.onion'): return 'onion' elif host.find(':') == -1: return 'IPv4'