diff --git a/web/__init__.py b/web/__init__.py index 7fbec82..c4fb9bf 100644 --- a/web/__init__.py +++ b/web/__init__.py @@ -24,6 +24,8 @@ def create_app(test_config=None): 'admin_mail': '', 'wg_endpoint': '', 'wg_port': '51820', + 'wg_allowed_nets': '', + 'wg_dns': False, 'wg_key': '', 'wg_net': '', 'version': 0, diff --git a/web/templates/vpn/wg-fri.conf b/web/templates/vpn/wg-fri.conf index cb294e3..811883d 100644 --- a/web/templates/vpn/wg-fri.conf +++ b/web/templates/vpn/wg-fri.conf @@ -3,17 +3,17 @@ # PublicKey = {{ pubkey }} PrivateKey = # paste private key here Address = {{ ip }} -{% if use_dns %}DNS = 212.235.188.28,212.235.188.29,fri1.uni-lj.si{% endif %} +{%- if dns %} +DNS = {{ dns }} +{%- endif %} [Peer] Endpoint = {{ server }}:{{ port }} PublicKey = {{ server_key }} PersistentKeepalive = 25 -AllowedIPs = 10.32.0.0/14 -AllowedIPs = 212.235.188.16/28 -AllowedIPs = 212.235.188.32/27 -AllowedIPs = 212.235.188.64/26 +{%- for net in allowed_nets.split() %} +AllowedIPs = {{ net }} +{%- endfor %} {% if add_default -%} AllowedIPs = 0.0.0.0/0 {%- endif %} - diff --git a/web/vpn.py b/web/vpn.py index 552854c..64758df 100644 --- a/web/vpn.py +++ b/web/vpn.py @@ -67,8 +67,9 @@ def new(): 'ip': str(ip), 'timestamp': now, 'name': name, + 'dns': settings.get('wg_dns') if flask.request.json.get('use_dns', True) else False, + 'allowed_nets': settings.get('wg_allowed_nets', []), 'add_default': flask.request.json.get('add_default', False), - 'use_dns': flask.request.json.get('use_dns', True), } return flask.render_template('vpn/wg-fri.conf', **args)