Skip to content

Commit

Permalink
Update wireguard.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderMalmstrom committed Nov 19, 2024
1 parent 1ae9c43 commit 3b69857
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions modules/wireguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,11 @@ def generate(host, *args):

current_event = lib.get_current_event()

if os.path.isfile(DB_FILE):
try:
conn = sqlite3.connect(DB_FILE)
db = conn.cursor()
except sqlite3.Error as e:
print("An error occurred:", e.args[0])
sys.exit(2)
else:
print("No database file found: %s" % DB_FILE)
sys.exit(3)

db.execute('SELECT ipv4_netmask_dec FROM network WHERE short_name = "TECH-WIREGUARD-VPN";')
res = db.fetchone()
if not res:
raise NodeNotFoundError('Node %s not found' % host)

subnet = res[0]

db.execute('SELECT ipv4_gateway_txt FROM network WHERE short_name = "TECH-WIREGUARD-VPN";')
res = db.fetchone()
conn.close()
if not res:
raise NodeNotFoundError('Node %s not found' % host)

gatewayIP = res[0]
tunnelIP = ipaddress.ip_address(gatewayIP) + 4
tunnelIP = str(tunnelIP)

info = {}
info['current_event'] = current_event
info['tunnelIP'] = tunnelIP
#info['tunnelIP'] = tunnelIP
return {'wireguard': info}

# vim: ts=4: sts=4: sw=4: expandtab

0 comments on commit 3b69857

Please sign in to comment.