freewifi 0.2.5 → 0.2.9

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.
@@ -23,7 +23,7 @@ class InternalFunc_1
23
23
  response_mess = https_connector.request(request_mess)
24
24
  body = response_mess.body
25
25
  return {:code => 200,
26
- :result => 'Request completed successfully',
26
+ :result => "Request completed successfully",
27
27
  :body => {:telegram_resp => JSON.parse(body.to_s),
28
28
  :description => "Telegram message to telegram_chat_id: #{telegram_chat_id.to_s}"}}
29
29
  rescue
@@ -21,58 +21,52 @@ class WiFiPortal_1
21
21
  :mtik_api_connector,
22
22
  :hua_controller_connector,
23
23
  :iwag_connector1,
24
- :iwag_connector2,
25
- :protocol_mtik,
26
- :mtik_capsman_list
27
-
28
- def initialize(apigw_wsdl,
29
- apigw_endpoint,
30
- apigw_namespace,
31
- apigw_wsse_aut_log,
32
- apigw_wsse_aut_pass,
33
- iwag1_host,
34
- iwag1_username,
35
- iwag1_password,
36
- iwag1_port,
37
- mtik_control_ips_get,
38
- mtik_user,
39
- mtik_password,
40
- hua_wlc_1_ip,
41
- hua_wlc_2_ip,
42
- hua_wlc_login,
43
- hua_wlc_password,
44
- iwag2_host,
45
- iwag2_username,
46
- iwag2_password,
47
- iwag2_port,
48
- protocol_mtik,
49
- mtik_capsman_list
50
- )
51
- @iwag_telnet_connector = CSRtelnet_1.new(iwag1_host, iwag1_username, iwag1_password)
52
- @ard_api_gw_connector_wifi = Savon.client do
53
- #ssl_verify_mode :none
54
- wsdl apigw_wsdl
55
- endpoint apigw_endpoint
56
- namespace apigw_namespace
57
- wsse_auth(apigw_wsse_aut_log, apigw_wsse_aut_pass, :digest)
58
- encoding 'UTF-8'
59
- headers = {"Accept-Encoding" => "gzip, deflate", "Connection" => "Keep-Alive"}
60
- end
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
61
57
 
62
- @iwag1_host = iwag1_host
63
- @iwag_username = iwag1_username
64
- @iwag_password = iwag1_password
58
+ @iwag1_host = iwag1_host
59
+ @iwag_username = iwag1_username
60
+ @iwag_password = iwag1_password
65
61
 
66
- @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)
67
63
 
68
- @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)
69
65
 
70
- @iwag_connector1 = IwagRequester.new(iwag1_host, iwag1_username, iwag1_password, iwag1_port)
71
- @iwag_connector2 = IwagRequester.new(iwag2_host, iwag2_username, iwag2_password, iwag2_port)
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)
72
68
 
73
- @protocol_mtik = protocol_mtik
74
- @mtik_capsman_list = mtik_capsman_list
75
- end
69
+ end
76
70
 
77
71
 
78
72
  def python_mac_iwag1_1(ipaddress)
@@ -258,7 +252,13 @@ class WiFiPortal_1
258
252
 
259
253
  def get_subs_add_info4new_1(access_interface, subscribers_mac)
260
254
 
261
- capsman_list = mtik_capsman_list
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
+ ]
262
262
 
263
263
  answer = ""
264
264
 
@@ -271,27 +271,11 @@ class WiFiPortal_1
271
271
  capsman_list.each do |capsman|
272
272
  threads_mikro_wlc << Thread.new do
273
273
  begin
274
- if protocol_mtik == 'api'
275
- p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, capsman)
276
- splitting5 = mikr_info5.split("---")
277
- if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
278
- answer = mikr_info5
279
- p answer
280
- end
281
- elsif protocol_mtik == 'ssh'
282
- p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_ssh(subscribers_mac, capsman)
283
- splitting5 = mikr_info5.split("---")
284
- if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
285
- answer = mikr_info5
286
- p answer
287
- end
288
- else
289
- p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, capsman)
290
- splitting5 = mikr_info5.split("---")
291
- if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
292
- answer = mikr_info5
293
- p answer
294
- end
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
295
279
  end
296
280
  rescue
297
281
  p "thr0 wrong"
@@ -1,5 +1,4 @@
1
1
  require 'mtik'
2
- require 'net/ssh'
3
2
 
4
3
  class NEWhubWifiApi_1
5
4
 
@@ -12,184 +11,87 @@ class NEWhubWifiApi_1
12
11
  end
13
12
 
14
13
 
