Merge branch 'memory' into testing

This commit is contained in:
Lee Miller 2025-02-18 03:17:04 +02:00
commit b83262fe66
Signed by: lee.miller
GPG Key ID: 4F97A5EA88F4AB63

View File

@ -15,8 +15,6 @@ class I2PListener(I2PThread):
self.version_reply = []
self.new_socket()
def new_socket(self):
self.s = socket.create_connection((self.host, self.port))
self._send(b'HELLO VERSION MIN=3.0 MAX=3.3\n')
@ -31,25 +29,31 @@ class I2PListener(I2PThread):
def run(self):
while not self.state.shutting_down:
self.new_socket()
duplicate = False
try:
destination = self._receive_line().split()[0]
logging.info(
'Incoming I2P connection from: %s', destination.decode())
hosts = set()
for c in self.state.connections.copy():
hosts.add(c.host)
for d in self.state.i2p_dialers.copy():
hosts.add(d.destination)
if destination in hosts:
logging.debug('Rejecting duplicate I2P connection.')
self.s.close()
else:
c = self.state.connection(destination, 'i2p', self.s, True)
c.start()
self.state.connections.add(c)
c = None
self.new_socket()
except socket.timeout:
pass
continue
for c in self.state.connections.copy():
if c.host == destination:
duplicate = True
break
else:
for d in self.state.i2p_dialers.copy():
if d.destination == destination:
duplicate = True
break
if duplicate:
logging.info('Rejecting duplicate I2P connection.')
self.s.close()
else:
c = self.state.connection(destination, 'i2p', self.s, True)
c.start()
self.state.connections.add(c)
c = None
logging.debug('Shutting down I2P Listener')