15 lines
440 B
Python
15 lines
440 B
Python
"""Give user alice one WireGuard peer: wireguard_peer.py PUBLIC-KEY TUNNEL-ADDRESS.
|
|
|
|
Runs on the server; the peer's allowed address is TUNNEL-ADDRESS/32.
|
|
"""
|
|
|
|
import sys
|
|
|
|
sys.path.insert(0, '/usr/lib/linux-manager')
|
|
|
|
import linuxmanager_users as users
|
|
|
|
public_key, address = sys.argv[1:3]
|
|
with users.session() as connection:
|
|
users.update(connection, 'alice', {'wireguard_peers': [{'public_key': public_key, 'ips': [f'{address}/32']}]})
|