diff --git a/wg_api/__pycache__/views.cpython-310.pyc b/wg_api/__pycache__/views.cpython-310.pyc index 5abb4f6a..ddd5ebf1 100644 Binary files a/wg_api/__pycache__/views.cpython-310.pyc and b/wg_api/__pycache__/views.cpython-310.pyc differ diff --git a/wg_api/utils/__pycache__/reqs_handler.cpython-310.pyc b/wg_api/utils/__pycache__/reqs_handler.cpython-310.pyc index 718cbd26..abe2ee12 100644 Binary files a/wg_api/utils/__pycache__/reqs_handler.cpython-310.pyc and b/wg_api/utils/__pycache__/reqs_handler.cpython-310.pyc differ diff --git a/wg_api/utils/reqs_handler.py b/wg_api/utils/reqs_handler.py index a1b7d186..5c028baa 100644 --- a/wg_api/utils/reqs_handler.py +++ b/wg_api/utils/reqs_handler.py @@ -28,9 +28,7 @@ def req_edit_state(id, state): def req_edit_user(id): inf_s = get_session() - req_val = id - req_url = 'http://10.30.1.138:5000/api/client/'+req_val req = inf_s.get(req_url) @@ -42,5 +40,17 @@ def req_edit_user(id): return req.json() +def req_apply_sys(): + inf_s = get_session() + # http://10.30.1.138:5000/api/apply-wg-config?_=1669872830286 + req_url = 'http://10.30.1.138:5000/api/apply-wg-config' + + req = inf_s.get(req_url) + + print("-->") + print(req) + + return req + # # http://10.30.1.138:5000/api/client/caivc1vekn84im2m6ec0?_=1669623393468 diff --git a/wg_api/views.py b/wg_api/views.py index 38e4d40a..66a5a692 100644 --- a/wg_api/views.py +++ b/wg_api/views.py @@ -12,7 +12,7 @@ from .models import user_model from .utils.html_parser import get_logs, get_profiles import json from .utils.statistics import count_clients, count_traffic, count_connection, count_percentage, count_broken -from .utils.reqs_handler import req_edit_state, req_edit_user +from .utils.reqs_handler import req_edit_state, req_edit_user, req_apply_sys from django.middleware.csrf import get_token from django.views.decorators.csrf import csrf_exempt @@ -283,6 +283,16 @@ def wgViewClients(request): return HttpResponse(final_data, content_type='application') +def get_ApplyConfig(request): + + # id = request.GET.get('id', '') + # state = request.GET.get('state', '') + # print("Edit Request...") + + req_response = req_apply_sys() + + return HttpResponse(req_response) + def get_EditState(request): id = request.GET.get('id', '') @@ -297,7 +307,14 @@ def get_EditState(request): req_edit_state(id, state) else: - print(id) + print("[ Bulk handler ]=======") + print(request.body) + + target_ids = request.body + + for x in json.loads(target_ids): + req_edit_state(str(x), state) + print(x) final_data = json.dumps({"state":"Success"}) diff --git a/wgweb/__pycache__/settings.cpython-310.pyc b/wgweb/__pycache__/settings.cpython-310.pyc index 0138170b..c9f8117e 100644 Binary files a/wgweb/__pycache__/settings.cpython-310.pyc and b/wgweb/__pycache__/settings.cpython-310.pyc differ diff --git a/wgweb/__pycache__/urls.cpython-310.pyc b/wgweb/__pycache__/urls.cpython-310.pyc index 07aba1ac..5b1596bf 100644 Binary files a/wgweb/__pycache__/urls.cpython-310.pyc and b/wgweb/__pycache__/urls.cpython-310.pyc differ diff --git a/wgweb/urls.py b/wgweb/urls.py index 676cb6f9..c66f8dd6 100644 --- a/wgweb/urls.py +++ b/wgweb/urls.py @@ -27,5 +27,6 @@ urlpatterns = [ path('api2/wgLogs', views.wgViewLogs), path('api2/wgClients', views.wgViewClients), path('api2/wgEditState', views.get_EditState), + path('api2/wgSysApply', views.get_ApplyConfig), path('api2/wgEditClient', views.get_EditClient) ]