summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xautopeer_shell.py19
-rw-r--r--crond.autopeer3
-rwxr-xr-xinstall.sh4
4 files changed, 21 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 03a08c8..3fc34e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ sqlite3.db
__pycache__
.rsync-filter
dn42-registry
+smokeping-peer.conf
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/")
diff --git a/crond.autopeer b/crond.autopeer
new file mode 100644
index 0000000..72891c8
--- /dev/null
+++ b/crond.autopeer
@@ -0,0 +1,3 @@
+47 * * * * root git -c merge.verifysignatures=false -c core.sshcommand="ssh -i /opt/autopeer/id_autopeer" -C /opt/autopeer/dn42-registry pull
+*/5 * * * * root /opt/autopeer/cronjob.py
+0 * * * * root git -C /opt/autopeer pull
diff --git a/install.sh b/install.sh
index b1851d6..bd0ea5a 100755
--- a/install.sh
+++ b/install.sh
@@ -12,9 +12,7 @@ addgroup autopeer
adduser --disabled-password --comment '' new
git -c core.sshcommand="ssh -i /opt/autopeer/id_autopeer" clone git@git.dn42.dev:dn42/registry.git /opt/autopeer/dn42-registry
-echo '47 * * * * root git -c merge.verifysignatures=false -c core.sshcommand="ssh -i /opt/autopeer/id_autopeer" -C /opt/autopeer/dn42-registry pull' >>/etc/cron.d/autopeer
-echo '*/5 * * * * root /opt/autopeer/cronjob.py' >>/etc/cron.d/autopeer
-echo '0 * * * * root git -C /opt/autopeer pull' >>/etc/cron.d/autopeer
+ln -s /opt/autopeer/crond.autopeer /etc/cron.d/autopeer
umask 0007
mkdir /opt/autopeer/db