diff --git a/theonionbox/stamp.py b/theonionbox/stamp.py index 05e0247..b85b42b 100644 --- a/theonionbox/stamp.py +++ b/theonionbox/stamp.py @@ -1,4 +1,4 @@ __title__ = 'The Onion Box' __description__ = 'Dashboard to monitor Tor node operations.' __version__ = '19.2b6' -__stamp__ = '20191129|205240' \ No newline at end of file +__stamp__ = '20191201|213412' \ No newline at end of file diff --git a/theonionbox/tob/box.py b/theonionbox/tob/box.py index 225c2b8..a939d38 100644 --- a/theonionbox/tob/box.py +++ b/theonionbox/tob/box.py @@ -498,8 +498,6 @@ def _run(self, icon=None): try: self.server.run(self.box) except KeyboardInterrupt: - # SIGINT consumed before ... - # ... so this never emits!! self.log.notice("Received SIGINT signal.") except Exception as exc: self.log.error(exc) diff --git a/theonionbox/tob/persistor.py b/theonionbox/tob/persistor.py index 99268a3..bd8a3d9 100644 --- a/theonionbox/tob/persistor.py +++ b/theonionbox/tob/persistor.py @@ -66,6 +66,8 @@ def __init__(self, storage: Storage, fingerprint: str): self.path = None self.fp = None + self.fpid = None + log = logging.getLogger('theonionbox') if len(fingerprint) == 0: @@ -105,7 +107,8 @@ def __init__(self, storage: Storage, fingerprint: str): if fpid is not None: self.path = path - self.fp = fpid + self.fp = fingerprint + self.fpid = fpid conn.close() @@ -129,6 +132,9 @@ def open_connection(self, path: Optional[str] = None) -> Optional[Connection]: def persist(self, interval: str, timestamp: float, read: Optional[int] = 0, write: Optional[int] = 0, connection: Optional[Connection] = None) -> bool: + if self.fpid is None: + return False + if connection is None: connection = self.open_connection() if connection is None: @@ -136,10 +142,10 @@ def persist(self, interval: str, timestamp: float, try: connection.execute("INSERT INTO bandwidth(fp, interval, timestamp, read, write) VALUES(?, ?, ?, ?, ?)", - (self.fp, interval, timestamp, read, write)) + (self.fpid, interval, timestamp, read, write)) except Exception as e: log = logging.getLogger('theonionbox') - log.warning(f'Failed to open persist bandwidth data for fingerprint {self.fp}: {e}') + log.warning(f'Failed to open persist bandwidth data for fingerprint {self.fp[:6]}: {e}') return False return True @@ -168,7 +174,7 @@ def get(self, interval: str, js_timestamp: Optional[int] = int(time()*1000), lim try: cur.execute(sql, {'jsts': js_timestamp, - 'fp': self.fp, + 'fp': self.fpid, 'interval': interval, 'limit': limit, 'offset': offset}