prefer not multicast port addresses
This commit is contained in:
parent
a8d38faa62
commit
55b9eac037
|
@ -40,6 +40,7 @@ class Peer:
|
||||||
|
|
||||||
self.addresses = set()
|
self.addresses = set()
|
||||||
self.addresses.add((address, port))
|
self.addresses.add((address, port))
|
||||||
|
self.main_address = (address, port)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def potential(self) -> bool:
|
def potential(self) -> bool:
|
||||||
|
@ -49,14 +50,6 @@ class Peer:
|
||||||
def potential(self, value: bool) -> None:
|
def potential(self, value: bool) -> None:
|
||||||
self.active = not value
|
self.active = not value
|
||||||
|
|
||||||
@property
|
|
||||||
def main_address(self) -> Tuple[str, int]:
|
|
||||||
"""
|
|
||||||
A client can have multiple addresses.
|
|
||||||
We contact it only on one of them.
|
|
||||||
"""
|
|
||||||
return list(self.addresses)[0]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def banned(self) -> bool:
|
def banned(self) -> bool:
|
||||||
"""
|
"""
|
||||||
|
@ -80,6 +73,10 @@ class Peer:
|
||||||
self.last_long_hello_time = max(self.last_hello_time, other.last_long_hello_time)
|
self.last_long_hello_time = max(self.last_hello_time, other.last_long_hello_time)
|
||||||
self.addresses.update(self.addresses)
|
self.addresses.update(self.addresses)
|
||||||
self.addresses.update(other.addresses)
|
self.addresses.update(other.addresses)
|
||||||
|
if self.main_address[1] == 1212: #always prefer the non-multicast address
|
||||||
|
self.main_address = other.main_address
|
||||||
|
elif other.main_address[1] == 1212:
|
||||||
|
other.main_address = self.main_address
|
||||||
self.id = self.id if self.id > 0 else other.id
|
self.id = self.id if self.id > 0 else other.id
|
||||||
self.marked_as_banned = other.marked_as_banned
|
self.marked_as_banned = other.marked_as_banned
|
||||||
return self
|
return self
|
||||||
|
|
Loading…
Reference in New Issue