mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2025-04-19 08:55:12 +00:00
Add functionality for applying database patches on login
This commit is contained in:
parent
c43fdd749f
commit
7226177d42
@ -2,17 +2,33 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Welcome to WireGuard WebAdmin</h1>
|
||||
<p>WireGuard WebAdmin is a web-based interface designed for managing WireGuard VPN, a remarkably simple, fast, and modern VPN that employs cutting-edge cryptography.</p>
|
||||
<p>I have dedicated significant effort to this project over the past few weeks and am thrilled to announce that we are now close to version 1.0</p>
|
||||
<h1>Database settings updated</h1>
|
||||
<p>The following modifications have been applied to your database:</p>
|
||||
<table class="table table-bordered">
|
||||
<th>Patch</th>
|
||||
<th>Field</th>
|
||||
<th>Value</th>
|
||||
<th>Objects</th>
|
||||
<th>Reason</th>
|
||||
<thead>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for update in update_list %}
|
||||
<tr>
|
||||
<td>{{ update.patch_version}}</td>
|
||||
<td>{{ update.field }}</td>
|
||||
<td>{{ update.new_value }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
{% for object in update.object_list %}<li>{{ object }}</li>{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
<td>{{ update.reason|safe }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<h3>Upcoming Enhancements</h3>
|
||||
<ul>
|
||||
<li>Improving "Pending changes" notification and separation (WireGuard from Firewall)</li>
|
||||
</ul>
|
||||
|
||||
<p>Stay tuned to our GitHub page for imminent updates to this project.</p>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
@ -173,4 +173,43 @@ def view_wireguard_manage_instance(request):
|
||||
else:
|
||||
form = WireGuardInstanceForm(instance=current_instance)
|
||||
context = {'page_title': page_title, 'wireguard_instances': wireguard_instances, 'current_instance': current_instance, 'form': form, 'pending_changes_warning': pending_changes_warning}
|
||||
return render(request, 'wireguard/wireguard_manage_server.html', context)
|
||||
return render(request, 'wireguard/wireguard_manage_server.html', context)
|
||||
|
||||
|
||||
@login_required
|
||||
def view_apply_db_patches(request):
|
||||
if not UserAcl.objects.filter(user=request.user).filter(user_level__gte=50).exists():
|
||||
return redirect('/status/')
|
||||
webadmin_settings, webadmin_settings_created = WebadminSettings.objects.get_or_create(name='webadmin_settings')
|
||||
update_applied = False
|
||||
update_list = []
|
||||
|
||||
if webadmin_settings.db_patch_version < 1:
|
||||
print('Applying DB patch 1')
|
||||
object_list = []
|
||||
for wg_instance in WireGuardInstance.objects.filter(peer_list_refresh_interval__gt=10):
|
||||
object_list.append(f'wg{wg_instance.instance_id}')
|
||||
wg_instance.peer_list_refresh_interval = 10
|
||||
wg_instance.save()
|
||||
|
||||
if object_list:
|
||||
update_applied = True
|
||||
update_list.append({
|
||||
'patch_version': 1, 'object_list': object_list,
|
||||
'field': 'peer_list_refresh_interval', 'new_value': '10',
|
||||
'reason': 'The interval has been reduced to improve the user experience on the peer list. This <b>may impact server performance</b> in larger environments. You can modify this interval in "Server Settings."'
|
||||
})
|
||||
webadmin_settings.db_patch_version = 1
|
||||
webadmin_settings.save()
|
||||
|
||||
data = {
|
||||
'update_applied': update_applied,
|
||||
'update_list': update_list,
|
||||
}
|
||||
if update_applied:
|
||||
return render(request, 'wireguard/welcome.html', context=data)
|
||||
else:
|
||||
return redirect('/status/')
|
||||
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.views.generic import RedirectView
|
||||
|
||||
from wireguard.views import view_wireguard_status, view_wireguard_manage_instance
|
||||
from wireguard.views import view_wireguard_status, view_wireguard_manage_instance, view_apply_db_patches
|
||||
from wireguard_peer.views import view_wireguard_peer_list, view_wireguard_peer_manage, view_manage_ip_address, view_wireguard_peer_sort
|
||||
from console.views import view_console
|
||||
from user_manager.views import view_user_list, view_manage_user, view_peer_group_list, view_peer_group_manage
|
||||
@ -31,7 +31,7 @@ from wgrrd.views import view_rrd_graph
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', RedirectView.as_view(url='/status/', permanent=False), name='redirect_to_status'),
|
||||
path('', view_apply_db_patches, name='apply_db_patches'),
|
||||
path('status/', view_wireguard_status, name='wireguard_status'),
|
||||
path('dns/', view_static_host_list, name='static_host_list'),
|
||||
path('dns/apply_config/', view_apply_dns_config, name='apply_dns_config'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user