mirror of https://github.com/oxen-io/lokinet
update lokinetmon
* add --introset-filter option to filter results in introset inspection mode by regex
This commit is contained in:
parent
75451d7124
commit
32a94c73e2
|
@ -6,6 +6,7 @@ import sys
|
|||
import time
|
||||
import platform
|
||||
import os
|
||||
import re
|
||||
from argparse import ArgumentParser as AP
|
||||
|
||||
is_windows = lambda : platform.system().lower() == 'windows'
|
||||
|
@ -40,12 +41,13 @@ except ImportError:
|
|||
print("for other linuxs do:")
|
||||
print("\tpip3 install --user geoip")
|
||||
print("for other linuxs you are responsible for obtaining your owen geoip databases, glhf")
|
||||
time.sleep(1)
|
||||
else:
|
||||
print("install it with:")
|
||||
print("\tpip3 install --user geoip")
|
||||
print("")
|
||||
print("press enter to continue without geoip")
|
||||
sys.stdin.read(1)
|
||||
print()
|
||||
print("press enter to continue without geoip")
|
||||
sys.stdin.read(1)
|
||||
else:
|
||||
try:
|
||||
geoip_env_var = 'GEOIP_DB_FILE'
|
||||
|
@ -86,6 +88,7 @@ def ip_to_flag(ip):
|
|||
class Monitor:
|
||||
|
||||
_sample_size = 12
|
||||
introset_filter = None
|
||||
|
||||
def __init__(self, url, introsetMode=False):
|
||||
self.txrate = 0
|
||||
|
@ -407,12 +410,14 @@ class Monitor:
|
|||
"""
|
||||
y_pos += 1
|
||||
self.win.move(y_pos, 1)
|
||||
self.win.addstr("localhost.loki")
|
||||
y_pos = self._display_our_introset(y_pos, service)
|
||||
y_pos += 1
|
||||
if self.introset_filter("localhost.loki"):
|
||||
self.win.addstr("localhost.loki")
|
||||
y_pos = self._display_our_introset(y_pos, service)
|
||||
y_pos += 1
|
||||
remotes = service['remoteSessions'] or []
|
||||
for session in remotes:
|
||||
y_pos = self._display_session_introset(y_pos, session)
|
||||
if self.introset_filter(session['remoteIdentity']):
|
||||
y_pos = self._display_session_introset(y_pos, session)
|
||||
|
||||
def _display_intro(self, y_pos, intro, label, paths):
|
||||
y_pos += 1
|
||||
|
@ -544,6 +549,7 @@ def main():
|
|||
|
||||
ap.add_argument("--introset", action='store_const', const=True, default=False, help="run in introset inspection mode")
|
||||
ap.add_argument("--url", default='tcp://127.0.0.1:1190', type=str, help='url to lokinet rpc')
|
||||
ap.add_argument('--introset-filter', default=None, type=str, help="while in introset inspection mode filter results by regex")
|
||||
|
||||
args = ap.parse_args()
|
||||
|
||||
|
@ -551,6 +557,9 @@ def main():
|
|||
args.url,
|
||||
args.introset
|
||||
)
|
||||
mon.introset_filter = lambda x : True
|
||||
if args.introset_filter:
|
||||
mon.introset_filter = lambda x : re.match(args.introset_filter, x) is not None
|
||||
mon.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue