Skip to content

Commit

Permalink
Remove TorV2 checks for TorV3 addr verification
Browse files Browse the repository at this point in the history
Fix bool
  • Loading branch information
Liquid369 committed Mar 26, 2024
1 parent 9736c7a commit 76fb659
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,13 @@ def ipmap(ip, port):
try:
ipv6map = ''

if len(ip) > 6 and ip.endswith('.onion'):
pchOnionCat = bytearray([0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43])
if len(ip) == 62 and ip.endswith('.onion'):
vchOnionPrefix = bytes([0x04, 32])
vchAddr = base64.b32decode(ip[0:-6], True)
if len(vchAddr) != 16 - len(pchOnionCat):
raise Exception('Invalid onion %s' % str(ip))
return pchOnionCat.hex() + vchAddr.hex() + int(port).to_bytes(2, byteorder='big').hex()
vchAddrBytes = vchOnionPrefix + vchAddr[:32]
if len(vchAddr) != 35 and vchAddr[-1] != b'\x03':
raise Exception('Invalid TorV3 address %s' % str(ip))
return vchAddrBytes.hex() + int(port).to_bytes(2, byteorder='big').hex()

ipAddr = ip_address(ip)

Expand Down

0 comments on commit 76fb659

Please sign in to comment.