From caaedfa00370174666f27552bb069b196691a653 Mon Sep 17 00:00:00 2001 From: infidel Date: Thu, 1 Dec 2022 13:05:43 +0700 Subject: [PATCH] add url and view handler for sysconfig apply, --- wg_api/__pycache__/views.cpython-310.pyc | Bin 5261 -> 6452 bytes .../__pycache__/reqs_handler.cpython-310.pyc | Bin 1034 -> 1262 bytes wg_api/utils/reqs_handler.py | 14 ++++++++++-- wg_api/views.py | 21 ++++++++++++++++-- wgweb/__pycache__/settings.cpython-310.pyc | Bin 2599 -> 2673 bytes wgweb/__pycache__/urls.cpython-310.pyc | Bin 1301 -> 1395 bytes wgweb/urls.py | 1 + 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/wg_api/__pycache__/views.cpython-310.pyc b/wg_api/__pycache__/views.cpython-310.pyc index 5abb4f6a33db1fbda7c6006872ed30414ea3e4d8..ddd5ebf19962019818b9537c53662eadf28ec07e 100644 GIT binary patch delta 2580 zcmZ`*OKcNI7~Yv(uh))WiIbQlPGSfz19c0Ps4A5fNGVXjP(oX2DY9J8BrMtWhM6@X zk%JGRQXk@g_S!=@B5^39Jyq(ZQl%bx>TRVSda3%5dh4M=LjC{QKps-pns5I3|9@Wp zYkaTz^^u&P&89W@rjCEw`ey(AT$vsq_Yb|=(^$f_yp)~t(sr6?Ok<|o=Vk1SqLXgc z%h@?aTfooTd7x7)?H0U#yI;|L?toXci;B*;gWixmH zN4+t7%q!bvZ`>XyS`UPIcfy;rC%uYY@pjrf)x?6k%bT*N6y5Lc_V(C&h;~|I1FU#g zV?~}^)$P479%Mr>9^#1``+&2b4YSf+&91T?Yy|oPY?O^be~^{gIP{0u1e=8ZC6=Ah zs+B)9?fyRp-%p;nboK*>FIH(ZG{dEI{Pu}XaGkdUr_~H#6ctZ4rPJEVtdb~yR&L^P z1}y6`mkWMd@^GB25k35lO!lIz;5Qr1g#~x1A(td*rRI3h2>f~8hCyFTirEIg&Ao-7 zg)Z9s=`c7BP3{KZnoXEyQ?7Gkj@k)s&JjDw3`UuLm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!(lj;yAYBxcO+=Y?}%}34$E>{@Av#6RE5{oZ^2<)wRF zcj7pf0@n}XZ202S=Wd(+rkua<@X{N;V;-x)v(5ZETLR-ctFs0?S6O*a={99Rdh$>5Eur!Yx+cHYrrj>t?UKxi#-sjl zG9HIRG2vaBX=xabvJwwJJq}axqr#i=J9URN<+i>eb?q5q%1CeDDgp7#OG6$F;^;Kw z{b4*vQ@#vt-h2{T`04|=Fj5o1R4i2^w#NO3kMyrpV#trmzZ?15vRt=XdZwm=%T23g zG;nc823Gsp#kRO(W}O`DN8!l_lY?|so?CyAn-A|)e$|W)u2`3CZw2;!&08bS%6;#r z#VhE36`N0Rt=x_$Cn4uIaB>qJY8;L;{dhVBZyCK6 z1P1}>@hXB1kQt*1PX>ak@Y1b6#|tJny@RlYu#NC807Uo4gCykd$nR@ku3n+)6jXQO zC>)FQbGhsPO-AzP#&vQi|5|#!yfGtuLr|v6jr!_BX!mudG9w}n$Xpf1Ol2iz-lI?l z<=u=%jIZN~dMXAYJgvURBGI{Bq`TMaomTI3a@WV3#g&!zj)%h#l6xUx>5_z~6Za5u z9XA(f=A^ZP^8q>z5pud$xgCU}j|cAI=QspPqz@dcfcyM!o0#pj%kH4sOOz?y+#E6SXrU^5D0Q4otV zgOzfz%w3*;I;zFDh diff --git a/wg_api/utils/__pycache__/reqs_handler.cpython-310.pyc b/wg_api/utils/__pycache__/reqs_handler.cpython-310.pyc index 718cbd26c7a049c2543ff0160ebaaae0be9ae6b3..abe2ee1280f495596f2938f54cbe27fdd0839935 100644 GIT binary patch delta 304 zcmeC;c*n_?&&$ij00iIdJCdtdCi2NJnoQKz;pIr-Y+;CEO<@dX(B#?}^Nxw}*JN+z z&D~g^aaK zB}^$y&5Vo;B}_G7x`qj81+!n3c1B4_ft9|#p@E*Ufu5nBp|ORPseyrkequo;5EtZB z>XxT#>L%ysrDdiUNdQgPWG>l)6ZvEqbtY=-urdZSXmV^!dB?<9H943$S%Zm#i3^B1 r7&%yqq=3pbS&IaLR1qtP-~kchAVO;L4i+^&kbxWwK($O9>^wpM*!vH& 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 0138170ba8ec9dc46715e230fefd2ad2515843a5..c9f8117e4de39586be3cfb730ed3251f91acc816 100644 GIT binary patch delta 316 zcmZ23@==60pO=@50SJBywkMZPNM3REMKA_gYK!K6ecV>(Ne zaEfG``iIPl_4Q9}kOVnayVBm7eO3X{&__mypk!^A+Q!-B# zS9!W#US49lUT*5<6HLpPB!3BIl#~<{Tj}c~WQy2;UfA5o+R4bsx0##Wjge7mauCNP zO%dndAh-CCpwQqDSC@GIAWwHszu;R!U{Pm(e{WCM_+VG(&>+{zk2&VEX#x!?(wyAE m=`RxiWU?^u@CY!ou(L38FmbSQ@N#goaj-D5Fin2XX#oI!Elvsm delta 230 zcmew;vRs5WpO=@50SLO<>XT(B^2#!9nyBrY6~&vvmClgDlEMunc@{BdGN$m(VM%9< z;!EL+;!ojE5lCfA5tL>~5t_r4$rvS&BAg-uR3n@s3MR$Cq3X@To9D82GBWaRR%dr(WR#ek$1!QL7Uw)RHK41D)Fz+f^q24fGFcdScm$YP*jbo4 Sm^fHDcsaOPI3`a;*`Awx4$DoYA?Drc4u zn8gER34>X@K$ZxY#Rp`Gf?51PmRK`WI!Bavia;=frr^d?hnaYJ5(_eo^vlzI^3yZ( zCigHKsPRKZf-8$13kq^7s|29}t|^%%&N-Q>c_n_D5|b}7cL}mX_1$7mERHYBOf8=r z#iA|1pPpJ057z3OpO==IKDmWOflV6d@FMBSt602M6o5}I3 zmJpc53uFm5Go`adiKOraGidT}d~}#;@@8gzQNhH5Oe6jBbk~&366c)E)VvZuP0`65 mEM1eAuxL%b&mzwz0W`iyVloS>H>1qt09H{hE=CCC_yqtb=OlXo 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) ]