diff options
Diffstat (limited to 'autopeer_shell.py')
| -rwxr-xr-x | autopeer_shell.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/autopeer_shell.py b/autopeer_shell.py index f7b2cdd..2c6eac4 100755 --- a/autopeer_shell.py +++ b/autopeer_shell.py @@ -114,6 +114,8 @@ class AutopeerShell(cmd.Cmd): print(f'Error: ipv6 link local must match {IPLL_REGEX}', file=sys.stderr) return + sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.gethostname()}] Created new peering {name!r} for AS{SELECTED_ASN} by {USER}", text=True) + try: curs = DB.execute( 'INSERT INTO peers (name, asn, pubkey, endpoint, port, ipll, creator_ip, creator_name, creator_date) VALUES (:name, :asn, :pubkey, :endpoint, :port, :ipll, :creator_ip, :creator_name, :creator_date)', @@ -137,6 +139,7 @@ class AutopeerShell(cmd.Cmd): def do_delpeer(self, name): '''<name> Delete your peering''' + sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.gethostname()}] Deleted peering {name!r} for AS{SELECTED_ASN} by {USER}", text=True) curs = DB.execute( 'DELETE FROM peers WHERE name = :name AND asn = :asn', dict(name=name, asn=SELECTED_ASN) @@ -218,7 +221,10 @@ Your Tunnel IPv6LL: {you.ipll} if __name__ == '__main__': shell = AutopeerShell() - if len(os.getenv('SSH_ORIGINAL_COMMAND', '')): - shell.onecmd(os.getenv('SSH_ORIGINAL_COMMAND')) + command = os.getenv('SSH_ORIGINAL_COMMAND', '') + if len(command): + sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.gethostname()}] {USER} ran {command}", text=True) + shell.onecmd(command) else: + sp = subprocess.run(['socat', 'stdio', NOTIFY_TO], input=f"[autopeer {socket.gethostname()}] {USER} logged in", text=True) shell.cmdloop() |
