summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interface-wireguard.py7
-rwxr-xr-xsrc/op_mode/wireguard.py18
2 files changed, 11 insertions, 14 deletions
diff --git a/src/conf_mode/interface-wireguard.py b/src/conf_mode/interface-wireguard.py
index 0f9e66aa6..d51a7a08d 100755
--- a/src/conf_mode/interface-wireguard.py
+++ b/src/conf_mode/interface-wireguard.py
@@ -31,7 +31,6 @@ intfc = WireGuardIf(ifname)
kdir = r'/config/auth/wireguard'
-
def check_kmod():
if not os.path.exists('/sys/module/wireguard'):
sl.syslog(sl.LOG_NOTICE, "loading wirguard kmod")
@@ -55,7 +54,7 @@ def get_config():
'fwmark': 0x00,
'mtu': 1420,
'peer': {},
- 'pk': '{}/private.key'.format(kdir)
+ 'pk' : '{}/default/private.key'.format(kdir)
}
}
@@ -81,8 +80,7 @@ def get_config():
if c.exists(ifname + ' mtu'):
config_data[ifname]['mtu'] = c.return_value(ifname + ' mtu')
if c.exists(ifname + ' private-key'):
- config_data[ifname]['pk'] = "{0}/{1}/private.key".format(
- kdir, c.return_value(ifname + ' private-key'))
+ config_data[ifname]['pk'] = "{0}/{1}/private.key".format(kdir,c.return_value(ifname + ' private-key'))
if c.exists(ifname + ' peer'):
for p in c.list_nodes(ifname + ' peer'):
if not c.exists(ifname + ' peer ' + p + ' disable'):
@@ -113,7 +111,6 @@ def get_config():
return config_data
-
def verify(c):
if not c:
return None
diff --git a/src/op_mode/wireguard.py b/src/op_mode/wireguard.py
index e48da2e40..4e93ec6aa 100755
--- a/src/op_mode/wireguard.py
+++ b/src/op_mode/wireguard.py
@@ -91,18 +91,16 @@ def genpsk():
subprocess.call(['wg genpsk'], shell=True)
-
def list_key_dirs():
- """ lists all dirs under /config/auth/wireguard """
+ """ lists all dirs under /config/auth/wireguard """
if os.path.exists(dir):
nks = next(os.walk(dir))[1]
for nk in nks:
print (nk)
-
def del_key_dir(kname):
""" deletes /config/auth/wireguard/<kname> """
- kdir = "{0}/{1}".format(dir, kname)
+ kdir = "{0}/{1}".format(dir,kname)
if not os.path.isdir(kdir):
print ("named keypair {} not found".format(kname))
return 1
@@ -133,24 +131,26 @@ if __name__ == '__main__':
if args.location:
genkey("{0}/{1}".format(dir, args.location))
else:
- genkey(dir)
-
+ genkey("{}/default".format(dir))
if args.showpub:
if args.location:
showkey("{0}/{1}/public.key".format(dir, args.location))
else:
- showkey("{}/public.key".format(dir))
+ showkey("{}/default/public.key".format(dir))
if args.showpriv:
if args.location:
showkey("{0}/{1}/private.key".format(dir, args.location))
else:
- showkey("{}/private".format(dir))
+ showkey("{}/default/private.key".format(dir))
if args.genpsk:
genpsk()
if args.listkdir:
list_key_dirs()
if args.delkdir:
- del_key_dir(args.location)
+ if args.location:
+ del_key_dir(args.location)
+ else:
+ del_key_dir("default")
except ConfigError as e:
print(e)