mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-12-25 23:49:28 -05:00
Added verbosity level to utilities
This commit is contained in:
parent
9c1ac46989
commit
c71660a9c3
@ -104,6 +104,13 @@ class Reticulum:
|
||||
self.share_instance = True
|
||||
|
||||
self.requested_loglevel = loglevel
|
||||
if self.requested_loglevel != None:
|
||||
if self.requested_loglevel > RNS.LOG_EXTREME:
|
||||
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
|
||||
self.is_connected_to_shared_instance = False
|
||||
|
@ -8,7 +8,7 @@ import argparse
|
||||
from RNS._version import __version__
|
||||
|
||||
|
||||
def program_setup(configdir, destination_hexhash):
|
||||
def program_setup(configdir, destination_hexhash, verbosity):
|
||||
try:
|
||||
dest_len = (RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2
|
||||
if len(destination_hexhash) != dest_len:
|
||||
@ -21,8 +21,7 @@ def program_setup(configdir, destination_hexhash):
|
||||
print(str(e))
|
||||
exit()
|
||||
|
||||
|
||||
reticulum = RNS.Reticulum(configdir = configdir)
|
||||
reticulum = RNS.Reticulum(configdir = configdir, loglevel = 3+verbosity)
|
||||
|
||||
if not RNS.Transport.has_path(destination_hash):
|
||||
RNS.Transport.request_path(destination_hash)
|
||||
@ -37,11 +36,16 @@ def program_setup(configdir, destination_hexhash):
|
||||
sys.stdout.flush()
|
||||
i = (i+1)%len(syms)
|
||||
|
||||
hops = str(RNS.Transport.hops_to(destination_hash))
|
||||
hops = RNS.Transport.hops_to(destination_hash)
|
||||
next_hop = RNS.prettyhexrep(RNS.Transport.next_hop(destination_hash))
|
||||
next_hop_interface = str(RNS.Transport.next_hop_interface(destination_hash))
|
||||
|
||||
print("\rPath found, destination "+RNS.prettyhexrep(destination_hash)+" is "+hops+" hops away via "+next_hop+" on "+next_hop_interface)
|
||||
if hops > 1:
|
||||
ms = "s"
|
||||
else:
|
||||
ms = ""
|
||||
|
||||
print("\rPath found, destination "+RNS.prettyhexrep(destination_hash)+" is "+str(hops)+" hop"+ms+" away via "+next_hop+" on "+next_hop_interface)
|
||||
|
||||
|
||||
def main():
|
||||
@ -69,6 +73,8 @@ def main():
|
||||
type=str
|
||||
)
|
||||
|
||||
parser.add_argument('-v', '--verbose', action='count', default=0)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.config:
|
||||
@ -81,7 +87,7 @@ def main():
|
||||
parser.print_help()
|
||||
print("")
|
||||
else:
|
||||
program_setup(configdir = configarg, destination_hexhash = args.destination)
|
||||
program_setup(configdir = configarg, destination_hexhash = args.destination, verbosity = args.verbose)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("")
|
||||
|
@ -10,7 +10,7 @@ from RNS._version import __version__
|
||||
|
||||
DEFAULT_PROBE_SIZE = 16
|
||||
|
||||
def program_setup(configdir, destination_hexhash, size=DEFAULT_PROBE_SIZE, full_name = None):
|
||||
def program_setup(configdir, destination_hexhash, size=DEFAULT_PROBE_SIZE, full_name = None, verbosity = 0):
|
||||
if full_name == None:
|
||||
print("The full destination name including application name aspects must be specified for the destination")
|
||||
exit()
|
||||
@ -35,7 +35,7 @@ def program_setup(configdir, destination_hexhash, size=DEFAULT_PROBE_SIZE, full_
|
||||
exit()
|
||||
|
||||
|
||||
reticulum = RNS.Reticulum(configdir = configdir)
|
||||
reticulum = RNS.Reticulum(configdir = configdir, loglevel = 3+verbosity)
|
||||
|
||||
if not RNS.Transport.has_path(destination_hash):
|
||||
RNS.Transport.request_path(destination_hash)
|
||||
@ -75,7 +75,12 @@ def program_setup(configdir, destination_hexhash, size=DEFAULT_PROBE_SIZE, full_
|
||||
print("\b\b ")
|
||||
sys.stdout.flush()
|
||||
|
||||
hops = str(RNS.Transport.hops_to(destination_hash))
|
||||
hops = RNS.Transport.hops_to(destination_hash)
|
||||
if hops > 1:
|
||||
ms = "s"
|
||||
else:
|
||||
ms = ""
|
||||
|
||||
rtt = receipt.get_rtt()
|
||||
if (rtt >= 1):
|
||||
rtt = round(rtt, 3)
|
||||
@ -87,8 +92,8 @@ def program_setup(configdir, destination_hexhash, size=DEFAULT_PROBE_SIZE, full_
|
||||
print(
|
||||
"Valid reply received from "+
|
||||
RNS.prettyhexrep(receipt.destination.hash)+
|
||||
", round-trip time is "+rttstring+
|
||||
" over "+hops+" hops"
|
||||
"\nRound-trip time is "+rttstring+
|
||||
" over "+str(hops)+" hop"+ms
|
||||
)
|
||||
|
||||
|
||||
@ -126,6 +131,8 @@ def main():
|
||||
type=str
|
||||
)
|
||||
|
||||
parser.add_argument('-v', '--verbose', action='count', default=0)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.config:
|
||||
@ -141,7 +148,8 @@ def main():
|
||||
program_setup(
|
||||
configdir = configarg,
|
||||
destination_hexhash = args.destination_hash,
|
||||
full_name = args.full_name
|
||||
full_name = args.full_name,
|
||||
verbosity = args.verbose
|
||||
)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
|
Loading…
Reference in New Issue
Block a user