summaryrefslogtreecommitdiff
path: root/autopeer_shell.py
diff options
context:
space:
mode:
Diffstat (limited to 'autopeer_shell.py')
-rwxr-xr-xautopeer_shell.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/autopeer_shell.py b/autopeer_shell.py
index ea54ec5..649b24c 100755
--- a/autopeer_shell.py
+++ b/autopeer_shell.py
@@ -29,6 +29,9 @@ def as_from_user(which=None):
else:
print(f"oops, something went wrong getting your ASes, specifically: {filename}", file=sys.stderr)
+ if not user_ases:
+ raise Exception("you don't mnt any AS?!")
+
if MY_ASN in user_ases and which: # allow owner to operate as anyone
return which
elif which is None: # at startup, use the first found
@@ -103,7 +106,12 @@ My Tunnel IPv6LL: {me.ipll}
@parse(5)
def do_addpeer(self, name, pubkey, endpoint, port, ipll):
'''<name> <wg pubkey> <wg address> <wg port> <ipv6 link local>
- Add a new peer'''
+ Add a new peer.
+ <name> is an opaque identifier and must be unique for your ASN
+ <wg pubkey> is your WireGuard public key
+ <wg address> is your WireGuard IP or hostname
+ <wg port> is your WireGuard port
+ <ipv6 link local> is your WireGuard IPv6LL'''
if not re.match(NAME_REGEX, name):
print(f'Error: name must match {NAME_REGEX}', file=sys.stderr)
return
@@ -149,7 +157,8 @@ My Tunnel IPv6LL: {me.ipll}
@parse(1)
def do_delpeer(self, name):
'''<name>
- Delete your peering'''
+ Delete your peering.
+ Note: The deletion will be processed the next time the cronjob runs, at which time the name will become available.'''
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(
'UPDATE peers SET deleted = 1 WHERE name = :name AND asn = :asn AND deleted = 0',
@@ -184,6 +193,7 @@ Your Tunnel IPv6LL: {you.ipll}
def do_showtemplates(self, name):
'''<name>
Show basic config templates for your side'''
+ print('### USE THESE CONFIGS ON YOUR NODE')
print(_bird_config(name, _get_my_info(SELECTED_ASN), _get_peer_info(name, SELECTED_ASN)))
print(_wg_config(name, _get_my_info(SELECTED_ASN), _get_peer_info(name, SELECTED_ASN)))
@@ -192,6 +202,7 @@ Your Tunnel IPv6LL: {you.ipll}
'''<name>
Show my side config
'''
+ print('### MY SIDE CONFIGS')
print(_bird_config(name, _get_peer_info(name, SELECTED_ASN), _get_my_info(SELECTED_ASN)))
print(_wg_config(name, _get_peer_info(name, SELECTED_ASN), _get_my_info(SELECTED_ASN)))
@@ -233,9 +244,11 @@ Your Tunnel IPv6LL: {you.ipll}
@parse(0)
def do_version(self):
- print("autopeer version:")
+ print("autopeer version:", end=' ')
+ sys.stdout.flush()
os.system("git -c safe.directory=/opt/autopeer -C /opt/autopeer/ describe --always")
print("by steering7253 https://steering.dn42 https://st33ri.ng")
+ print("Source available at https://cgit.dn42/steering/autopeer.git/ https://cgit.space/steering/autopeer.git/")