mirror of
https://github.com/markqvist/Reticulum.git
synced 2025-05-02 14:46:05 -04:00
Added signal handler and interface detachment oon exit.
This commit is contained in:
parent
81cdb0b7e6
commit
3d4ac0126b
5 changed files with 33 additions and 3 deletions
|
@ -2,6 +2,7 @@ from .Interfaces import *
|
|||
import configparser
|
||||
from .vendor.configobj import ConfigObj
|
||||
import RNS
|
||||
import signal
|
||||
import atexit
|
||||
import struct
|
||||
import array
|
||||
|
@ -78,6 +79,12 @@ class Reticulum:
|
|||
RNS.Transport.exit_handler()
|
||||
RNS.Identity.exit_handler()
|
||||
|
||||
@staticmethod
|
||||
def sigint_handler(signal, frame):
|
||||
RNS.Transport.detach_interfaces()
|
||||
RNS.exit()
|
||||
|
||||
|
||||
def __init__(self,configdir=None, loglevel=None):
|
||||
"""
|
||||
Initialises and starts a Reticulum instance. This must be
|
||||
|
@ -109,7 +116,7 @@ class Reticulum:
|
|||
self.requested_loglevel = RNS.LOG_EXTREME
|
||||
if self.requested_loglevel < RNS.LOG_CRITICAL:
|
||||
self.requested_loglevel = RNS.LOG_CRITICAL
|
||||
|
||||
|
||||
RNS.loglevel = self.requested_loglevel
|
||||
|
||||
self.is_shared_instance = False
|
||||
|
@ -147,6 +154,7 @@ class Reticulum:
|
|||
RNS.Transport.start(self)
|
||||
|
||||
atexit.register(Reticulum.exit_handler)
|
||||
signal.signal(signal.SIGINT, Reticulum.sigint_handler)
|
||||
|
||||
def __start_local_interface(self):
|
||||
if self.share_instance:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue