1 and 65536 arent valid ports

This commit is contained in:
Victor Shyba 2019-09-30 17:08:13 -03:00
parent 2e2c751d75
commit 18d80f4ed5

View file

@ -154,9 +154,9 @@ class KademliaPeer:
if self._node_id is not None: if self._node_id is not None:
if not len(self._node_id) == constants.hash_length: if not len(self._node_id) == constants.hash_length:
raise ValueError("invalid node_id: {}".format(hexlify(self._node_id).decode())) raise ValueError("invalid node_id: {}".format(hexlify(self._node_id).decode()))
if self.udp_port is not None and not 0 <= self.udp_port <= 65536: if self.udp_port is not None and not 1 <= self.udp_port <= 65535:
raise ValueError("invalid udp port") raise ValueError("invalid udp port")
if self.tcp_port is not None and not 0 <= self.tcp_port <= 65536: if self.tcp_port is not None and not 1 <= self.tcp_port <= 65535:
raise ValueError("invalid tcp port") raise ValueError("invalid tcp port")
if not is_valid_ipv4(self.address): if not is_valid_ipv4(self.address):
raise ValueError("invalid ip address") raise ValueError("invalid ip address")