mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-26 23:40:18 +00:00
Added detach handler to TCP Server Interface
This commit is contained in:
parent
6db742ade7
commit
be02586133
@ -417,6 +417,7 @@ class TCPServerInterface(Interface):
|
|||||||
self.IN = True
|
self.IN = True
|
||||||
self.OUT = False
|
self.OUT = False
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.detached = False
|
||||||
|
|
||||||
self.i2p_tunneled = i2p_tunneled
|
self.i2p_tunneled = i2p_tunneled
|
||||||
self.mode = RNS.Interfaces.Interface.Interface.MODE_FULL
|
self.mode = RNS.Interfaces.Interface.Interface.MODE_FULL
|
||||||
@ -476,6 +477,21 @@ class TCPServerInterface(Interface):
|
|||||||
def processOutgoing(self, data):
|
def processOutgoing(self, data):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def detach(self):
|
||||||
|
if self.server != None:
|
||||||
|
if hasattr(self.server, "shutdown"):
|
||||||
|
if callable(self.server.shutdown):
|
||||||
|
try:
|
||||||
|
RNS.log("Detaching "+str(self), RNS.LOG_DEBUG)
|
||||||
|
self.server.shutdown()
|
||||||
|
self.detached = True
|
||||||
|
self.server = None
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("Error while shutting down server for "+str(self)+": "+str(e))
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "TCPServerInterface["+self.name+"/"+self.bind_ip+":"+str(self.bind_port)+"]"
|
return "TCPServerInterface["+self.name+"/"+self.bind_ip+":"+str(self.bind_port)+"]"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user