freewifi 0.1.8 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -66,8 +66,7 @@ module Freewifi_1
66
66
  capsman_password,
67
67
  hub_vip,
68
68
  ap_admin_password,
69
- capsman_ip_wifi
70
- )
69
+ capsman_ip_wifi)
71
70
 
72
71
  @mtik_hub1_ip = hub1ip
73
72
  @mtik_hub2_ip = hub2ip
@@ -87,8 +86,6 @@ module Freewifi_1
87
86
  @hub_vip = hub_vip
88
87
  @ap_admin_password = ap_admin_password
89
88
  @capsman_ip_wifi = capsman_ip_wifi
90
-
91
-
92
89
  end
93
90
 
94
91
 
@@ -268,18 +265,17 @@ end
268
265
 
269
266
  class PortalFwifi_1
270
267
 
271
- attr_accessor :apigw_wsdl,
272
- :apigw_endpoint,
273
- :apigw_namespace,
274
- :apigw_wsse_aut_log,
275
- :apigw_wsse_aut_pass,
276
- :general_procedures,
268
+ attr_accessor :general_procedures,
277
269
  :mtik_control_ips_get,
278
270
  :mtik_user,
279
271
  :mtik_password,
280
272
  :mongo_connector_wifi_1,
281
- :remote_ip,
282
- :real_ip
273
+ :telegram_api_url,
274
+ :telegram_chat_id,
275
+ :mongo_ip,
276
+ :mongo_port,
277
+ :mongo_database,
278
+ :additional_func_wifi_1
283
279
 
284
280
 
285
281
  def initialize(apigw_wsdl,
@@ -296,41 +292,108 @@ class PortalFwifi_1
296
292
  mongo_ip,
297
293
  mongo_port,
298
294
  mongo_database,
299
- remote_ip,
300
- real_ip,
301
295
  hua_wlc_1_ip,
302
296
  hua_wlc_2_ip,
303
297
  hua_wlc_login,
304
- hua_wlc_password
298
+ hua_wlc_password,
299
+ telegram_api_url,
300
+ telegram_chat_id,
301
+ iwag2_host,
302
+ iwag2_username,
303
+ iwag2_password,
304
+ iwag1_port=22,
305
+ iwag2_port=22
305
306
  )
306
307
 
307
- @apigw_wsdl = apigw_wsdl
308
- @apigw_endpoint = apigw_endpoint
309
- @apigw_namespace = apigw_namespace
310
- @apigw_wsse_aut_log = apigw_wsse_aut_log
311
- @apigw_wsse_aut_pass = apigw_wsse_aut_pass
312
- @general_procedures = WiFiPortal_1.new(apigw_wsdl, apigw_endpoint, apigw_namespace, apigw_wsse_aut_log, apigw_wsse_aut_pass, iwag1_host, iwag_username, iwag_password, mtik_control_ips_get, mtik_user, mtik_password, hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password)
308
+ @general_procedures = WiFiPortal_1.new(apigw_wsdl,
309
+ apigw_endpoint,
310
+ apigw_namespace,
311
+ apigw_wsse_aut_log,
312
+ apigw_wsse_aut_pass,
313
+ iwag1_host,
314
+ iwag_username,
315
+ iwag_password,
316
+ iwag1_port,
317
+ mtik_control_ips_get,
318
+ mtik_user,
319
+ mtik_password,
320
+ hua_wlc_1_ip,
321
+ hua_wlc_2_ip,
322
+ hua_wlc_login,
323
+ hua_wlc_password,
324
+ iwag2_host,
325
+ iwag2_username,
326
+ iwag2_password,
327
+ iwag2_port
328
+ )
313
329
  @mtik_control_ips_get = mtik_control_ips_get
314
330
  @mtik_user = mtik_user
315
331
  @mtik_password = mtik_password
316
- @mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database)
317
- @remote_ip = remote_ip
318
- @real_ip = real_ip
332
+ @additional_func_wifi_1 = InternalFunc_1.new
333
+ @telegram_api_url = telegram_api_url
334
+ @telegram_chat_id = telegram_chat_id
335
+ @mongo_ip = mongo_ip
336
+ @mongo_port = mongo_port
337
+ @mongo_database = mongo_database
319
338
  end
320
339
 
321
340
 
322
- def wifi_get_subs_info_return_1(ipaddress)
341
+ def wifi_get_subs_info_return_1(ipaddress, remote_ip, real_ip)
323
342
  input_params = {:ipaddress => ipaddress}
324
343
  output_params = {}
325
344
 
326
- begin
327
- resp_procedure = general_procedures.get_subs_info_return_1(ipaddress)
328
- output_params = resp_procedure
329
- rescue
330
- output_params = {:code => 507, :result => "Unknown SDK error"}
345
+ subs_info_ret_1_thr1 = Thread.new do
346
+ begin
347
+ resp_procedure = general_procedures.get_subs_info_return_1(ipaddress)
348
+ output_params = resp_procedure
349
+ rescue
350
+ output_params = {:code => 507, :result => "Unknown SDK error"}
351
+ end
352
+ end
353
+ subs_info_ret_1_thr1.join
354
+
355
+ subs_info_ret_1_thr2 = Thread.new do
356
+ begin
357
+ p "mongo"
358
+ #mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database)
359
+ #mongo_connector_wifi_1.audit_logger_wifi_portal_1("wifi_get_subs_info_return_1", remote_ip, input_params, output_params, real_ip)
360
+ rescue
361
+ additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => {:result => "mongo failed"}, :procedure => "wifi_get_subs_info_return_1", :file => "freewifi.rb"}, "debug")
362
+ additional_func_wifi_1.telegram_message_1("{:function => \"wifi_get_subs_info_return_1\", :result => \"failed communicate with mongo database\", :sdk => \"freewifi\"}", telegram_api_url, telegram_chat_id)
363
+ end
364
+ end
365
+ subs_info_ret_1_thr2.join
366
+
367
+ output_params
368
+ end
369
+
370
+
371
+ def wifi_get_subs_inf_ret_ssh_1(ipaddress, remote_ip, real_ip)
372
+ input_params = {:ipaddress => ipaddress}
373
+ output_params = {}
374
+
375
+ subs_info_ret_1_thr1 = Thread.new do
376
+ begin
377
+ resp_procedure = general_procedures.get_subs_info_ret_ssh_1(ipaddress)
378
+ output_params = resp_procedure
379
+ rescue
380
+ output_params = {:code => 507, :result => "Unknown SDK error"}
381
+ end
382
+ end
383
+ subs_info_ret_1_thr1.join
384
+
385
+ subs_info_ret_1_thr2 = Thread.new do
386
+ begin
387
+ p "mongo"
388
+ #mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database)
389
+ #mongo_connector_wifi_1.audit_logger_wifi_portal_1("wifi_get_subs_info_return_1", remote_ip, input_params, output_params, real_ip)
390
+ rescue
391
+ additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => {:result => "mongo failed"}, :procedure => "wifi_get_subs_info_return_1", :file => "freewifi.rb"}, "debug")
392
+ additional_func_wifi_1.telegram_message_1("{:function => \"wifi_get_subs_info_return_1\", :result => \"failed communicate with mongo database\", :sdk => \"freewifi\"}", telegram_api_url, telegram_chat_id)
393
+ end
331
394
  end
