Skip to content

Commit

Permalink
Rename TUN device to scionlab-vpn and make border router depending on it
Browse files Browse the repository at this point in the history
  • Loading branch information
mkowalski committed Nov 14, 2019
1 parent 5471ae8 commit 17ef749
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
1 change: 1 addition & 0 deletions scionlab/config_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def _add_vpn_config(host, archive):
client_config = generate_vpn_client_config(vpn_client)
archive.write_text("client.conf", client_config)
archive.write_text("override_openvpn_client.conf", '[Install]\nWantedBy=scionlab.target\n')
archive.write_text("override_border_router.conf", '[Unit]\nAfter=sys-devices-virtual-net-scionlab\\x2dvpn.device\nBindsTo=sys-devices-virtual-net-scionlab\\x2dvpn.device\n')

vpn_servers = list(host.vpn_servers.all())
for vpn_server in vpn_servers:
Expand Down
3 changes: 2 additions & 1 deletion scionlab/hostfiles/client.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
client

# We use a TUN device, a virtual point-to-point IP link
dev tun
dev-type tun
dev scionlab-vpn

# Connecting to a UDP server
proto udp
Expand Down
23 changes: 4 additions & 19 deletions scionlab/hostfiles/scionlab-config
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,10 @@ def restart_scion():

def install_vpn_client_config(tmpdir):
exists, changed = _install_file(tmpdir, 'client.conf', '/etc/openvpn/', 'client.conf')
_, _ = _install_file(tmpdir, 'override_openvpn_client.conf', '/etc/systemd/system/[email protected]/', 'override.conf')
_, _ = _install_file(tmpdir, 'override_openvpn_client.conf',
'/etc/systemd/system/[email protected]/', 'override.conf')
_, _ = _install_file(tmpdir, 'override_border_router.conf',
'/etc/systemd/system/[email protected]/', 'override.conf')

if exists:
scionlab_services = os.path.join(tmpdir, 'scionlab-services.txt')
Expand All @@ -331,24 +334,6 @@ def install_vpn_client_config(tmpdir):
with open(scionlab_services, 'a') as f:
f.write('\n[email protected]')

# (TODO) We do not start OpenVPN client here, thus this logic has to be moved somewhere else

# if changed:
# # ensure the interface is up; give up after 5 tries
# vpn_ready = False
# for i in range(5):
# logging.debug('Waiting for VPN ...')
# time.sleep(1)
# st = subprocess.run(['ip', 'address', 'show', 'dev', 'tun0'],
# stdout=subprocess.DEVNULL,
# stderr=subprocess.DEVNULL)
# if st.returncode == 0:
# vpn_ready = True
# break
# if vpn_ready:
# logging.debug("Got VPN")
# else:
# logging.warn('WARNING!: VPN could be unready. SCION may fail to start.')
else:
subprocess.run(['systemctl', 'stop', 'openvpn@client'], check=False)

Expand Down
7 changes: 6 additions & 1 deletion scionlab/tests/data/test_config_tar/user_as_18.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ README.md: |-
override_openvpn_client.conf: |
[Install]
WantedBy=scionlab.target
override_border_router.conf: |
[Unit]
After=sys-devices-virtual-net-scionlab\x2dvpn.device
BindsTo=sys-devices-virtual-net-scionlab\x2dvpn.device
client.conf: |
# Specify that we are a client
client
# We use a TUN device, a virtual point-to-point IP link
dev tun
dev-type tun
dev scionlab-vpn
# Connecting to a UDP server
proto udp
Expand Down

0 comments on commit 17ef749

Please sign in to comment.