update stuff

This commit is contained in:
Adora Laura Kalb 2024-05-23 10:01:02 +02:00
parent 9859d3f544
commit 257ea183c5
Signed by: adoralaura
SSH key fingerprint: SHA256:3XrkbR8ikAZJVtYfaUliX1MhmJYVAe/ocIb/MiDHBJ8
2 changed files with 64 additions and 3 deletions

View file

@ -1,14 +1,15 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import time import time
start_time = time.time()
import argparse import argparse
import logging import logging
import requests import requests
import json import json
from config import * from config import config
start_time = time.time()
headers = { headers = {
'X-API-Key': config['apikey'], 'X-API-Key': config['apikey'],

60
wireguard/new-peer.sh Executable file
View file

@ -0,0 +1,60 @@
#!/bin/bash
clientdir=/etc/wireguard/clients
endpoint="vpn.example.net:5999"
echo "Name of new peer?"
read peername
echo "IP of new peer? (without CIDR)"
read peerip
if [ -f $clientdir/$peername.conf ]; then
echo "peer $peername already exists. Exiting..."
exit 1
fi
# generating the clients private key
client_privatekey=$(wg genkey)
echo "$client_privatekey" > $clientdir/$peername-private.key
# generating the clients public key from the private key
client_publickey=$(echo "$client_privatekey" | wg pubkey)
echo "$client_publickey" > $clientdir/$peername-public.key
# getting the PSK
psk=$(cat /etc/wireguard/psk.key)
# getting server public key
server_publickey=$(cat /etc/wireguard/server_public.key)
echo ""
echo ""
echo "########################################################"
echo "########## config for /etc/wireguard/wg0.conf ##########"
cat << EOF
# $peername
[Peer]
PublicKey = $client_publickey
PresharedKey = $psk
AllowedIPs = $peerip/32
EOF
echo ""
echo ""
echo "########################################################"
echo "################## Client-Config #######################"
cat | tee $clientdir/$peername.conf << EOF
[Interface]
PrivateKey = $client_privatekey
Address = $peerip/32
DNS = 192.168.21.2, 192.168.21.3
[Peer]
PublicKey = $server_publickey
PresharedKey = $psk
AllowedIPs = 0.0.0.0/0
Endpoint = $endpoint
PersistentKeepalive = 25
EOF