395
+ subs_info_ret_1_thr2.join
332
396
 
333
- mongo_connector_wifi_1.audit_logger_wifi_portal_1("wifi_get_subs_info_return_1", remote_ip, input_params, output_params, real_ip)
334
397
  output_params
335
398
  end
336
399
 
@@ -12,6 +12,25 @@ class InternalFunc_1
12
12
  d_curr.to_s
13
13
  end
14
14
 
15
+ def telegram_message_1(message, telegram_api_url, telegram_chat_id)
16
+ begin
17
+ uri = URI.parse(telegram_api_url)
18
+ https_connector = Net::HTTP.new(uri.host, uri.port)
19
+ https_connector.use_ssl = true
20
+ data = {chat_id: telegram_chat_id, text: message}
21
+ request_mess = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/json'})
22
+ request_mess.body = data.to_json
23
+ response_mess = https_connector.request(request_mess)
24
+ body = response_mess.body
25
+ return {:code => 200,
26
+ :result => "Request completed successfully",
27
+ :body => {:telegram_resp => JSON.parse(body.to_s),
28
+ :description => "Telegram message to telegram_chat_id: #{telegram_chat_id.to_s}"}}
29
+ rescue
30
+ return {:code => 507, :result => "Unknown SDK error"}
31
+ end
32
+ end
33
+
15
34
  def printer_texter_wifi_1(text, log_level)
16
35
  begin
17
36
  if log_level == "debug" && Freewifi_1::LOGLEVEL_1 == "debug"
@@ -9,4 +9,5 @@ class CiscoSchemesGen_1
9
9
 
10
10
  end
11
11
 
12
- end
12
+ end
13
+
@@ -0,0 +1,91 @@
1
+ require 'net/ssh'
2
+
3
+ class IwagRequester
4
+
5
+ attr_accessor :iwag_host, :iwag_login, :iwag_password, :iwag_port
6
+
7
+ def initialize(iwag_host, iwag_login, iwag_password, iwag_port)
8
+ @iwag_host = iwag_host
9
+ @iwag_login = iwag_login
10
+ @iwag_password = iwag_password
11
+ @iwag_port = iwag_port
12
+ end
13
+
14
+ def mac_parse(mac)
15
+ a = mac.upcase
16
+ pos = a[0] + a[1]
17
+ if pos == "01"
18
+ subscribers_mac = a[2] + a[3] + ":" + a[5] + a[6] + ":" + a[7] + a[8] + ":" + a[10] + a[11] + ":" + a[12] + a[13] + ":" + a[15] + a[16]
19
+ else
20
+ subscribers_mac = a[0] + a[1] + ":" + a[2] + a[3] + ":" + a[5] + a[6] + ":" + a[7] + a[8] + ":" + a[10] + a[11] + ":" + a[12] + a[13]
21
+ end
22
+ subscribers_mac
23
+ end
24
+
25
+
26
+ def iwag_get_dhcp_binding_ssh(bind_ip)
27
+ mac = "Unknown"
28
+ accessinterface = "Unknown"
29
+ hostname = "Unknown"
30
+ ssid = "Unknown"
31
+ iwag_thr = Thread.new do
32
+ Net::SSH.start(iwag_host, iwag_login, :password => iwag_password, :port=>iwag_port) do |session|
33
+ answ_bind = session.exec!("show ip dhcp binding #{bind_ip}")
34
+ regexp_main = /\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s{1,20}(\w{2,4}.\w{2,4}.\w{2,4}.\w{2,4})|\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s{1,20}(\w{4}.\w{4}.\w{4})/
35
+ #regexp_main = /\r\n(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s+(\S{13,18})\s+Sep 18 2020 07:44 PM\s+Automatic\s+Active\s+Tunnel201\r\n/
36
+ ggg7 = answ_bind.match(regexp_main)
37
+ begin
38
+ if ggg7[1] != nil
39
+ mac = mac_parse(ggg7[1])
40
+ else
41
+ mac = mac_parse(ggg7[2])
42
+ end
43
+ rescue
44
+ mac = "Unknown"
45
+ end
46
+ regexp_remote_id = /Remote id :\s(\S{2,100})/
47
+ regexp_tunnel = /Active\s{2,40}(\S{2,40})|Selecting\s{2,40}(\S{2,40})/
48
+ regexp_curcuit_id = /Circuit id :\s(\S{2,100})/
49
+ ggg9 = answ_bind.match(regexp_tunnel)
50
+
51
+ begin
52
+ if ggg9[1] != nil
53
+ accessinterface = ggg9[1]
54
+ else
55
+ accessinterface = ggg9[2]
56
+ end
57
+ rescue
58
+ accessinterface = "Unknown"
59
+ end
60
+ ggg8 = answ_bind.match(regexp_remote_id)
61
+ ggg10 = answ_bind.match(regexp_curcuit_id)
62
+ begin
63
+ a1 = ggg8[1].split(":")
64
+ hostname = a1[0]
65
+ ssid = a1[1]
66
+ rescue
67
+ begin
68
+ if ggg8[1] != nil
69
+ if ggg8[1].include?("wireless_public_interface")
70
+ hostname = ggg10[1]
71
+ ssid = "Unknown"
72
+ else
73
+ hostname = ggg8[1]
74
+ ssid = "Unknown"
75
+ end
76
+ else
77
+ ssid = "Unknown"
78
+ hostname = "Unknown"
79
+ end
80
+ rescue
81
+ ssid = "Unknown"
82
+ hostname = "Unknown"
83
+ end
84
+ end
85
+ end
86
+ end
87
+ iwag_thr.join
88
+ {"mac": mac, "iwaginterface": accessinterface, "aphostname": hostname, "SSID": ssid}
89
+ end
90
+
91
+ end
@@ -0,0 +1,24 @@
1
+
2
+
3
+ class IwagDbCache
4
+
5
+ attr_accessor :db_host, :db_login, :db_password
6
+
7
+ def initialize(db_host, db_login, db_password)
8
+ @db_host = db_host
9
+ @db_login = db_login
10
+ @db_password = db_password
11
+ end
12
+
13
+ def check_db_exists(ip)
14
+
15
+ end
16
+
17
+
18
+ def insert_new_cache()
19
+
20
+ end
21
+
22
+
23
+ end
24
+
@@ -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" => "172.24.247.183", "Timeout" => false, "Prompt" => /.*\#/ ) { |str| }
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
- subscribers_mac = "unknown"
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
@@ -1,4 +1,5 @@
1
1
  module Freewifi_1
