Skip to content

Commit 2b174ff

Browse files
authored
[change] Improved default site name and OpenVPN template
- Automatically update default site with DASHBOARD_DOMAIN - Improved OpenVPN template: - Updated ciphers - Added login to OpenVPN template
1 parent 8f378f3 commit 2b174ff

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

images/openwisp_dashboard/load_init_data.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def create_default_vpn_template(vpn):
124124
if Template.objects.filter(vpn=vpn).exists():
125125
return Template.objects.get(vpn=vpn)
126126

127-
template = Template.objects.create(
127+
template = Template(
128128
auto_cert=True,
129129
name=template_name,
130130
type="vpn",
@@ -133,6 +133,11 @@ def create_default_vpn_template(vpn):
133133
vpn=vpn,
134134
default=True,
135135
)
136+
# The config field is auto-generated on full_clean()
137+
template.full_clean()
138+
if template.config.get("openvpn"):
139+
template.config["openvpn"][0]["log"] = "/var/log/tun0.log"
140+
# Verify that the config is still valid.
136141
template.full_clean()
137142
template.save()
138143
return template
@@ -196,6 +201,26 @@ def create_ssh_key_template():
196201
return template
197202

198203

204+
def update_default_site():
205+
"""Update default site with DASHBOARD_DOMAIN."""
206+
if "django.contrib.sites" in settings.INSTALLED_APPS:
207+
from django.contrib.sites.models import Site
208+
209+
try:
210+
site = Site.objects.get(pk=settings.SITE_ID)
211+
except Site.DoesNotExist:
212+
# Optionally log a message here if desired
213+
return
214+
dashboard_domain = os.environ.get("DASHBOARD_DOMAIN", "")
215+
if (
216+
site.name == "example.com" or site.domain == "example.com"
217+
) and dashboard_domain:
218+
site.name = dashboard_domain
219+
site.domain = dashboard_domain
220+
site.full_clean()
221+
site.save()
222+
223+
199224
def create_default_topology(vpn):
200225
"""Creates Topology object for the default VPN."""
201226
if vpn.backend == "openwisp_controller.vpn_backends.OpenVpn":
@@ -239,6 +264,7 @@ def create_default_topology(vpn):
239264
redis_client = redis.Redis.from_url(settings.CACHES["default"]["LOCATION"])
240265

241266
create_admin()
267+
update_default_site()
242268
# Steps for creating new vpn client template with all the
243269
# required objects (CA, Certificate, VPN Server).
244270
is_vpn_enabled = os.environ.get("VPN_DOMAIN", "") != ""

images/openwisp_dashboard/openvpn.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"local": "",
1212
"comp_lzo": "no",
1313
"auth": "SHA1",
14-
"cipher": "none",
14+
"data_ciphers": "AES-128-GCM:none",
15+
"data_ciphers_fallback": "AES-128-GCM",
16+
"cipher": "AES-128-GCM",
1517
"engine": "",
1618
"ca": "ca.pem",
1719
"cert": "cert.pem",

0 commit comments

Comments
 (0)