15
- def get_info_subs_from_mik_1(subs_mac, controllers_ip)
16
- input_parameters = {:subs_mac => subs_mac, :controllers_ip => controllers_ip}
17
- #region get additional information
18
-
19
- subscribers_mac = subs_mac
20
- access_point =""
21
- ssid_ap =""
22
- tx_rate_set = ""
23
- tx_rate = ""
24
- rx_rate = ""
25
- rx_signal = ""
26
- uptime = ""
27
- packets = ""
28
- bytes = ""
29
-
30
- MTik::verbose = false
31
- mikrot_connection1 = MTik::Connection.new :host => controllers_ip, :user => mtik_user, :pass => mtik_password, :conn_timeout => 7, :cmd_timeout => 7
32
- mikrot_connection1.get_reply('/caps-man/registration-table/getall') do |req, sentence|
33
-
34
- req.reply.each do |reply|
35
- if reply.key?('mac-address')
36
- #p reply
37
- if reply['mac-address'] == subscribers_mac
38
-
39
- access_point = reply['interface']
40
- ssid_ap = reply['ssid']
41
- tx_rate = reply['tx-rate']
42
- rx_rate = reply['rx-rate']
43
- rx_signal = reply['rx-signal']
44
- uptime = reply['uptime']
45
- packets = reply['packets']
46
- bytes = reply['bytes']
47
- tx_rate_set = reply['tx-rate-set']
48
- end
14
+ def get_info_subs_from_mik_1(subs_mac, controllers_ip)
15
+ input_parameters = {:subs_mac => subs_mac, :controllers_ip => controllers_ip}
16
+ #region get additional information
17
+
18
+ subscribers_mac = subs_mac
19
+ access_point =""
20
+ ssid_ap =""
21
+ tx_rate_set = ""
22
+ tx_rate = ""
23
+ rx_rate = ""
24
+ rx_signal = ""
25
+ uptime = ""
26
+ packets = ""
27
+ bytes = ""
28
+
29
+ MTik::verbose = false
30
+ mikrot_connection1 = MTik::Connection.new :host => controllers_ip, :user => mtik_user, :pass => mtik_password, :conn_timeout => 7, :cmd_timeout => 7
31
+ mikrot_connection1.get_reply('/caps-man/registration-table/getall') do |req, sentence|
32
+
33
+ req.reply.each do |reply|
34
+ if reply.key?('mac-address')
35
+ #p reply
36
+ if reply['mac-address'] == subscribers_mac
37
+
38
+ access_point = reply['interface']
39
+ ssid_ap = reply['ssid']
40
+ tx_rate = reply['tx-rate']
41
+ rx_rate = reply['rx-rate']
42
+ rx_signal = reply['rx-signal']
43
+ uptime = reply['uptime']
44
+ packets = reply['packets']
45
+ bytes = reply['bytes']
46
+ tx_rate_set = reply['tx-rate-set']
49
47
  end
50
48
  end
51
49
  end
52
-
53
- if access_point=="" || ssid_ap=="" || packets==""
54
- access_point = "not on mikrotik controller"
55
- ssid_ap = "unknown"
56
- tx_rate_set = "unknown"
57
- tx_rate = "0"
58
- rx_rate = "0"
59
- rx_signal = "0"
60
- uptime = "0"
61
- packets = "0"
62
- bytes = "0"
63
- end
64
-
65
- if access_point==nil
66
- access_point= "unknown"
67
- end
68
- if ssid_ap==nil
69
- ssid_ap= "unknown"
70
- end
71
- if tx_rate_set==nil
72
- tx_rate_set= "unknown"
73
- end
74
- if tx_rate==nil
75
- tx_rate= "unknown"
76
- end
77
- if rx_rate==nil
78
- rx_rate= "unknown"
79
- end
80
- if rx_signal==nil
81
- rx_signal= "unknown"
82
- end
83
- if uptime==nil
84
- uptime= "unknown"
85
- end
86
- if packets==nil
87
- packets= "unknown"
88
- end
89
- if bytes==nil
90
- bytes= "unknown"
91
- end
92
-
93
- #endregion
94
- subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes
95
-
96
50
  end
97
51
 
52
+ if access_point=="" || ssid_ap=="" || packets==""
53
+ access_point = "not on mikrotik controller"
54
+ ssid_ap = "unknown"
55
+ tx_rate_set = "unknown"
56
+ tx_rate = "0"
57
+ rx_rate = "0"
58
+ rx_signal = "0"
59
+ uptime = "0"
60
+ packets = "0"
61
+ bytes = "0"
62
+ end
98
63
 