2
2
  LOGLEVEL_1 = "debug"
3
+
3
4
  end
4
5
 
@@ -14,7 +14,7 @@ class MongoWifiCl_1
14
14
  @mongo_ip = mongo_ip
15
15
  @mongo_port = mongo_port
16
16
  client_host = [mongo_ip + ":" + mongo_port]
17
- @client = Mongo::Client.new(client_host, :database => mongo_database)
17
+ @client = Mongo::Client.new(client_host, :database => mongo_database, :connect_timeout => 2)
18
18
 
19
19
  @additional_func_1 = InternalFunc_1.new
20
20
  end
@@ -5,6 +5,7 @@ $LOAD_PATH.unshift File.expand_path("../huawei", __dir__)
5
5
  require 'freewifi/cisco/iwag/iwag_telnet_connector'
6
6
  require 'freewifi/mikrotik/newhub_mtik_api'
7
7
  require 'freewifi/huawei/hua_controller_class'
8
+ require 'freewifi/cisco/iwag/get_iwag_data'
8
9
  require 'rubygems'
9
10
  require 'savon'
10
11
 
@@ -18,29 +19,54 @@ class WiFiPortal_1
18
19
  :mtik_user,
19
20
  :mtik_password,
20
21
  :mtik_api_connector,
21
- :hua_controller_connector
22
-
23
- def initialize(apigw_wsdl, apigw_endpoint, apigw_namespace, apigw_wsse_aut_log, apigw_wsse_aut_pass, iwag1_host, iwag_username, iwag_password, mtik_control_ips_get, mtik_user, mtik_password, hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password)
24
- @iwag_telnet_connector = CSRtelnet_1.new(iwag1_host, iwag_username, iwag_password)
25
- @ard_api_gw_connector_wifi = Savon.client do
26
- #ssl_verify_mode :none
27
- wsdl apigw_wsdl
28
- endpoint apigw_endpoint
29
- namespace apigw_namespace
30
- wsse_auth(apigw_wsse_aut_log, apigw_wsse_aut_pass, :digest)
31
- encoding 'UTF-8'
32
- headers = {"Accept-Encoding" => "gzip, deflate", "Connection" => "Keep-Alive"}
33
- end
22
+ :hua_controller_connector,
23
+ :iwag_connector1,
24
+ :iwag_connector2
25
+
26
+ def initialize(apigw_wsdl,
27
+ apigw_endpoint,
28
+ apigw_namespace,
29
+ apigw_wsse_aut_log,
30
+ apigw_wsse_aut_pass,
31
+ iwag1_host,
32
+ iwag1_username,
33
+ iwag1_password,
34
+ iwag1_port,
35
+ mtik_control_ips_get,
36
+ mtik_user,
37
+ mtik_password,
38
+ hua_wlc_1_ip,
39
+ hua_wlc_2_ip,
40
+ hua_wlc_login,
41
+ hua_wlc_password,
42
+ iwag2_host,
43
+ iwag2_username,
44
+ iwag2_password,
45
+ iwag2_port
46
+ )
47
+ @iwag_telnet_connector = CSRtelnet_1.new(iwag1_host, iwag1_username, iwag1_password)
48
+ @ard_api_gw_connector_wifi = Savon.client do
49
+ #ssl_verify_mode :none
50
+ wsdl apigw_wsdl
51
+ endpoint apigw_endpoint
52
+ namespace apigw_namespace
53
+ wsse_auth(apigw_wsse_aut_log, apigw_wsse_aut_pass, :digest)
54
+ encoding 'UTF-8'
55
+ headers = {"Accept-Encoding" => "gzip, deflate", "Connection" => "Keep-Alive"}
56
+ end
34
57
 
35
- @iwag1_host = iwag1_host
36
- @iwag_username = iwag_username
37
- @iwag_password = iwag_password
58
+ @iwag1_host = iwag1_host
59
+ @iwag_username = iwag1_username
60
+ @iwag_password = iwag1_password
38
61
 
39
- @mtik_api_connector = NEWhubWifiApi_1.new(mtik_control_ips_get, mtik_user, mtik_password)
62
+ @mtik_api_connector = NEWhubWifiApi_1.new(mtik_control_ips_get, mtik_user, mtik_password)
40
63
 
41
- @hua_controller_connector = HuaWifi_1.new(hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password)
64
+ @hua_controller_connector = HuaWifi_1.new(hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password)
42
65
 
43
- end
66
+ @iwag_connector1 = IwagRequester.new(iwag1_host, iwag1_username, iwag1_password, iwag1_port)
67
+ @iwag_connector2 = IwagRequester.new(iwag2_host, iwag2_username, iwag2_password, iwag2_port)
68
+
69
+ end
44
70
 
45
71
 
46
72
  def python_mac_iwag1_1(ipaddress)
@@ -55,6 +81,16 @@ class WiFiPortal_1
55
81
  end
56
82
  end
57
83
 
84
+
85
+ def ssh_mac_iwag1_1(ipaddress)
86
+ begin
87
+ data_iw1 = iwag_connector1.iwag_get_dhcp_binding_ssh(ipaddress)
88
+ "#{data_iw1[:mac]} #{data_iw1[:iwaginterface]} #{data_iw1[:aphostname]} #{data_iw1[:SSID]}"
89
+ rescue
90
+ return "Unknown Unknown Unknown Unknown"
91
+ end
92
+ end
93
+
58
94
  def python_mac_iwag2_1(ipaddress)
59
95
  begin
60
96
  response = ard_api_gw_connector_wifi.call(:mts_python_mac_iwag2) do
@@ -67,8 +103,18 @@ class WiFiPortal_1
67
103
  end
68
104
  end
69
105
 
106
+ def ssh_mac_iwag2_1(ipaddress)
107
+ begin
108
+ data_iw1 = iwag_connector2.iwag_get_dhcp_binding_ssh(ipaddress)
109
+ "#{data_iw1[:mac]} #{data_iw1[:iwaginterface]} #{data_iw1[:aphostname]} #{data_iw1[:SSID]}"
110
+ rescue
111
+ return "Unknown Unknown Unknown Unknown"
112
+ end
113
+ end
114
+
70
115
  def get_subs_add_info3_1(ipaddress, access_interface)
71
116
 
117
+
72
118
  answer = ""
73
119
 
74
120
  #region get additional information
@@ -79,8 +125,8 @@ class WiFiPortal_1
79
125
  begin
80
126
 
81
127
  dump =""
