MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / bm_command_addr

Method bm_command_addr

src/network/udp.py:83–105  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

81 return BMProto.bm_command_object(self)
82
83 def bm_command_addr(self):
84# BMProto.bm_command_object(self)
85 addresses = self._decode_addr()
86 # only allow peer discovery from private IPs in order to avoid attacks from random IPs on the internet
87 if not self.local:
88 return True
89 remoteport = False
90 for i in addresses:
91 seenTime, stream, services, ip, port = i
92 decodedIP = protocol.checkIPAddress(str(ip))
93 if stream not in state.streamsInWhichIAmParticipating:
94 continue
95 if seenTime < time.time() - BMProto.maxTimeOffset or seenTime > time.time() + BMProto.maxTimeOffset:
96 continue
97 if decodedIP is False:
98 # if the address isn't local, interpret it as the hosts' own announcement
99 remoteport = port
100 if remoteport is False:
101 return True
102 logger.debug("received peer discovery from %s:%i (port %i):", self.destination.host, self.destination.port, remoteport)
103 if self.local:
104 state.discoveredPeers[state.Peer(self.destination.host, remoteport)] = time.time()
105 return True
106
107 def bm_command_portcheck(self):
108 return True

Callers

nothing calls this directly

Calls 1

_decode_addrMethod · 0.80

Tested by

no test coverage detected