Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
Restrict port to IPv4 addresses for guards (#77)
Browse files Browse the repository at this point in the history
Restrict port to IPv4 addresses for guards
  • Loading branch information
laurent-girod authored Oct 21, 2021
1 parent b280e5d commit 27d616a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tools/gen_fresh_dirinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,16 @@ def setup_logger() -> logging.Logger:

def is_orport_used(router: RouterStatusEntryMicroV3, port: int) -> bool:
"""
Check if a port is used as an OR port by a router.
Check if a port is used as an OR port by a router on its IPv4 address.
:param router: router entry in the consensus
:param port: port we want to check
:return: True if the port is used, False otherwise
"""
for _, port_used, _ in router.or_addresses:
if port_used == port:
return True
return False
# This field correspond to the OR port specified in the "router" line of a router's description.
# Per Tor's spec it is always used for an IPv4 address.
# (Tor directory protocol, version 3, 2.1.1.)
return router.or_port == port


def is_address_port_changed(
Expand Down

0 comments on commit 27d616a

Please sign in to comment.