99
-
100
- def get_info_subs_from_mik_ssh(subs_mac, controllers_ip)
101
- input_parameters = {:subs_mac => subs_mac, :controllers_ip => controllers_ip}
102
- #region get additional information
103
-
104
-
105
- subscribers_mac = subs_mac
106
- access_point =""
107
- ssid_ap =""
108
- tx_rate_set = ""
109
- tx_rate = ""
110
- rx_rate = ""
111
- rx_signal = ""
112
- uptime = ""
113
- packets = ""
114
- bytes = ""
115
-
116
- begin
117
- Net::SSH.start(controllers_ip, mtik_user, :password => mtik_password) do |ssh|
118
- #result = ssh.exec!("/interface eoip print where tunnel-id=#{tunnel_id}")
119
- #p result
120
- result = ssh.exec!("/caps-man registration-table print detail value-list where mac-address=#{subs_mac}")
121
- p result
122
- access_point_reg = /interface:\s(.+)\r\n/
123
- access_point = result.scan(access_point_reg)[0][0]
124
- ssid_reg = /ssid:\s(.+)\r\n/
125
- ssid_ap = result.scan(ssid_reg)[0][0]
126
-
127
- tx_rate_set = "unknown"
128
- tx_rate = "0"
129
- rx_rate = "0"
130
- rx_signal = "0"
131
- uptime = "0"
132
- packets = "0"
133
- bytes = "0"
134
-
135
- p access_point
136
- p ssid_ap
137
- #regimsi = /\s+name="(.+)"\s+/
138
- #m1 = regimsi.match(result)[1]
139
-
140
- #result2 = ssh.exec!("interface bridge port add bridge=#{bridge_name} interface=#{tunnel_name}")
141
- end
142
- #Net::SSH.stop
143
- rescue
144
- nil
145
- end
146
-
147
- p "1111111111111111111"
148
-
149
- if access_point=="" || ssid_ap=="" || packets==""
150
- access_point = "not on mikrotik controller"
151
- ssid_ap = "unknown"
152
- tx_rate_set = "unknown"
153
- tx_rate = "0"
154
- rx_rate = "0"
155
- rx_signal = "0"
156
- uptime = "0"
157
- packets = "0"
158
- bytes = "0"
159
- end
160
-
161
- if access_point==nil || access_point==''
162
- access_point= "unknown"
163
- end
164
- if ssid_ap==nil || ssid_ap==''
165
- ssid_ap= "unknown"
166
- end
167
- if tx_rate_set==nil || tx_rate_set==''
168
- tx_rate_set= "unknown"
169
- end
170
- if tx_rate==nil || tx_rate==''
171
- tx_rate= "unknown"
172
- end
173
- if rx_rate==nil || rx_rate==''
174
- rx_rate= "unknown"
175
- end
176
- if rx_signal==nil || rx_signal==''
177
- rx_signal= "unknown"
178
- end
179
- if uptime==nil || uptime==''
180
- uptime= "unknown"
181
- end
182
- if packets==nil || packets==''
183
- packets= "unknown"
184
- end
185
- if bytes==nil || bytes==''
186
- bytes= "unknown"
187
- end
188
-
189
- #endregion
190
- subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes
191
-
64
+ if access_point==nil
65
+ access_point= "unknown"
66
+ end
67
+ if ssid_ap==nil
68
+ ssid_ap= "unknown"
69
+ end
70
+ if tx_rate_set==nil
71
+ tx_rate_set= "unknown"
72
+ end
73
+ if tx_rate==nil
74
+ tx_rate= "unknown"
75
+ end
76
+ if rx_rate==nil
77
+ rx_rate= "unknown"
192
78
  end
79
+ if rx_signal==nil
80
+ rx_signal= "unknown"
81
+ end
82
+ if uptime==nil
83
+ uptime= "unknown"
84
+ end
85
+ if packets==nil
86
+ packets= "unknown"
87
+ end
88
+ if bytes==nil
89
+ bytes= "unknown"
90
+ end
91
+
92
+ #endregion
93
+ subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes
193
94
 
95
+ end
194
96
 
195
97
  end
@@ -1,3 +1,3 @@
1
1
  module Freewifi_1
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.9'
3
3
  end
data/lib/freewifi.rb CHANGED
@@ -303,9 +303,7 @@ class PortalFwifi_1
303
303
  iwag2_username,
304
304
  iwag2_password,
305
305
  iwag1_port=22,
306
- iwag2_port=22,
307
- protocol_mtik='api',
308
- mtik_capsman_list
306
+ iwag2_port=22
309
307
  )
310
308
 
311
309
  @general_procedures = WiFiPortal_1.new(apigw_wsdl,
@@ -327,9 +325,7 @@ class PortalFwifi_1
327
325
  iwag2_host,
328
326
  iwag2_username,
329
327
  iwag2_password,
330
- iwag2_port,
331
- protocol_mtik,
332
- mtik_capsman_list
328
+ iwag2_port
333
329
  )
334
330
  @mtik_control_ips_get = mtik_control_ips_get
335
331
  @mtik_user = mtik_user
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freewifi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy