@@ -11,6 +11,14 @@ local tl_ops_manage_env = require("tl_ops_manage_env")
1111local cjson = require (" cjson.safe" );
1212cjson .encode_empty_table_as_object (false )
1313
14+ local store_list = {
15+ " tl-ops-balance-api" ," tl-ops-balance-body" ," tl-ops-balance-cookie" ,
16+ " tl-ops-balance-header" ," tl-ops-balance-param" ," tl-ops-service" ,
17+ " tl-ops-health" ," tl-ops-plugins-manage" ," tl-ops-limit" ,
18+ " tl-ops-balance" ," tl-ops-waf" ," tl-ops-waf-api" , " tl-ops-waf-ip" ,
19+ " tl-ops-waf-header" ," tl-ops-waf-param" ," tl-ops-waf-cookie" ," tl-ops-waf-cc" ,
20+ " tl-ops-auth" ," tl-ops-time-alert" ," tl-ops-ssl" ," tl-ops-page-proxy"
21+ }
1422
1523-- 读取文件
1624local read = function ( filename )
@@ -40,225 +48,49 @@ local read = function( filename )
4048end
4149
4250
43- local Router = function ()
44- local api_content , api_size = read (" tl-ops-balance-api.tlstore" );
45- if not api_content then
46- api_content = {}
47- end
48- local body_content , body_size = read (" tl-ops-balance-body.tlstore" );
49- if not body_content then
50- body_content = {}
51- end
52- local cookie_content , cookie_size = read (" tl-ops-balance-cookie.tlstore" );
53- if not cookie_content then
54- cookie_content = {}
55- end
56- local header_content , header_size = read (" tl-ops-balance-header.tlstore" );
57- if not header_content then
58- header_content = {}
59- end
60- local param_content , param_size = read (" tl-ops-balance-param.tlstore" );
61- if not param_content then
62- param_content = {}
63- end
64- local service_content , service_size = read (" tl-ops-service.tlstore" );
65- if not service_content then
66- service_content = {}
67- end
68- local health_content , health_size = read (" tl-ops-health.tlstore" );
69- if not health_content then
70- health_content = {}
71- end
72- local plugins_manage_content , plugins_manage_size = read (" tl-ops-plugins-manage.tlstore" );
73- if not plugins_manage_content then
74- plugins_manage_content = {}
75- end
76- local limit_content , limit_size = read (" tl-ops-limit.tlstore" );
77- if not limit_content then
78- limit_content = {}
79- end
80- local balance_content , balance_size = read (" tl-ops-balance.tlstore" );
81- if not balance_content then
82- balance_content = {}
83- end
84- local waf_content , waf_size = read (" tl-ops-waf.tlstore" );
85- if not waf_content then
86- waf_content = {}
87- end
88- local waf_api_content , waf_api_size = read (" tl-ops-waf-api.tlstore" );
89- if not waf_api_content then
90- waf_api_content = {}
91- end
92- local waf_ip_content , waf_ip_size = read (" tl-ops-waf-ip.tlstore" );
93- if not waf_ip_content then
94- waf_ip_content = {}
95- end
96- local waf_cookie_content , waf_cookie_size = read (" tl-ops-waf-cookie.tlstore" );
97- if not waf_cookie_content then
98- waf_cookie_content = {}
99- end
100- local waf_param_content , waf_param_size = read (" tl-ops-waf-param.tlstore" );
101- if not waf_param_content then
102- waf_param_content = {}
103- end
104- local waf_header_content , waf_header_size = read (" tl-ops-waf-header.tlstore" );
105- if not waf_header_content then
106- waf_header_content = {}
107- end
108- local waf_cc_content , waf_cc_size = read (" tl-ops-waf-cc.tlstore" );
109- if not waf_cc_content then
110- waf_cc_content = {}
111- end
112- local auth , auth_size = read (" tl-ops-auth.tlstore" );
113- if not auth then
114- auth = {}
115- end
116- local time_alert , time_alert_size = read (" tl-ops-time-alert.tlstore" );
117- if not time_alert then
118- time_alert = {}
51+ local Router = function ()
52+ ngx .req .read_body ()
53+ local args = ngx .req .get_post_args ()
54+
55+ local page = args .page
56+ if not page then
57+ page = 1
11958 end
120- local time_alert , time_alert_size = read (" tl-ops-time-alert.tlstore" );
121- if not time_alert then
122- time_alert = {}
59+ page = tonumber (page )
60+
61+ local limit = args .limit
62+ if not limit then
63+ limit = # store_list
12364 end
65+ limit = tonumber (limit )
66+
67+ local start = (page - 1 ) * limit + 1
68+ local tail = page * limit
12469
125- local res_data = {
126- api = {
127- id = 1 ,
128- name = " tl-ops-balance-api.tlstore" ,
129- size = api_size ,
130- version = # api_content / 2 ,
131- list = api_content ,
132- },
133- body = {
134- id = 1 ,
135- name = " tl-ops-balance-body.tlstore" ,
136- size = body_size ,
137- version = # body_content / 2 ,
138- list = body_content ,
139- },
140- cookie = {
141- id = 2 ,
142- name = " tl-ops-balance-cookie.tlstore" ,
143- size = cookie_size ,
144- version = # cookie_content / 2 ,
145- list = cookie_content ,
146- },
147- header = {
148- id = 3 ,
149- name = " tl-ops-balance-header.tlstore" ,
150- size = header_size ,
151- version = # header_content / 2 ,
152- list = header_content ,
153- },
154- param = {
155- id = 4 ,
156- name = " tl-ops-balance-param.tlstore" ,
157- size = param_size ,
158- version = # param_content / 2 ,
159- list = param_content ,
160- },
161- service = {
162- id = 5 ,
163- name = " tl-ops-service.tlstore" ,
164- size = service_size ,
165- version = # service_content / 2 ,
166- list = service_content ,
167- },
168- health = {
169- id = 6 ,
170- name = " tl-ops-health.tlstore" ,
171- size = health_size ,
172- version = # health_content ,
173- list = health_content ,
174- },
175- limit = {
176- id = 7 ,
177- name = " tl-ops-limit.tlstore" ,
178- size = limit_size ,
179- version = # limit_content / 3 ,
180- list = limit_content ,
181- },
182- plugins_manage = {
183- id = 8 ,
184- name = " tl-ops-plugins-manage.tlstore" ,
185- size = plugins_manage_size ,
186- version = # plugins_manage_content ,
187- list = plugins_manage_content ,
188- },
189- balance = {
190- id = 8 ,
191- name = " tl-ops-balance.tlstore" ,
192- size = balance_size ,
193- version = # balance_content ,
194- list = balance_content ,
195- },
196- waf = {
197- id = 9 ,
198- name = " tl-ops-waf.tlstore" ,
199- size = waf_size ,
200- version = # waf_content ,
201- list = waf_content ,
202- },
203- waf_api = {
204- id = 10 ,
205- name = " tl-ops-waf-api.tlstore" ,
206- size = waf_api_size ,
207- version = # waf_api_content ,
208- list = waf_api_content ,
209- },
210- waf_ip = {
211- id = 11 ,
212- name = " tl-ops-waf-ip.tlstore" ,
213- size = waf_ip_size ,
214- version = # waf_ip_content ,
215- list = waf_ip_content ,
216- },
217- waf_cookie = {
218- id = 12 ,
219- name = " tl-ops-waf-cookie.tlstore" ,
220- size = waf_cookie_size ,
221- version = # waf_cookie_content ,
222- list = waf_cookie_content ,
223- },
224- waf_param = {
225- id = 13 ,
226- name = " tl-ops-waf-param.tlstore" ,
227- size = waf_param_size ,
228- version = # waf_param_content ,
229- list = waf_param_content ,
230- },
231- waf_header = {
232- id = 14 ,
233- name = " tl-ops-waf-header.tlstore" ,
234- size = waf_header_size ,
235- version = # waf_header_content ,
236- list = waf_header_content ,
237- },
238- waf_cc = {
239- id = 15 ,
240- name = " tl-ops-waf-cc.tlstore" ,
241- size = waf_cc_size ,
242- version = # waf_cc_content ,
243- list = waf_cc_content ,
244- },
245- auth = {
246- id = 16 ,
247- name = " tl-ops-auth.tlstore" ,
248- size = auth_size ,
249- version = # auth ,
250- list = auth ,
251- },
252- time_alert = {
253- id = 17 ,
254- name = " tl-ops-time-alert.tlstore" ,
255- size = time_alert_size ,
256- version = # time_alert ,
257- list = time_alert ,
258- }
70+ local res_data = {
71+ count = # store_list ,
72+ list = {}
25973 }
26074
75+ for index , value in ipairs (store_list ) do
76+ if index >= start and index <= tail then
77+ local name = value .. " .tlstore" ;
78+ local content , size = read (name );
79+ if not content then
80+ content = {}
81+ end
82+ table.insert (res_data .list , {
83+ id = index ,
84+ name = value .. " .tlstore" ,
85+ size = size ,
86+ version = " 暂不统计" ,
87+ list = content ,
88+ })
89+ end
90+ end
91+
26192 tl_ops_utils_func :set_ngx_req_return_ok (tl_ops_rt .ok , " success" , res_data );
26293 end
263-
94+
95+
26496return Router
0 commit comments