82
- connection = Net::Telnet.new( "Host" => "172.24.247.183", "Timeout" => false, "Prompt" => /.*\#/ ) { |str| }
83
- connection.login({ "Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/ }) { |str| }
128
+ connection = Net::Telnet.new("Host" => "172.24.247.183", "Timeout" => false, "Prompt" => /.*\#/) {|str|}
129
+ connection.login({"Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/}) {|str|}
84
130
  connection.cmd("show ip dhcp binding #{ipaddress}") {
85
131
  |c|
86
132
  dump << c
@@ -97,11 +143,11 @@ class WiFiPortal_1
97
143
  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
144
  end
99
145
 
100
-
101
146
  rescue
102
147
  subscribers_mac = "unknown"
103
148
  end
104
149
 
150
+
105
151
  begin
106
152
  thr0 = Thread.new do
107
153
  begin
@@ -193,7 +239,7 @@ class WiFiPortal_1
193
239
  thr4.join
194
240
 
195
241
  if answer==""
196
- answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown"
242
+ answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown"
197
243
  end
198
244
 
199
245
  end
@@ -204,8 +250,15 @@ class WiFiPortal_1
204
250
  end
205
251
 
206
252
 
253
+ def get_subs_add_info4new_1(access_interface, subscribers_mac)
207
254
 
208
- def get_subs_add_info4new_1(access_interface,subscribers_mac)
255
+ capsman_list = [
256
+ "172.24.247.15",
257
+ "172.24.214.155",
258
+ "172.24.214.140",
259
+ "172.24.214.105",
260
+ "172.24.223.105"
261
+ ]
209
262
 
210
263
  answer = ""
211
264
 
@@ -214,115 +267,537 @@ class WiFiPortal_1
214
267
 
215
268
  p subscribers_mac
216
269
 
217
- thr0 = Thread.new do
218
- begin
219
- p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.247.15")
220
- splitting5 = mikr_info5.split("---")
221
- if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
222
- answer = mikr_info5
270
+ threads_mikro_wlc = []
271
+ capsman_list.each do |capsman|
272
+ threads_mikro_wlc << Thread.new do
273
+ begin
274
+ p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, capsman)
275
+ splitting5 = mikr_info5.split("---")
276
+ if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
277
+ answer = mikr_info5
278
+ p answer
279
+ end
280
+ rescue
281
+ p "thr0 wrong"
223
282
  end
224
- rescue
225
- p "thr0 wrong"
226
283
  end
227
284
  end
285
+ threads_mikro_wlc.each(&:join)
228
286
 
229
- thr1 = Thread.new do
230
- begin
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
287
+ if answer==""
288
+ answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown"
239
289
  end
290
+ end
291
+ answer
292
+ end
240
293
 
241
- thr2 = Thread.new do
242
- begin
243
- p mikr_info9 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.214.140")
244
- splitting9 = mikr_info9.split("---")
245
- if splitting9[1] != "not on mikrotik controller" && splitting9[1]!="unknown" && splitting9[1]!=nil
246
- answer = mikr_info9
247
- end
248
- rescue
249
- p "thr2 wrong"
294
+ def proc_100_71_0_0(ip_address)
295
+ begin
296
+ p access_int = iwag_telnet_connector.return_iwag_access_interface_1(ip_address)
297
+
298
+ ip_a = ip_address
299
+
300
+ access_poi = "unknown"
301
+ ssid_a = "unknown"
302
+ tx_rate_se = "unknown"
303
+ tx_rat = "unknown"
304
+ rx_rat = "unknown"
305
+ rx_signa = "unknown"
306
+ uptim = "unknown"
307
+ packet = "unknown"
308
+ byt = "unknown"
309
+
310
+ if access_int == "Tunnel5"
311
+ mikr_info2 = self.get_subs_add_info3_1(ip_address, access_int)
312
+ splitting2 = mikr_info2.split("---")
313
+ subs_mac = splitting2[0]
314
+ access_poi = "belrw_3_Cisco_ap1-1"
315
+ ssid_a = "BelRW_WiFi"
316
+ tx_rate_se = "unknown"
317
+ tx_rat = "unknown"
318
+ rx_rat = "unknown"
319
+ rx_signa = "unknown"
320
+ uptim = "unknown"
321
+ packet = "unknown"
322
+ byt = "unknown"
323
+ elsif access_int == "GigabitEthernet2.4008"
324
+ mikr_info3 = self.get_subs_add_info3_1(ip_address, access_int)
325
+ splitting3 = mikr_info3.split("---")
326
+ subs_mac = splitting3[0]
327
+ access_poi = "belrw_4_HP_ap1-1"
328
+ ssid_a = "BelRW_WiFi"
329
+ tx_rate_se = "unknown"
330
+ tx_rat = "unknown"
331
+ rx_rat = "unknown"
332
+ rx_signa = "unknown"
333
+ uptim = "unknown"
334
+ packet = "unknown"
335
+ byt = "unknown"
336
+ elsif access_int == "Tunnel9"
337
+ subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
338
+ p resp1 = hua_controller_connector.get_sub_info_1(subs_mac)
339
+ p resp=resp1.split(",,,")
340
+
341
+ p access_poi = resp[1]
342
+ p ssid_a = resp[2]
343
+ p tx_rate_se = resp[3]
344
+ p tx_rat = resp[4]
345
+ p rx_rat = resp[5]
346
+ p rx_signa = resp[6]
347
+ p uptim = resp[7]
348
+ p packet = resp[8]
349
+ p byt = resp[9]
350
+ elsif access_int == "Tunnel16"
351
+ subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
352
+ p resp1 = hua_controller_connector.get_sub_info2_1(subs_mac)
353
+ p resp=resp1.split(",,,")
354
+
355
+ p access_poi = resp[1]
356
+ p ssid_a = resp[2]
357
+ p tx_rate_se = resp[3]
358
+ p tx_rat = resp[4]
359
+ p rx_rat = resp[5]
360
+ p rx_signa = resp[6]
361
+ p uptim = resp[7]
362
+ p packet = resp[8]
363
+ p byt = resp[9]
364
+ else
365
+ p "before get info"
366
+ p mikr_info5 = self.get_subs_add_info3_1(ip_address, access_int)
367
+ p "after get info"
368
+ splitting5 = mikr_info5.split("---")
369
+ p subs_mac = splitting5[0]
370
+
371
+ p access_poi = splitting5[1]
372
+ p ssid_a = splitting5[2]
373
+ p tx_rate_se = splitting5[3]
374
+ p tx_rat = splitting5[4]
375
+ p rx_rat = splitting5[5]
376
+ p rx_signa = splitting5[6]
377
+ p uptim = splitting5[7]
378
+ p packet = splitting5[8]
379
+ p byt = splitting5[9]
380
+
381
+
382
+ if access_poi==nil || access_poi=="" || access_poi=="unknown"
383
+ access_poi = "not on mikrotik controller"
384
+ end
385
+
386
+ if ssid_a==nil || ssid_a=="" || ssid_a=="unknown"
387
+ ssid_a = "unknown"
388
+ tx_rate_se = "unknown"
389
+ tx_rat = "unknown"
390
+ rx_rat = "unknown"
391
+ rx_signa = "unknown"
392
+ uptim = "unknown"
393
+ packet = "unknown"
394
+ byt = "unknown"
250
395
  end
396
+
251
397
  end
252
398
 
399
+ if subs_mac=="unknown"
400
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
401
+ end
253
402
 
254
- begin
255
- thr3 = Thread.new do
256
- begin
257
- p mikr_info9 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.214.105")
258
- splitting9 = mikr_info9.split("---")
259
- if splitting9[1] != "not on mikrotik controller" && splitting9[1]!="unknown" && splitting9[1]!=nil
260
- answer = mikr_info9
261
- end
262
- rescue
263
- p "thr3 wrong"
264
- end
265
- end
266
- rescue
267
- p "thread 3 failed"
403
+ if subs_mac==""
404
+ subs_mac="unknown"
268
405
  end
269
406
 
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
407
+
408
+ mess = {:iwag_access_interface => access_int,
409
+ :subscribers_mac => subs_mac,
410
+ :access_point => access_poi,
411
+ :ssid_ap => ssid_a,
412
+ :apid => "unknown",
413
+ :statistics =>
414
+ {:tx_rate_set => tx_rate_se,
415
+ :tx_rate => tx_rat,
416
+ :rx_rate => rx_rat,
417
+ :rx_signal => rx_signa,
418
+ :uptime => uptim,
419
+ :packets => packet,
420
+ :bytes => byt}
421
+ }
422
+ # 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}"
423
+ output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
424
+ rescue
425
+
426
+ puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
427
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
428
+ end
429
+ output_params
430
+ end
431
+
432
+ def proc_100_75_0_0(ip_address)
433
+
434
+ begin
435
+ result_iwag = self.python_mac_iwag2_1(ip_address)
436
+ if result_iwag.split(" ")[0]!="Unknown"
437
+ ppp = result_iwag.split(" ")
438
+
439
+ subs_mac = ppp[0]
440
+ access_int = ppp[1]
441
+ access_poi = ppp[2]
442
+ ssid_a = ppp[3]
443
+
444
+ tx_rate_se = "unknown"
445
+ tx_rat = "unknown"
446
+ rx_rat = "unknown"
447
+ rx_signa = "unknown"
448
+ uptim = "unknown"
449
+ packet = "unknown"
450
+ byt = "unknown"
451
+
452
+ if access_int=='GigabitEthernet4.3002'
453
+ access_poi = "belrw_4_HP_ap1-1"
454
+ ssid_a = "BelRW_WiFi"
455
+ elsif access_int=='GigabitEthernet4.3005'
456
+ access_poi = "belbiz-AP1-1"
457
+ ssid_a = "IMAGURU_GUEST"
281
458
  end
282
- rescue
283
- p "thread 4 failed"
284
- end
285
459
 
286
- thr0.join
287
- thr1.join
288
- thr2.join
289
- thr3.join
290
- thr4.join
460
+ if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
461
+ frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
462
+ splitting5 = frommikrotik.split("---")
463
+ p access_poi = splitting5[1]
464
+ p ssid_a = splitting5[2]
465
+ p tx_rate_se = splitting5[3]
466
+ p tx_rat = splitting5[4]
467
+ p rx_rat = splitting5[5]
468
+ p rx_signa = splitting5[6]
469
+ p uptim = splitting5[7]
470
+ p packet = splitting5[8]
471
+ p byt = splitting5[9]
472
+ end
473
+
474
+ if subs_mac=="unknown"
475
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
476
+ end
477
+
478
+ if subs_mac==""
479
+ subs_mac="unknown"
480
+ end
481
+
482
+
483
+ mess = {:iwag_access_interface => access_int,
484
+ :subscribers_mac => subs_mac,
485
+ :access_point => access_poi,
486
+ :ssid_ap => ssid_a,
487
+ :apid => "unknown",
488
+ :statistics =>
489
+ {:tx_rate_set => tx_rate_se,
490
+ :tx_rate => tx_rat,
491
+ :rx_rate => rx_rat,
492
+ :rx_signal => rx_signa,
493
+ :uptime => uptim,
494
+ :packets => packet,
495
+ :bytes => byt}
496
+ }
497
+ # 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}"
498
+ output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
499
+ p output_params
500
+
501
+ else
502
+
503
+ mess = {:iwag_access_interface => "unknown",
504
+ :subscribers_mac => "unknown",
505
+ :access_point => "unknown",
506
+ :ssid_ap => "unknown",
507
+ :apid => "unknown",
508
+ :statistics =>
509
+ {:tx_rate_set => "unknown",
510
+ :tx_rate => "unknown",
511
+ :rx_rate => "unknown",
512
+ :rx_signal => "unknown",
513
+ :uptime => "unknown",
514
+ :packets => "unknown",
515
+ :bytes => "unknown"}
516
+ }
517
+ # 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}"
518
+ output_params = {:code => 202, :result => "Request completed", :body => {:message => mess}}
519
+ p output_params
291
520
 
292
- if answer==""
293
- answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown"
294
521
  end
522
+ rescue
523
+ puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
524
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
525
+ end
526
+
527
+ output_params
528
+
529
+ ####
530
+ end
531
+
532
+
533
+ def proc_100_70_0_0(ip_address)
534
+ p "min11iwag1"
535
+
536
+ begin
537
+ result_iwag = self.python_mac_iwag1_1(ip_address)
538
+ p result_iwag
539
+ if result_iwag.split(" ")[0]!="Unknown"
540
+ ppp = result_iwag.split(" ")
541
+
542
+ subs_mac = ppp[0]
543
+ access_int = ppp[1]
544
+ access_poi = ppp[2]
545
+ ssid_a = ppp[3]
546
+
547
+
548
+ if access_int=='GigabitEthernet4.3002'
549
+ access_poi = "belrw_4_HP_ap1-1"
550
+ ssid_a = "BelRW_WiFi"
551
+ elsif access_int=='GigabitEthernet4.3005'
552
+ access_poi = "belbiz-AP1-1"
553
+ ssid_a = "IMAGURU_GUEST"
554
+ end
555
+
556
+ if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
557
+ frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
558
+ splitting5 = frommikrotik.split("---")
559
+ p access_poi = splitting5[1]
560
+ p ssid_a = splitting5[2]
561
+ p tx_rate_se = splitting5[3]
562
+ p tx_rat = splitting5[4]
563
+ p rx_rat = splitting5[5]
564
+ p rx_signa = splitting5[6]
565
+ p uptim = splitting5[7]
566
+ p packet = splitting5[8]
567
+ p byt = splitting5[9]
568
+ end
569
+
570
+ tx_rate_se = "unknown"
571
+ tx_rat = "unknown"
572
+ rx_rat = "unknown"
573
+ rx_signa = "unknown"
574
+ uptim = "unknown"
575
+ packet = "unknown"
576
+ byt = "unknown"
295
577
 
578
+ if subs_mac=="unknown"
579
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
580
+ end
581
+
582
+ if subs_mac==""
583
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
584
+ end
585
+
586
+ mess = {:iwag_access_interface => access_int,
587
+ :subscribers_mac => subs_mac,
588
+ :access_point => access_poi,
589
+ :ssid_ap => ssid_a,
590
+ :apid => "unknown",
591
+ :statistics =>
592
+ {:tx_rate_set => tx_rate_se,
593
+ :tx_rate => tx_rat,
594
+ :rx_rate => rx_rat,
595
+ :rx_signal => rx_signa,
596
+ :uptime => uptim,
597
+ :packets => packet,
598
+ :bytes => byt}
599
+ }
600
+ # 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}"
601
+ output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
602
+ p output_params
603
+
604
+ else
605
+
606
+ mess = {:iwag_access_interface => "unknown",
607
+ :subscribers_mac => "unknown",
608
+ :access_point => "unknown",
609
+ :ssid_ap => "unknown",
610
+ :apid => "unknown",
611
+ :statistics =>
612
+ {:tx_rate_set => "unknown",
613
+ :tx_rate => "unknown",
614
+ :rx_rate => "unknown",
615
+ :rx_signal => "unknown",
616
+ :uptime => "unknown",
617
+ :packets => "unknown",
618
+ :bytes => "unknown"}
619
+ }
620
+
621
+ # 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}"
622
+
623
+ output_params = {:code => 405, :result => "ERROR. MAC address not found on IWAG."}
624
+
625
+ #render :soap => mess
626
+
627
+ end
628
+ rescue
629
+ puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
630
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
296
631
  end
297
632
 
633
+ output_params
298
634
 
299
- return answer
635
+ ####
300
636
 
301
637
  end
302
638
 
303
639
 
640
+ def get_subs_info_return_1(ip_address)
304
641
 
642
+ input_params = {:ip_address => ip_address}
643
+ output_params = {}
305
644
 
645
+ begin
646
+ ipaddr_transformed = IPAddr.new ip_address
647
+ ipaddr_network = ipaddr_transformed.mask(17).to_s
306
648
 
307
- def get_subs_info_return_1(ip_address)
649
+ if ipaddr_network == "100.71.0.0" #iwag old
650
+
651
+ output_params = self.proc_100_71_0_0(ip_address)
652
+
653
+ elsif ipaddr_network == "100.75.0.0" #min11iwag2
654
+
655
+ output_params = self.proc_100_75_0_0(ip_address)
656
+
657
+ elsif ipaddr_network == "100.70.0.0" #min11iwag1
658
+
659
+ output_params = self.proc_100_70_0_0(ip_address)
660
+
661
+ else
662
+ output_params = {:code => 404, :result => "ERROR. Unknown IP Pool."}
663
+ end
664
+
665
+ rescue
666
+ output_params = {:code => 500, :result => "ERROR. Something wrong.", :body => "SOAP mts_wifi_get_subs_info_return errorMethod unknown error"}
667
+ end
668
+
669
+ output_params
670
+
671
+ end
672
+
673
+
674
+ def get_subs_info_ret_ssh_1(ip_address)
308
675
 
309
676
  input_params = {:ip_address => ip_address}
310
677
  output_params = {}
311
678
 
312
679
  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
680
+ ipaddr_transformed = IPAddr.new ip_address
681
+ ipaddr_network = ipaddr_transformed.mask(17).to_s
682
+
683
+ if ipaddr_network == "100.71.0.0" #iwag old
684
+
685
+ output_params = self.proc_100_71_0_0_ssh(ip_address)
686
+
687
+ elsif ipaddr_network == "100.75.0.0" #min11iwag2
317
688
 
318
- if ipaddr3=="100.71.0.0" #iwag old
689
+ output_params = self.proc_100_75_0_0_ssh(ip_address)
319
690
 
320
- begin
321
- p access_int = iwag_telnet_connector.return_iwag_access_interface_1(ip_address)
691
+ elsif ipaddr_network == "100.70.0.0" #min11iwag1
322
692
 
323
- ip_a = ip_address
693
+ output_params = self.proc_100_70_0_0_ssh(ip_address)
694
+
695
+ else
696
+ output_params = {:code => 404, :result => "ERROR. Unknown IP Pool."}
697
+ end
698
+
699
+ rescue
700
+ output_params = {:code => 500, :result => "ERROR. Something wrong.", :body => "SOAP mts_wifi_get_subs_info_return errorMethod unknown error"}
701
+ end
702
+
703
+ output_params
704
+
705
+ end
706
+
707
+
708
+ def proc_100_71_0_0_ssh(ip_address)
709
+ begin
710
+ p access_int = iwag_telnet_connector.return_iwag_access_interface_1(ip_address)
711
+
712
+ ip_a = ip_address
713
+
714
+ access_poi = "unknown"
715
+ ssid_a = "unknown"
716
+ tx_rate_se = "unknown"
717
+ tx_rat = "unknown"
718
+ rx_rat = "unknown"
719
+ rx_signa = "unknown"
720
+ uptim = "unknown"
721
+ packet = "unknown"
722
+ byt = "unknown"
723
+
724
+ if access_int == "Tunnel5"
725
+ mikr_info2 = self.get_subs_add_info3_1(ip_address, access_int)
726
+ splitting2 = mikr_info2.split("---")
727
+ subs_mac = splitting2[0]
728
+ access_poi = "belrw_3_Cisco_ap1-1"
729
+ ssid_a = "BelRW_WiFi"
730
+ tx_rate_se = "unknown"
731
+ tx_rat = "unknown"
732
+ rx_rat = "unknown"
733
+ rx_signa = "unknown"
734
+ uptim = "unknown"
735
+ packet = "unknown"
736
+ byt = "unknown"
737
+ elsif access_int == "GigabitEthernet2.4008"
738
+ mikr_info3 = self.get_subs_add_info3_1(ip_address, access_int)
739
+ splitting3 = mikr_info3.split("---")
740
+ subs_mac = splitting3[0]
741
+ access_poi = "belrw_4_HP_ap1-1"
742
+ ssid_a = "BelRW_WiFi"
743
+ tx_rate_se = "unknown"
744
+ tx_rat = "unknown"
745
+ rx_rat = "unknown"
746
+ rx_signa = "unknown"
747
+ uptim = "unknown"
748
+ packet = "unknown"
749
+ byt = "unknown"
750
+ elsif access_int == "Tunnel9"
751
+ subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
752
+ p resp1 = hua_controller_connector.get_sub_info_1(subs_mac)
753
+ p resp=resp1.split(",,,")
754
+
755
+ p access_poi = resp[1]
756
+ p ssid_a = resp[2]
757
+ p tx_rate_se = resp[3]
758
+ p tx_rat = resp[4]
759
+ p rx_rat = resp[5]
760
+ p rx_signa = resp[6]
761
+ p uptim = resp[7]
762
+ p packet = resp[8]
763
+ p byt = resp[9]
764
+ elsif access_int == "Tunnel16"
765
+ subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
766
+ p resp1 = hua_controller_connector.get_sub_info2_1(subs_mac)
767
+ p resp=resp1.split(",,,")
768
+
769
+ p access_poi = resp[1]
770
+ p ssid_a = resp[2]
771
+ p tx_rate_se = resp[3]
772
+ p tx_rat = resp[4]
773
+ p rx_rat = resp[5]
774
+ p rx_signa = resp[6]
775
+ p uptim = resp[7]
776
+ p packet = resp[8]
777
+ p byt = resp[9]
778
+ else
779
+ p "before get info"
780
+ p mikr_info5 = self.get_subs_add_info3_1(ip_address, access_int)
781
+ p "after get info"
782
+ splitting5 = mikr_info5.split("---")
783
+ p subs_mac = splitting5[0]
784
+
785
+ p access_poi = splitting5[1]
786
+ p ssid_a = splitting5[2]
787
+ p tx_rate_se = splitting5[3]
788
+ p tx_rat = splitting5[4]
789
+ p rx_rat = splitting5[5]
790
+ p rx_signa = splitting5[6]
791
+ p uptim = splitting5[7]
792
+ p packet = splitting5[8]
793
+ p byt = splitting5[9]
794
+
795
+
796
+ if access_poi==nil || access_poi=="" || access_poi=="unknown"
797
+ access_poi = "not on mikrotik controller"
798
+ end
324
799
 
325
- access_poi = "unknown"
800
+ if ssid_a==nil || ssid_a=="" || ssid_a=="unknown"
326
801
  ssid_a = "unknown"
327
802
  tx_rate_se = "unknown"
328
803
  tx_rat = "unknown"
@@ -331,337 +806,248 @@ class WiFiPortal_1
331
806
  uptim = "unknown"
332
807
  packet = "unknown"
333
808
  byt = "unknown"
809
+ end
334
810
 
335
- if access_int == "Tunnel5"
336
- mikr_info2 = self.get_subs_add_info3_1(ip_address, access_int)
337
- splitting2 = mikr_info2.split("---")
338
- subs_mac = splitting2[0]
339
- access_poi = "belrw_3_Cisco_ap1-1"
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]
811
+ end
395
812
 
396
- p access_poi = splitting5[1]
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]
813
+ if subs_mac=="unknown"
814
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
815
+ end
405
816
 
817
+ if subs_mac==""
818
+ subs_mac="unknown"
819
+ end
406
820
 
407
- if access_poi==nil || access_poi=="" || access_poi=="unknown"
408
- access_poi = "not on mikrotik controller"
409
- end
410
821
 
411
- if ssid_a==nil || ssid_a=="" || ssid_a=="unknown"
412
- ssid_a = "unknown"
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
822
+ mess = {:iwag_access_interface => access_int,
823
+ :subscribers_mac => subs_mac,
824
+ :access_point => access_poi,
825
+ :ssid_ap => ssid_a,
826
+ :apid => "unknown",
827
+ :statistics =>
828
+ {:tx_rate_set => tx_rate_se,
829
+ :tx_rate => tx_rat,
830
+ :rx_rate => rx_rat,
831
+ :rx_signal => rx_signa,
832
+ :uptime => uptim,
833
+ :packets => packet,
834
+ :bytes => byt}
835
+ }
836
+ # 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}"
837
+ output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
838
+ rescue
421
839
 
422
- end
840
+ puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
841
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
842
+ end
843
+ output_params
844
+ end
423
845
 
424
- if subs_mac=="unknown"
425
- output_params = {:code => 505, :result => "ERROR. Something wrong."}
426
- end
846
+ def proc_100_75_0_0_ssh(ip_address)
427
847
 
428
- if subs_mac==""
429
- subs_mac="unknown"
430
- end
848
+ begin
849
+ result_iwag = self.ssh_mac_iwag2_1(ip_address)
850
+ if result_iwag.split(" ")[0]!="Unknown"
851
+ ppp = result_iwag.split(" ")
852
+
853
+ subs_mac = ppp[0]
854
+ access_int = ppp[1]
855
+ access_poi = ppp[2]
856
+ ssid_a = ppp[3]
857
+
858
+ tx_rate_se = "unknown"
859
+ tx_rat = "unknown"
860
+ rx_rat = "unknown"
861
+ rx_signa = "unknown"
862
+ uptim = "unknown"
863
+ packet = "unknown"
864
+ byt = "unknown"
865
+
866
+ if access_int=='GigabitEthernet4.3002'
867
+ access_poi = "belrw_4_HP_ap1-1"
868
+ ssid_a = "BelRW_WiFi"
869
+ elsif access_int=='GigabitEthernet4.3005'
870
+ access_poi = "belbiz-AP1-1"
871
+ ssid_a = "IMAGURU_GUEST"
872
+ end
431
873
 
874
+ if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
875
+ frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
876
+ splitting5 = frommikrotik.split("---")
877
+ p access_poi = splitting5[1]
878
+ p ssid_a = splitting5[2]
879
+ p tx_rate_se = splitting5[3]
880
+ p tx_rat = splitting5[4]
881
+ p rx_rat = splitting5[5]
882
+ p rx_signa = splitting5[6]
883
+ p uptim = splitting5[7]
884
+ p packet = splitting5[8]
885
+ p byt = splitting5[9]
886
+ end
432
887
 
433
- mess = {:iwag_access_interface => access_int,
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'
888
+ if subs_mac=="unknown"
452
889
  output_params = {:code => 505, :result => "ERROR. Something wrong."}
453
890
  end
454
891
 
455
- elsif ipaddr3=="100.75.0.0" #min11iwag2
456
-
457
- begin
458
- result_iwag = self.python_mac_iwag2_1(ip_address)
459
- if result_iwag.split(" ")[0]!="Unknown"
460
- ppp = result_iwag.split(" ")
461
-
462
- subs_mac = ppp[0]
463
- access_int = ppp[1]
464
- access_poi = ppp[2]
465
- ssid_a = ppp[3]
466
-
467
- tx_rate_se = "unknown"
468
- tx_rat = "unknown"
469
- rx_rat = "unknown"
470
- rx_signa = "unknown"
471
- uptim = "unknown"
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
482
-
483
- if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
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
496
-
497
- if subs_mac=="unknown"
498
- output_params = {:code => 505, :result => "ERROR. Something wrong."}
499
- end
500
-
501
- if subs_mac==""
502
- subs_mac="unknown"
503
- end
892
+ if subs_mac==""
893
+ subs_mac="unknown"
894
+ end
504
895
 
505
896
 
506
- mess = {:iwag_access_interface => access_int,
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
- }
897
+ mess = {:iwag_access_interface => access_int,
898
+ :subscribers_mac => subs_mac,
899
+ :access_point => access_poi,
900
+ :ssid_ap => ssid_a,
901
+ :apid => "unknown",
902
+ :statistics =>
903
+ {:tx_rate_set => tx_rate_se,
904
+ :tx_rate => tx_rat,
905
+ :rx_rate => rx_rat,
906
+ :rx_signal => rx_signa,
907
+ :uptime => uptim,
908
+ :packets => packet,
909
+ :bytes => byt}
910
+ }
520
911
  # 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
912
+ output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
913
+ p output_params
543
914
 
544
- end
545
- rescue
546
- puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
547
- output_params = {:code => 505, :result => "ERROR. Something wrong."}
548
- end
549
-
550
- ####
551
- elsif ipaddr3=="100.70.0.0" #min11iwag1
915
+ else
552
916
 
553
- p "min11iwag1"
917
+ mess = {:iwag_access_interface => "unknown",
918
+ :subscribers_mac => "unknown",
919
+ :access_point => "unknown",
920
+ :ssid_ap => "unknown",
921
+ :apid => "unknown",
922
+ :statistics =>
923
+ {:tx_rate_set => "unknown",
924
+ :tx_rate => "unknown",
925
+ :rx_rate => "unknown",
926
+ :rx_signal => "unknown",
927
+ :uptime => "unknown",
928
+ :packets => "unknown",
929
+ :bytes => "unknown"}
930
+ }
931
+ # 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}"
932
+ output_params = {:code => 202, :result => "Request completed", :body => {:message => mess}}
933
+ p output_params
554
934
 
555
- begin
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(" ")
935
+ end
936
+ rescue
937
+ puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
938
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
939
+ end
560
940
 
561
- subs_mac = ppp[0]
562
- access_int = ppp[1]
563
- access_poi = ppp[2]
564
- ssid_a = ppp[3]
941
+ output_params
565
942
 
943
+ ####
944
+ end
566
945
 
567
- if access_int=='GigabitEthernet4.3002'
568
- access_poi = "belrw_4_HP_ap1-1"
569
- ssid_a = "BelRW_WiFi"
570
- elsif access_int=='GigabitEthernet4.3005'
571
- access_poi = "belbiz-AP1-1"
572
- ssid_a = "IMAGURU_GUEST"
573
- end
574
946
 
575
- if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
576
- frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
577
- splitting5 = frommikrotik.split("---")
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
947
+ def proc_100_70_0_0_ssh(ip_address)
948
+ p "min11iwag1"
588
949
 
589
- tx_rate_se = "unknown"
590
- tx_rat = "unknown"
591
- rx_rat = "unknown"
592
- rx_signa = "unknown"
593
- uptim = "unknown"
594
- packet = "unknown"
595
- byt = "unknown"
950
+ begin
951
+ result_iwag = self.ssh_mac_iwag1_1(ip_address)
952
+ p result_iwag
953
+ if result_iwag.split(" ")[0]!="Unknown"
954
+ ppp = result_iwag.split(" ")
955
+
956
+ subs_mac = ppp[0]
957
+ access_int = ppp[1]
958
+ access_poi = ppp[2]
959
+ ssid_a = ppp[3]
960
+
961
+
962
+ if access_int=='GigabitEthernet4.3002'
963
+ access_poi = "belrw_4_HP_ap1-1"
964
+ ssid_a = "BelRW_WiFi"
965
+ elsif access_int=='GigabitEthernet4.3005'
966
+ access_poi = "belbiz-AP1-1"
967
+ ssid_a = "IMAGURU_GUEST"
968
+ end
596
969
 
597
- if subs_mac=="unknown"
598
- output_params = {:code => 505, :result => "ERROR. Something wrong."}
599
- end
970
+ if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
971
+ frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
972
+ splitting5 = frommikrotik.split("---")
973
+ p access_poi = splitting5[1]
974
+ p ssid_a = splitting5[2]
975
+ p tx_rate_se = splitting5[3]
976
+ p tx_rat = splitting5[4]
977
+ p rx_rat = splitting5[5]
978
+ p rx_signa = splitting5[6]
979
+ p uptim = splitting5[7]
980
+ p packet = splitting5[8]
981
+ p byt = splitting5[9]
982
+ end
600
983
 
601
- if subs_mac==""
602
- output_params = {:code => 505, :result => "ERROR. Something wrong."}
603
- end
984
+ tx_rate_se = "unknown"
985
+ tx_rat = "unknown"
986
+ rx_rat = "unknown"
987
+ rx_signa = "unknown"
988
+ uptim = "unknown"
989
+ packet = "unknown"
990
+ byt = "unknown"
604
991
 
605
- mess = {:iwag_access_interface => access_int,
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
992
+ if subs_mac=="unknown"
993
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
994
+ end
645
995
 
646
- end
647
- rescue
648
- puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
996
+ if subs_mac==""
649
997
  output_params = {:code => 505, :result => "ERROR. Something wrong."}
650
998
  end
651
999
 
652
- ####
1000
+ mess = {:iwag_access_interface => access_int,
1001
+ :subscribers_mac => subs_mac,
1002
+ :access_point => access_poi,
1003
+ :ssid_ap => ssid_a,
1004
+ :apid => "unknown",
1005
+ :statistics =>
1006
+ {:tx_rate_set => tx_rate_se,
1007
+ :tx_rate => tx_rat,
1008
+ :rx_rate => rx_rat,
1009
+ :rx_signal => rx_signa,
1010
+ :uptime => uptim,
1011
+ :packets => packet,
1012
+ :bytes => byt}
1013
+ }
1014
+ # 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}"
1015
+ output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
1016
+ p output_params
653
1017
 
654
1018
  else
655
- output_params = {:code => 404, :result => "ERROR. Unknown IP Pool."}
1019
+
1020
+ mess = {:iwag_access_interface => "unknown",
1021
+ :subscribers_mac => "unknown",
1022
+ :access_point => "unknown",
1023
+ :ssid_ap => "unknown",
1024
+ :apid => "unknown",
1025
+ :statistics =>
1026
+ {:tx_rate_set => "unknown",
1027
+ :tx_rate => "unknown",
1028
+ :rx_rate => "unknown",
1029
+ :rx_signal => "unknown",
1030
+ :uptime => "unknown",
1031
+ :packets => "unknown",
1032
+ :bytes => "unknown"}
1033
+ }
1034
+
1035
+ # 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}"
1036
+
1037
+ output_params = {:code => 405, :result => "ERROR. MAC address not found on IWAG."}
1038
+
1039
+ #render :soap => mess
656
1040
 
657
1041
  end
658
1042
  rescue
659
- puts 'SOAP mts_wifi_get_subs_info_return errorMethod invalid ip address'
660
- output_params = {:code => 500, :result => "ERROR. Something wrong."}
1043
+ puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
1044
+ output_params = {:code => 505, :result => "ERROR. Something wrong."}
661
1045
  end
662
1046
 
663
1047
  output_params
664
1048
 
1049
+ ####
1050
+
665
1051
  end
666
1052
 
667
1053