freewifi 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.idea/freewifi.iml +1 -1
- data/.idea/workspace.xml +87 -347
- data/lib/freewifi.rb +1 -7
- data/lib/freewifi/cisco/any/cisco_schemes_conf_gen.rb +2 -1
- data/lib/freewifi/cisco/iwag/iwag_telnet_connector.rb +19 -5
- data/lib/freewifi/config.rb +1 -0
- data/lib/freewifi/general/wifi_portal_procedures.rb +346 -385
- data/lib/freewifi/mikrotik/automation/get_data_ssh_fun.rb +2 -0
- data/lib/freewifi/mikrotik/newhub_mtik_api.rb +4 -2
- data/lib/freewifi/version.rb +1 -1
- metadata +3 -2
data/lib/freewifi.rb
CHANGED
@@ -273,8 +273,6 @@ class PortalFwifi_1
|
|
273
273
|
:mtik_user,
|
274
274
|
:mtik_password,
|
275
275
|
:mongo_connector_wifi_1,
|
276
|
-
:remote_ip,
|
277
|
-
:real_ip,
|
278
276
|
:telegram_api_url,
|
279
277
|
:telegram_chat_id,
|
280
278
|
:mongo_ip,
|
@@ -297,8 +295,6 @@ class PortalFwifi_1
|
|
297
295
|
mongo_ip,
|
298
296
|
mongo_port,
|
299
297
|
mongo_database,
|
300
|
-
remote_ip,
|
301
|
-
real_ip,
|
302
298
|
hua_wlc_1_ip,
|
303
299
|
hua_wlc_2_ip,
|
304
300
|
hua_wlc_login,
|
@@ -326,8 +322,6 @@ class PortalFwifi_1
|
|
326
322
|
@mtik_control_ips_get = mtik_control_ips_get
|
327
323
|
@mtik_user = mtik_user
|
328
324
|
@mtik_password = mtik_password
|
329
|
-
@remote_ip = remote_ip
|
330
|
-
@real_ip = real_ip
|
331
325
|
@additional_func_wifi_1 = InternalFunc_1.new
|
332
326
|
@telegram_api_url = telegram_api_url
|
333
327
|
@telegram_chat_id = telegram_chat_id
|
@@ -337,7 +331,7 @@ class PortalFwifi_1
|
|
337
331
|
end
|
338
332
|
|
339
333
|
|
340
|
-
def wifi_get_subs_info_return_1(ipaddress)
|
334
|
+
def wifi_get_subs_info_return_1(ipaddress, remote_ip, real_ip)
|
341
335
|
input_params = {:ipaddress => ipaddress}
|
342
336
|
output_params = {}
|
343
337
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net-telnet'
|
2
2
|
require 'net/ssh'
|
3
|
+
require 'date'
|
3
4
|
|
4
5
|
class CSRtelnet_1
|
5
6
|
|
@@ -15,17 +16,19 @@ class CSRtelnet_1
|
|
15
16
|
|
16
17
|
subscribers_mac = ""
|
17
18
|
|
18
|
-
begin
|
19
|
+
#begin
|
19
20
|
|
20
21
|
dump =""
|
21
|
-
connection = Net::Telnet.new( "Host" =>
|
22
|
+
connection = Net::Telnet.new( "Host" => iwag1_host, "Timeout" => false, "Prompt" => /.*\#/ ) { |str| }
|
22
23
|
connection.login({ "Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/ }) { |str| }
|
23
24
|
connection.cmd("show ip dhcp binding #{ipaddress}") {
|
24
25
|
|c|
|
26
|
+
p c
|
25
27
|
dump << c
|
26
28
|
}
|
27
29
|
connection.close
|
28
30
|
as = dump.split("\n")
|
31
|
+
p as
|
29
32
|
reer = as[4].split(" ")
|
30
33
|
|
31
34
|
ma = reer[1].to_s.upcase
|
@@ -37,15 +40,26 @@ class CSRtelnet_1
|
|
37
40
|
end
|
38
41
|
|
39
42
|
|
40
|
-
rescue
|
41
|
-
|
42
|
-
end
|
43
|
+
#rescue
|
44
|
+
# subscribers_mac = "unknown"
|
45
|
+
#end
|
43
46
|
|
44
47
|
return subscribers_mac
|
45
48
|
|
46
49
|
end
|
47
50
|
|
48
51
|
|
52
|
+
#test function. Not used
|
53
|
+
def get_iwag_info_ssh_1(ipaddress)
|
54
|
+
p DateTime.now
|
55
|
+
Net::SSH.start(iwag1_host, iwag_username, :password => iwag_password) do |ssh|
|
56
|
+
result = ssh.exec!("show ip dhcp binding #{ipaddress}\n")
|
57
|
+
p result
|
58
|
+
end
|
59
|
+
p DateTime.now
|
60
|
+
end
|
61
|
+
|
62
|
+
|
49
63
|
|
50
64
|
def return_iwag_access_interface_1(ipaddress)
|
51
65
|
host_iwag = iwag1_host
|
data/lib/freewifi/config.rb
CHANGED
@@ -69,6 +69,7 @@ class WiFiPortal_1
|
|
69
69
|
|
70
70
|
def get_subs_add_info3_1(ipaddress, access_interface)
|
71
71
|
|
72
|
+
|
72
73
|
answer = ""
|
73
74
|
|
74
75
|
#region get additional information
|
@@ -79,8 +80,8 @@ class WiFiPortal_1
|
|
79
80
|
begin
|
80
81
|
|
81
82
|
dump =""
|
82
|
-
connection = Net::Telnet.new(
|
83
|
-
connection.login({
|
83
|
+
connection = Net::Telnet.new("Host" => "172.24.247.183", "Timeout" => false, "Prompt" => /.*\#/) {|str|}
|
84
|
+
connection.login({"Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/}) {|str|}
|
84
85
|
connection.cmd("show ip dhcp binding #{ipaddress}") {
|
85
86
|
|c|
|
86
87
|
dump << c
|
@@ -97,11 +98,11 @@ class WiFiPortal_1
|
|
97
98
|
subscribers_mac = ma[0]+ma[1]+":"+ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]
|
98
99
|
end
|
99
100
|
|
100
|
-
|
101
101
|
rescue
|
102
102
|
subscribers_mac = "unknown"
|
103
103
|
end
|
104
104
|
|
105
|
+
|
105
106
|
begin
|
106
107
|
thr0 = Thread.new do
|
107
108
|
begin
|
@@ -193,7 +194,7 @@ class WiFiPortal_1
|
|
193
194
|
thr4.join
|
194
195
|
|
195
196
|
if answer==""
|
196
|
-
answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown"
|
197
|
+
answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown"
|
197
198
|
end
|
198
199
|
|
199
200
|
end
|
@@ -204,8 +205,15 @@ class WiFiPortal_1
|
|
204
205
|
end
|
205
206
|
|
206
207
|
|
208
|
+
def get_subs_add_info4new_1(access_interface, subscribers_mac)
|
207
209
|
|
208
|
-
|
210
|
+
capsman_list = [
|
211
|
+
"172.24.247.15",
|
212
|
+
"172.24.214.155",
|
213
|
+
"172.24.214.140",
|
214
|
+
"172.24.214.105",
|
215
|
+
"172.24.223.105"
|
216
|
+
]
|
209
217
|
|
210
218
|
answer = ""
|
211
219
|
|
@@ -214,450 +222,403 @@ class WiFiPortal_1
|
|
214
222
|
|
215
223
|
p subscribers_mac
|
216
224
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
225
|
+
threads_mikro_wlc = []
|
226
|
+
capsman_list.each do |capsman|
|
227
|
+
threads_mikro_wlc << Thread.new do
|
228
|
+
begin
|
229
|
+
p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, capsman)
|
230
|
+
splitting5 = mikr_info5.split("---")
|
231
|
+
if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
|
232
|
+
answer = mikr_info5
|
233
|
+
p answer
|
234
|
+
end
|
235
|
+
rescue
|
236
|
+
p "thr0 wrong"
|
223
237
|
end
|
224
|
-
rescue
|
225
|
-
p "thr0 wrong"
|
226
238
|
end
|
227
239
|
end
|
240
|
+
threads_mikro_wlc.each(&:join)
|
228
241
|
|
229
|
-
|
230
|
-
|
231
|
-
p mikr_info7 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.214.155")
|
232
|
-
splitting7 = mikr_info7.split("---")
|
233
|
-
if splitting7[1] != "not on mikrotik controller" && splitting7[1]!="unknown" && splitting7[1]!=nil
|
234
|
-
answer = mikr_info7
|
235
|
-
end
|
236
|
-
rescue
|
237
|
-
p "thr1 wrong"
|
238
|
-
end
|
242
|
+
if answer==""
|
243
|
+
answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown"
|
239
244
|
end
|
245
|
+
end
|
246
|
+
answer
|
247
|
+
end
|
240
248
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
249
|
+
def proc_100_71_0_0(ip_address)
|
250
|
+
begin
|
251
|
+
p access_int = iwag_telnet_connector.return_iwag_access_interface_1(ip_address)
|
252
|
+
|
253
|
+
ip_a = ip_address
|
254
|
+
|
255
|
+
access_poi = "unknown"
|
256
|
+
ssid_a = "unknown"
|
257
|
+
tx_rate_se = "unknown"
|
258
|
+
tx_rat = "unknown"
|
259
|
+
rx_rat = "unknown"
|
260
|
+
rx_signa = "unknown"
|
261
|
+
uptim = "unknown"
|
262
|
+
packet = "unknown"
|
263
|
+
byt = "unknown"
|
264
|
+
|
265
|
+
if access_int == "Tunnel5"
|
266
|
+
mikr_info2 = self.get_subs_add_info3_1(ip_address, access_int)
|
267
|
+
splitting2 = mikr_info2.split("---")
|
268
|
+
subs_mac = splitting2[0]
|
269
|
+
access_poi = "belrw_3_Cisco_ap1-1"
|
270
|
+
ssid_a = "BelRW_WiFi"
|
271
|
+
tx_rate_se = "unknown"
|
272
|
+
tx_rat = "unknown"
|
273
|
+
rx_rat = "unknown"
|
274
|
+
rx_signa = "unknown"
|
275
|
+
uptim = "unknown"
|
276
|
+
packet = "unknown"
|
277
|
+
byt = "unknown"
|
278
|
+
elsif access_int == "GigabitEthernet2.4008"
|
279
|
+
mikr_info3 = self.get_subs_add_info3_1(ip_address, access_int)
|
280
|
+
splitting3 = mikr_info3.split("---")
|
281
|
+
subs_mac = splitting3[0]
|
282
|
+
access_poi = "belrw_4_HP_ap1-1"
|
283
|
+
ssid_a = "BelRW_WiFi"
|
284
|
+
tx_rate_se = "unknown"
|
285
|
+
tx_rat = "unknown"
|
286
|
+
rx_rat = "unknown"
|
287
|
+
rx_signa = "unknown"
|
288
|
+
uptim = "unknown"
|
289
|
+
packet = "unknown"
|
290
|
+
byt = "unknown"
|
291
|
+
elsif access_int == "Tunnel9"
|
292
|
+
subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
|
293
|
+
p resp1 = hua_controller_connector.get_sub_info_1(subs_mac)
|
294
|
+
p resp=resp1.split(",,,")
|
295
|
+
|
296
|
+
p access_poi = resp[1]
|
297
|
+
p ssid_a = resp[2]
|
298
|
+
p tx_rate_se = resp[3]
|
299
|
+
p tx_rat = resp[4]
|
300
|
+
p rx_rat = resp[5]
|
301
|
+
p rx_signa = resp[6]
|
302
|
+
p uptim = resp[7]
|
303
|
+
p packet = resp[8]
|
304
|
+
p byt = resp[9]
|
305
|
+
elsif access_int == "Tunnel16"
|
306
|
+
subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
|
307
|
+
p resp1 = hua_controller_connector.get_sub_info2_1(subs_mac)
|
308
|
+
p resp=resp1.split(",,,")
|
309
|
+
|
310
|
+
p access_poi = resp[1]
|
311
|
+
p ssid_a = resp[2]
|
312
|
+
p tx_rate_se = resp[3]
|
313
|
+
p tx_rat = resp[4]
|
314
|
+
p rx_rat = resp[5]
|
315
|
+
p rx_signa = resp[6]
|
316
|
+
p uptim = resp[7]
|
317
|
+
p packet = resp[8]
|
318
|
+
p byt = resp[9]
|
319
|
+
else
|
320
|
+
p "before get info"
|
321
|
+
p mikr_info5 = self.get_subs_add_info3_1(ip_address, access_int)
|
322
|
+
p "after get info"
|
323
|
+
splitting5 = mikr_info5.split("---")
|
324
|
+
p subs_mac = splitting5[0]
|
325
|
+
|
326
|
+
p access_poi = splitting5[1]
|
327
|
+
p ssid_a = splitting5[2]
|
328
|
+
p tx_rate_se = splitting5[3]
|
329
|
+
p tx_rat = splitting5[4]
|
330
|
+
p rx_rat = splitting5[5]
|
331
|
+
p rx_signa = splitting5[6]
|
332
|
+
p uptim = splitting5[7]
|
333
|
+
p packet = splitting5[8]
|
334
|
+
p byt = splitting5[9]
|
335
|
+
|
336
|
+
|
337
|
+
if access_poi==nil || access_poi=="" || access_poi=="unknown"
|
338
|
+
access_poi = "not on mikrotik controller"
|
250
339
|
end
|
251
|
-
end
|
252
340
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
rescue
|
263
|
-
p "thr3 wrong"
|
264
|
-
end
|
341
|
+
if ssid_a==nil || ssid_a=="" || ssid_a=="unknown"
|
342
|
+
ssid_a = "unknown"
|
343
|
+
tx_rate_se = "unknown"
|
344
|
+
tx_rat = "unknown"
|
345
|
+
rx_rat = "unknown"
|
346
|
+
rx_signa = "unknown"
|
347
|
+
uptim = "unknown"
|
348
|
+
packet = "unknown"
|
349
|
+
byt = "unknown"
|
265
350
|
end
|
266
|
-
rescue
|
267
|
-
p "thread 3 failed"
|
268
|
-
end
|
269
351
|
|
270
|
-
begin
|
271
|
-
thr4 = Thread.new do
|
272
|
-
begin
|
273
|
-
p mikr_info9 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.223.105")
|
274
|
-
splitting9 = mikr_info9.split("---")
|
275
|
-
if splitting9[1] != "not on mikrotik controller" && splitting9[1]!="unknown" && splitting9[1]!=nil
|
276
|
-
answer = mikr_info9
|
277
|
-
end
|
278
|
-
rescue
|
279
|
-
p "thr4 wrong"
|
280
|
-
end
|
281
|
-
end
|
282
|
-
rescue
|
283
|
-
p "thread 4 failed"
|
284
352
|
end
|
285
353
|
|
286
|
-
|
287
|
-
|
288
|
-
thr2.join
|
289
|
-
thr3.join
|
290
|
-
thr4.join
|
291
|
-
|
292
|
-
if answer==""
|
293
|
-
answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown"
|
354
|
+
if subs_mac=="unknown"
|
355
|
+
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
294
356
|
end
|
295
357
|
|
296
|
-
|
358
|
+
if subs_mac==""
|
359
|
+
subs_mac="unknown"
|
360
|
+
end
|
297
361
|
|
298
362
|
|
299
|
-
|
363
|
+
mess = {:iwag_access_interface => access_int,
|
364
|
+
:subscribers_mac => subs_mac,
|
365
|
+
:access_point => access_poi,
|
366
|
+
:ssid_ap => ssid_a,
|
367
|
+
:apid => "unknown",
|
368
|
+
:statistics =>
|
369
|
+
{:tx_rate_set => tx_rate_se,
|
370
|
+
:tx_rate => tx_rat,
|
371
|
+
:rx_rate => rx_rat,
|
372
|
+
:rx_signal => rx_signa,
|
373
|
+
:uptime => uptim,
|
374
|
+
:packets => packet,
|
375
|
+
:bytes => byt}
|
376
|
+
}
|
377
|
+
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
378
|
+
output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
|
379
|
+
rescue
|
300
380
|
|
381
|
+
puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
|
382
|
+
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
383
|
+
end
|
384
|
+
output_params
|
301
385
|
end
|
302
386
|
|
387
|
+
def proc_100_75_0_0(ip_address)
|
303
388
|
|
389
|
+
begin
|
390
|
+
result_iwag = self.python_mac_iwag2_1(ip_address)
|
391
|
+
if result_iwag.split(" ")[0]!="Unknown"
|
392
|
+
ppp = result_iwag.split(" ")
|
393
|
+
|
394
|
+
subs_mac = ppp[0]
|
395
|
+
access_int = ppp[1]
|
396
|
+
access_poi = ppp[2]
|
397
|
+
ssid_a = ppp[3]
|
398
|
+
|
399
|
+
tx_rate_se = "unknown"
|
400
|
+
tx_rat = "unknown"
|
401
|
+
rx_rat = "unknown"
|
402
|
+
rx_signa = "unknown"
|
403
|
+
uptim = "unknown"
|
404
|
+
packet = "unknown"
|
405
|
+
byt = "unknown"
|
406
|
+
|
407
|
+
if access_int=='GigabitEthernet4.3002'
|
408
|
+
access_poi = "belrw_4_HP_ap1-1"
|
409
|
+
ssid_a = "BelRW_WiFi"
|
410
|
+
elsif access_int=='GigabitEthernet4.3005'
|
411
|
+
access_poi = "belbiz-AP1-1"
|
412
|
+
ssid_a = "IMAGURU_GUEST"
|
413
|
+
end
|
304
414
|
|
415
|
+
if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
|
416
|
+
frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
|
417
|
+
splitting5 = frommikrotik.split("---")
|
418
|
+
p access_poi = splitting5[1]
|
419
|
+
p ssid_a = splitting5[2]
|
420
|
+
p tx_rate_se = splitting5[3]
|
421
|
+
p tx_rat = splitting5[4]
|
422
|
+
p rx_rat = splitting5[5]
|
423
|
+
p rx_signa = splitting5[6]
|
424
|
+
p uptim = splitting5[7]
|
425
|
+
p packet = splitting5[8]
|
426
|
+
p byt = splitting5[9]
|
427
|
+
end
|
305
428
|
|
429
|
+
if subs_mac=="unknown"
|
430
|
+
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
431
|
+
end
|
306
432
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
output_params = {}
|
311
|
-
|
312
|
-
begin
|
313
|
-
ipaddr_full = ip_address
|
314
|
-
ipaddr1 = IPAddr.new ipaddr_full
|
315
|
-
p ipaddr2 = ipaddr1.mask(17).to_s
|
316
|
-
p ipaddr3 = ipaddr2.to_s
|
433
|
+
if subs_mac==""
|
434
|
+
subs_mac="unknown"
|
435
|
+
end
|
317
436
|
|
318
|
-
if ipaddr3=="100.71.0.0" #iwag old
|
319
437
|
|
320
|
-
|
321
|
-
|
438
|
+
mess = {:iwag_access_interface => access_int,
|
439
|
+
:subscribers_mac => subs_mac,
|
440
|
+
:access_point => access_poi,
|
441
|
+
:ssid_ap => ssid_a,
|
442
|
+
:apid => "unknown",
|
443
|
+
:statistics =>
|
444
|
+
{:tx_rate_set => tx_rate_se,
|
445
|
+
:tx_rate => tx_rat,
|
446
|
+
:rx_rate => rx_rat,
|
447
|
+
:rx_signal => rx_signa,
|
448
|
+
:uptime => uptim,
|
449
|
+
:packets => packet,
|
450
|
+
:bytes => byt}
|
451
|
+
}
|
452
|
+
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
453
|
+
output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
|
454
|
+
p output_params
|
322
455
|
|
323
|
-
|
456
|
+
else
|
324
457
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
458
|
+
mess = {:iwag_access_interface => "unknown",
|
459
|
+
:subscribers_mac => "unknown",
|
460
|
+
:access_point => "unknown",
|
461
|
+
:ssid_ap => "unknown",
|
462
|
+
:apid => "unknown",
|
463
|
+
:statistics =>
|
464
|
+
{:tx_rate_set => "unknown",
|
465
|
+
:tx_rate => "unknown",
|
466
|
+
:rx_rate => "unknown",
|
467
|
+
:rx_signal => "unknown",
|
468
|
+
:uptime => "unknown",
|
469
|
+
:packets => "unknown",
|
470
|
+
:bytes => "unknown"}
|
471
|
+
}
|
472
|
+
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{params[:ipaddress]} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
473
|
+
output_params = {:code => 202, :result => "Request completed", :body => {:message => mess}}
|
474
|
+
p output_params
|
334
475
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
ssid_a = "BelRW_WiFi"
|
341
|
-
tx_rate_se = "unknown"
|
342
|
-
tx_rat = "unknown"
|
343
|
-
rx_rat = "unknown"
|
344
|
-
rx_signa = "unknown"
|
345
|
-
uptim = "unknown"
|
346
|
-
packet = "unknown"
|
347
|
-
byt = "unknown"
|
348
|
-
elsif access_int == "GigabitEthernet2.4008"
|
349
|
-
mikr_info3 = self.get_subs_add_info3_1(ip_address, access_int)
|
350
|
-
splitting3 = mikr_info3.split("---")
|
351
|
-
subs_mac = splitting3[0]
|
352
|
-
access_poi = "belrw_4_HP_ap1-1"
|
353
|
-
ssid_a = "BelRW_WiFi"
|
354
|
-
tx_rate_se = "unknown"
|
355
|
-
tx_rat = "unknown"
|
356
|
-
rx_rat = "unknown"
|
357
|
-
rx_signa = "unknown"
|
358
|
-
uptim = "unknown"
|
359
|
-
packet = "unknown"
|
360
|
-
byt = "unknown"
|
361
|
-
elsif access_int == "Tunnel9"
|
362
|
-
subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
|
363
|
-
p resp1 = hua_controller_connector.get_sub_info_1(subs_mac)
|
364
|
-
p resp=resp1.split(",,,")
|
365
|
-
|
366
|
-
p access_poi = resp[1]
|
367
|
-
p ssid_a = resp[2]
|
368
|
-
p tx_rate_se = resp[3]
|
369
|
-
p tx_rat = resp[4]
|
370
|
-
p rx_rat = resp[5]
|
371
|
-
p rx_signa = resp[6]
|
372
|
-
p uptim = resp[7]
|
373
|
-
p packet = resp[8]
|
374
|
-
p byt = resp[9]
|
375
|
-
elsif access_int == "Tunnel16"
|
376
|
-
subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
|
377
|
-
p resp1 = hua_controller_connector.get_sub_info2_1(subs_mac)
|
378
|
-
p resp=resp1.split(",,,")
|
379
|
-
|
380
|
-
p access_poi = resp[1]
|
381
|
-
p ssid_a = resp[2]
|
382
|
-
p tx_rate_se = resp[3]
|
383
|
-
p tx_rat = resp[4]
|
384
|
-
p rx_rat = resp[5]
|
385
|
-
p rx_signa = resp[6]
|
386
|
-
p uptim = resp[7]
|
387
|
-
p packet = resp[8]
|
388
|
-
p byt = resp[9]
|
389
|
-
else
|
390
|
-
p "before get info"
|
391
|
-
p mikr_info5 = self.get_subs_add_info3_1(ip_address, access_int)
|
392
|
-
p "after get info"
|
393
|
-
splitting5 = mikr_info5.split("---")
|
394
|
-
p subs_mac = splitting5[0]
|
476
|
+
end
|
477
|
+
rescue
|
478
|
+
puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
|
479
|
+
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
480
|
+
end
|
395
481
|
|
396
|
-
|
397
|
-
p ssid_a = splitting5[2]
|
398
|
-
p tx_rate_se = splitting5[3]
|
399
|
-
p tx_rat = splitting5[4]
|
400
|
-
p rx_rat = splitting5[5]
|
401
|
-
p rx_signa = splitting5[6]
|
402
|
-
p uptim = splitting5[7]
|
403
|
-
p packet = splitting5[8]
|
404
|
-
p byt = splitting5[9]
|
482
|
+
output_params
|
405
483
|
|
484
|
+
####
|
485
|
+
end
|
406
486
|
|
407
|
-
if access_poi==nil || access_poi=="" || access_poi=="unknown"
|
408
|
-
access_poi = "not on mikrotik controller"
|
409
|
-
end
|
410
487
|
|
411
|
-
|
412
|
-
|
413
|
-
tx_rate_se = "unknown"
|
414
|
-
tx_rat = "unknown"
|
415
|
-
rx_rat = "unknown"
|
416
|
-
rx_signa = "unknown"
|
417
|
-
uptim = "unknown"
|
418
|
-
packet = "unknown"
|
419
|
-
byt = "unknown"
|
420
|
-
end
|
488
|
+
def proc_100_70_0_0(ip_address)
|
489
|
+
p "min11iwag1"
|
421
490
|
|
422
|
-
|
491
|
+
begin
|
492
|
+
result_iwag = self.python_mac_iwag1_1(ip_address)
|
493
|
+
p result_iwag
|
494
|
+
if result_iwag.split(" ")[0]!="Unknown"
|
495
|
+
ppp = result_iwag.split(" ")
|
496
|
+
|
497
|
+
subs_mac = ppp[0]
|
498
|
+
access_int = ppp[1]
|
499
|
+
access_poi = ppp[2]
|
500
|
+
ssid_a = ppp[3]
|
501
|
+
|
502
|
+
|
503
|
+
if access_int=='GigabitEthernet4.3002'
|
504
|
+
access_poi = "belrw_4_HP_ap1-1"
|
505
|
+
ssid_a = "BelRW_WiFi"
|
506
|
+
elsif access_int=='GigabitEthernet4.3005'
|
507
|
+
access_poi = "belbiz-AP1-1"
|
508
|
+
ssid_a = "IMAGURU_GUEST"
|
509
|
+
end
|
423
510
|
|
424
|
-
|
425
|
-
|
426
|
-
|
511
|
+
if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
|
512
|
+
frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
|
513
|
+
splitting5 = frommikrotik.split("---")
|
514
|
+
p access_poi = splitting5[1]
|
515
|
+
p ssid_a = splitting5[2]
|
516
|
+
p tx_rate_se = splitting5[3]
|
517
|
+
p tx_rat = splitting5[4]
|
518
|
+
p rx_rat = splitting5[5]
|
519
|
+
p rx_signa = splitting5[6]
|
520
|
+
p uptim = splitting5[7]
|
521
|
+
p packet = splitting5[8]
|
522
|
+
p byt = splitting5[9]
|
523
|
+
end
|
427
524
|
|
428
|
-
|
429
|
-
|
430
|
-
|
525
|
+
tx_rate_se = "unknown"
|
526
|
+
tx_rat = "unknown"
|
527
|
+
rx_rat = "unknown"
|
528
|
+
rx_signa = "unknown"
|
529
|
+
uptim = "unknown"
|
530
|
+
packet = "unknown"
|
531
|
+
byt = "unknown"
|
431
532
|
|
533
|
+
if subs_mac=="unknown"
|
534
|
+
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
535
|
+
end
|
432
536
|
|
433
|
-
|
434
|
-
:subscribers_mac => subs_mac,
|
435
|
-
:access_point => access_poi,
|
436
|
-
:ssid_ap => ssid_a,
|
437
|
-
:apid => "unknown",
|
438
|
-
:statistics =>
|
439
|
-
{:tx_rate_set => tx_rate_se,
|
440
|
-
:tx_rate => tx_rat,
|
441
|
-
:rx_rate => rx_rat,
|
442
|
-
:rx_signal => rx_signa,
|
443
|
-
:uptime => uptim,
|
444
|
-
:packets => packet,
|
445
|
-
:bytes => byt}
|
446
|
-
}
|
447
|
-
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
448
|
-
render :soap => mess
|
449
|
-
rescue
|
450
|
-
|
451
|
-
puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
|
537
|
+
if subs_mac==""
|
452
538
|
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
453
539
|
end
|
454
540
|
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
packet = "unknown"
|
473
|
-
byt = "unknown"
|
474
|
-
|
475
|
-
if access_int=='GigabitEthernet4.3002'
|
476
|
-
access_poi = "belrw_4_HP_ap1-1"
|
477
|
-
ssid_a = "BelRW_WiFi"
|
478
|
-
elsif access_int=='GigabitEthernet4.3005'
|
479
|
-
access_poi = "belbiz-AP1-1"
|
480
|
-
ssid_a = "IMAGURU_GUEST"
|
481
|
-
end
|
541
|
+
mess = {:iwag_access_interface => access_int,
|
542
|
+
:subscribers_mac => subs_mac,
|
543
|
+
:access_point => access_poi,
|
544
|
+
:ssid_ap => ssid_a,
|
545
|
+
:apid => "unknown",
|
546
|
+
:statistics =>
|
547
|
+
{:tx_rate_set => tx_rate_se,
|
548
|
+
:tx_rate => tx_rat,
|
549
|
+
:rx_rate => rx_rat,
|
550
|
+
:rx_signal => rx_signa,
|
551
|
+
:uptime => uptim,
|
552
|
+
:packets => packet,
|
553
|
+
:bytes => byt}
|
554
|
+
}
|
555
|
+
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
556
|
+
output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
|
557
|
+
p output_params
|
482
558
|
|
483
|
-
|
484
|
-
frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
|
485
|
-
splitting5 = frommikrotik.split("---")
|
486
|
-
p access_poi = splitting5[1]
|
487
|
-
p ssid_a = splitting5[2]
|
488
|
-
p tx_rate_se = splitting5[3]
|
489
|
-
p tx_rat = splitting5[4]
|
490
|
-
p rx_rat = splitting5[5]
|
491
|
-
p rx_signa = splitting5[6]
|
492
|
-
p uptim = splitting5[7]
|
493
|
-
p packet = splitting5[8]
|
494
|
-
p byt = splitting5[9]
|
495
|
-
end
|
559
|
+
else
|
496
560
|
|
497
|
-
|
498
|
-
|
499
|
-
|
561
|
+
mess = {:iwag_access_interface => "unknown",
|
562
|
+
:subscribers_mac => "unknown",
|
563
|
+
:access_point => "unknown",
|
564
|
+
:ssid_ap => "unknown",
|
565
|
+
:apid => "unknown",
|
566
|
+
:statistics =>
|
567
|
+
{:tx_rate_set => "unknown",
|
568
|
+
:tx_rate => "unknown",
|
569
|
+
:rx_rate => "unknown",
|
570
|
+
:rx_signal => "unknown",
|
571
|
+
:uptime => "unknown",
|
572
|
+
:packets => "unknown",
|
573
|
+
:bytes => "unknown"}
|
574
|
+
}
|
500
575
|
|
501
|
-
|
502
|
-
subs_mac="unknown"
|
503
|
-
end
|
576
|
+
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
504
577
|
|
578
|
+
output_params = {:code => 405, :result => "ERROR. MAC address not found on IWAG."}
|
505
579
|
|
506
|
-
|
507
|
-
:subscribers_mac => subs_mac,
|
508
|
-
:access_point => access_poi,
|
509
|
-
:ssid_ap => ssid_a,
|
510
|
-
:apid => "unknown",
|
511
|
-
:statistics =>
|
512
|
-
{:tx_rate_set => tx_rate_se,
|
513
|
-
:tx_rate => tx_rat,
|
514
|
-
:rx_rate => rx_rat,
|
515
|
-
:rx_signal => rx_signa,
|
516
|
-
:uptime => uptim,
|
517
|
-
:packets => packet,
|
518
|
-
:bytes => byt}
|
519
|
-
}
|
520
|
-
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
521
|
-
output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
|
522
|
-
p output_params
|
523
|
-
|
524
|
-
else
|
525
|
-
|
526
|
-
mess = {:iwag_access_interface => "unknown",
|
527
|
-
:subscribers_mac => "unknown",
|
528
|
-
:access_point => "unknown",
|
529
|
-
:ssid_ap => "unknown",
|
530
|
-
:apid => "unknown",
|
531
|
-
:statistics =>
|
532
|
-
{:tx_rate_set => "unknown",
|
533
|
-
:tx_rate => "unknown",
|
534
|
-
:rx_rate => "unknown",
|
535
|
-
:rx_signal => "unknown",
|
536
|
-
:uptime => "unknown",
|
537
|
-
:packets => "unknown",
|
538
|
-
:bytes => "unknown"}
|
539
|
-
}
|
540
|
-
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{params[:ipaddress]} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
541
|
-
output_params = {:code => 202, :result => "Request completed", :body => {:message => mess}}
|
542
|
-
p output_params
|
580
|
+
#render :soap => mess
|
543
581
|
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
582
|
+
end
|
583
|
+
rescue
|
584
|
+
puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
|
585
|
+
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
586
|
+
end
|
549
587
|
|
550
|
-
|
551
|
-
elsif ipaddr3=="100.70.0.0" #min11iwag1
|
588
|
+
output_params
|
552
589
|
|
553
|
-
|
590
|
+
####
|
554
591
|
|
555
|
-
|
556
|
-
result_iwag = self.python_mac_iwag1_1(ip_address)
|
557
|
-
p result_iwag
|
558
|
-
if result_iwag.split(" ")[0]!="Unknown"
|
559
|
-
ppp = result_iwag.split(" ")
|
592
|
+
end
|
560
593
|
|
561
|
-
subs_mac = ppp[0]
|
562
|
-
access_int = ppp[1]
|
563
|
-
access_poi = ppp[2]
|
564
|
-
ssid_a = ppp[3]
|
565
594
|
|
595
|
+
def get_subs_info_return_1(ip_address)
|
566
596
|
|
567
|
-
|
568
|
-
|
569
|
-
ssid_a = "BelRW_WiFi"
|
570
|
-
elsif access_int=='GigabitEthernet4.3005'
|
571
|
-
access_poi = "belbiz-AP1-1"
|
572
|
-
ssid_a = "IMAGURU_GUEST"
|
573
|
-
end
|
597
|
+
input_params = {:ip_address => ip_address}
|
598
|
+
output_params = {}
|
574
599
|
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
p access_poi = splitting5[1]
|
579
|
-
p ssid_a = splitting5[2]
|
580
|
-
p tx_rate_se = splitting5[3]
|
581
|
-
p tx_rat = splitting5[4]
|
582
|
-
p rx_rat = splitting5[5]
|
583
|
-
p rx_signa = splitting5[6]
|
584
|
-
p uptim = splitting5[7]
|
585
|
-
p packet = splitting5[8]
|
586
|
-
p byt = splitting5[9]
|
587
|
-
end
|
600
|
+
begin
|
601
|
+
ipaddr_transformed = IPAddr.new ip_address
|
602
|
+
ipaddr_network = ipaddr_transformed.mask(17).to_s
|
588
603
|
|
589
|
-
|
590
|
-
tx_rat = "unknown"
|
591
|
-
rx_rat = "unknown"
|
592
|
-
rx_signa = "unknown"
|
593
|
-
uptim = "unknown"
|
594
|
-
packet = "unknown"
|
595
|
-
byt = "unknown"
|
604
|
+
if ipaddr_network == "100.71.0.0" #iwag old
|
596
605
|
|
597
|
-
|
598
|
-
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
599
|
-
end
|
606
|
+
output_params = self.proc_100_71_0_0(ip_address)
|
600
607
|
|
601
|
-
|
602
|
-
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
603
|
-
end
|
608
|
+
elsif ipaddr_network == "100.75.0.0" #min11iwag2
|
604
609
|
|
605
|
-
|
606
|
-
:subscribers_mac => subs_mac,
|
607
|
-
:access_point => access_poi,
|
608
|
-
:ssid_ap => ssid_a,
|
609
|
-
:apid => "unknown",
|
610
|
-
:statistics =>
|
611
|
-
{:tx_rate_set => tx_rate_se,
|
612
|
-
:tx_rate => tx_rat,
|
613
|
-
:rx_rate => rx_rat,
|
614
|
-
:rx_signal => rx_signa,
|
615
|
-
:uptime => uptim,
|
616
|
-
:packets => packet,
|
617
|
-
:bytes => byt}
|
618
|
-
}
|
619
|
-
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
620
|
-
output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
|
621
|
-
p output_params
|
622
|
-
|
623
|
-
else
|
624
|
-
|
625
|
-
mess = {:iwag_access_interface => "unknown",
|
626
|
-
:subscribers_mac => "unknown",
|
627
|
-
:access_point => "unknown",
|
628
|
-
:ssid_ap => "unknown",
|
629
|
-
:apid => "unknown",
|
630
|
-
:statistics =>
|
631
|
-
{:tx_rate_set => "unknown",
|
632
|
-
:tx_rate => "unknown",
|
633
|
-
:rx_rate => "unknown",
|
634
|
-
:rx_signal => "unknown",
|
635
|
-
:uptime => "unknown",
|
636
|
-
:packets => "unknown",
|
637
|
-
:bytes => "unknown"}
|
638
|
-
}
|
639
|
-
|
640
|
-
# logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller such information as: #{mess.to_xml}"
|
641
|
-
|
642
|
-
output_params = {:code => 405, :result => "ERROR. MAC address not found on IWAG."}
|
643
|
-
|
644
|
-
#render :soap => mess
|
610
|
+
output_params = self.proc_100_75_0_0(ip_address)
|
645
611
|
|
646
|
-
|
647
|
-
rescue
|
648
|
-
puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
|
649
|
-
output_params = {:code => 505, :result => "ERROR. Something wrong."}
|
650
|
-
end
|
612
|
+
elsif ipaddr_network == "100.70.0.0" #min11iwag1
|
651
613
|
|
652
|
-
|
614
|
+
output_params = self.proc_100_70_0_0(ip_address)
|
653
615
|
|
654
616
|
else
|
655
617
|
output_params = {:code => 404, :result => "ERROR. Unknown IP Pool."}
|
656
|
-
|
657
618
|
end
|
619
|
+
|
658
620
|
rescue
|
659
|
-
|
660
|
-
output_params = {:code => 500, :result => "ERROR. Something wrong."}
|
621
|
+
output_params = {:code => 500, :result => "ERROR. Something wrong.", :body => "SOAP mts_wifi_get_subs_info_return errorMethod unknown error"}
|
661
622
|
end
|
662
623
|
|
663
624
|
output_params
|