diff options
Diffstat (limited to 'autopeer_shell.py')
| -rwxr-xr-x | autopeer_shell.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/autopeer_shell.py b/autopeer_shell.py index 1d77d43..8880ec6 100755 --- a/autopeer_shell.py +++ b/autopeer_shell.py @@ -8,6 +8,8 @@ except: pass from config import * from lib_autopeer import * +NAME_REGEX = r'^[a-zA-Z][a-zA-Z0-9]{0,8}$' + def as_from_user(which=None): if which is not None: try: @@ -92,7 +94,6 @@ class AutopeerShell(cmd.Cmd): def do_addpeer(self, name, pubkey, endpoint, port, ipll): '''<name> <wg pubkey> <wg address> <wg port> <ipv6 link local> Add a new peer''' - NAME_REGEX = r'^[a-zA-Z][a-zA-Z0-9]{0,8}$' if not re.match(NAME_REGEX, name): print(f'Error: name must match {NAME_REGEX}', file=sys.stderr) return @@ -199,6 +200,15 @@ Your Tunnel IPv6LL: {you.ipll} '''Run birdc''' os.system('/usr/sbin/birdc -r') + @parse(1) + def do_stat(self, name): + '''<name> + Show link stats''' + if not re.match(NAME_REGEX, name): + print(f'Error: name must match {NAME_REGEX}', file=sys.stderr) + return + os.system(f'ip stat show dev wg{SELECTED_ASN%10000:04}{name} group link') + @parse(0) def do_exit(self): return True |
