mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-26 15:30:18 +00:00
Improved I2P recovery time on unresponsive tunnels
This commit is contained in:
parent
f22e5cc200
commit
f22504d080
@ -672,6 +672,9 @@ class I2PInterfacePeer(Interface):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
if (time.time()-self.last_read > I2PInterfacePeer.I2P_PROBE_AFTER*2):
|
if (time.time()-self.last_read > I2PInterfacePeer.I2P_PROBE_AFTER*2):
|
||||||
|
if self.i2p_tunnel_state != I2PInterfacePeer.TUNNEL_STATE_STALE:
|
||||||
|
RNS.log("I2P tunnel became unresponsive", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
self.i2p_tunnel_state = I2PInterfacePeer.TUNNEL_STATE_STALE
|
self.i2p_tunnel_state = I2PInterfacePeer.TUNNEL_STATE_STALE
|
||||||
else:
|
else:
|
||||||
self.i2p_tunnel_state = I2PInterfacePeer.TUNNEL_STATE_ACTIVE
|
self.i2p_tunnel_state = I2PInterfacePeer.TUNNEL_STATE_ACTIVE
|
||||||
@ -683,21 +686,24 @@ class I2PInterfacePeer(Interface):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("An error ocurred while sending I2P keepalive. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("An error ocurred while sending I2P keepalive. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
self.shutdown_socket(self.socket)
|
self.shutdown_socket(self.socket)
|
||||||
|
should_run = False
|
||||||
|
|
||||||
# if (time.time()-self.last_read > I2PInterfacePeer.I2P_READ_TIMEOUT):
|
if (time.time()-self.last_read > I2PInterfacePeer.I2P_READ_TIMEOUT):
|
||||||
# RNS.log("I2P socket seems dead, restarting...", RNS.LOG_WARNING)
|
RNS.log("I2P socket is unresponsive, restarting...", RNS.LOG_WARNING)
|
||||||
# if self.socket != None:
|
if self.socket != None:
|
||||||
# try:
|
try:
|
||||||
# self.socket.shutdown(socket.SHUT_RDWR)
|
self.socket.shutdown(socket.SHUT_RDWR)
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# RNS.log("Error while shutting down socket for "+str(self)+": "+str(e))
|
RNS.log("Error while shutting down socket for "+str(self)+": "+str(e))
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# self.socket.close()
|
self.socket.close()
|
||||||
# except Exception as e:
|
except Exception as e:
|
||||||
# RNS.log("Error while closing socket for "+str(self)+": "+str(e))
|
RNS.log("Error while closing socket for "+str(self)+": "+str(e))
|
||||||
|
|
||||||
# should_run = False
|
should_run = False
|
||||||
|
|
||||||
|
self.wd_reset = False
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
self.wd_reset = False
|
self.wd_reset = False
|
||||||
@ -770,8 +776,12 @@ class I2PInterfacePeer(Interface):
|
|||||||
escape = False
|
escape = False
|
||||||
data_buffer = data_buffer+bytes([byte])
|
data_buffer = data_buffer+bytes([byte])
|
||||||
else:
|
else:
|
||||||
self.wd_reset = True
|
|
||||||
self.online = False
|
self.online = False
|
||||||
|
|
||||||
|
self.wd_reset = True
|
||||||
|
time.sleep(2)
|
||||||
|
self.wd_reset = False
|
||||||
|
|
||||||
if self.initiator and not self.detached:
|
if self.initiator and not self.detached:
|
||||||
RNS.log("Socket for "+str(self)+" was closed, attempting to reconnect...", RNS.LOG_WARNING)
|
RNS.log("Socket for "+str(self)+" was closed, attempting to reconnect...", RNS.LOG_WARNING)
|
||||||
self.reconnect()
|
self.reconnect()
|
||||||
|
Loading…
Reference in New Issue
Block a user