freewifi 0.2.4 → 0.2.8

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.
data/.travis.yml CHANGED
File without changes
data/CODE_OF_CONDUCT.md CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/freewifi.gemspec CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -21,7 +21,9 @@ class WiFiPortal_1
21
21
  :mtik_api_connector,
22
22
  :hua_controller_connector,
23
23
  :iwag_connector1,
24
- :iwag_connector2
24
+ :iwag_connector2,
25
+ :protocol_mtik,
26
+ :mtik_capsman_list
25
27
 
26
28
  def initialize(apigw_wsdl,
27
29
  apigw_endpoint,
@@ -42,7 +44,9 @@ class WiFiPortal_1
42
44
  iwag2_host,
43
45
  iwag2_username,
44
46
  iwag2_password,
45
- iwag2_port
47
+ iwag2_port,
48
+ protocol_mtik,
49
+ mtik_capsman_list
46
50
  )
47
51
  @iwag_telnet_connector = CSRtelnet_1.new(iwag1_host, iwag1_username, iwag1_password)
48
52
  @ard_api_gw_connector_wifi = Savon.client do
@@ -66,6 +70,8 @@ class WiFiPortal_1
66
70
  @iwag_connector1 = IwagRequester.new(iwag1_host, iwag1_username, iwag1_password, iwag1_port)
67
71
  @iwag_connector2 = IwagRequester.new(iwag2_host, iwag2_username, iwag2_password, iwag2_port)
68
72
 
73
+ @protocol_mtik = protocol_mtik
74
+ @mtik_capsman_list = mtik_capsman_list
69
75
  end
70
76
 
71
77
 
@@ -250,15 +256,11 @@ class WiFiPortal_1
250
256
  end
251
257
 
252
258
 
259
+
260
+
253
261
  def get_subs_add_info4new_1(access_interface, subscribers_mac)
254
262
 
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
- ]
263
+ capsman_list = mtik_capsman_list
262
264
 
263
265
  answer = ""
264
266
 
@@ -271,11 +273,27 @@ class WiFiPortal_1
271
273
  capsman_list.each do |capsman|
272
274
  threads_mikro_wlc << Thread.new do
273
275
  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
276
+ if protocol_mtik == 'api'
277
+ p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, capsman)
278
+ splitting5 = mikr_info5.split("---")
279
+ if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
280
+ answer = mikr_info5
281
+ p answer
282
+ end
283
+ elsif protocol_mtik == 'ssh'
284
+ p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_ssh(subscribers_mac, capsman)
285
+ splitting5 = mikr_info5.split("---")
286
+ if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
287
+ answer = mikr_info5
288
+ p answer
289
+ end
290
+ else
291
+ p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, capsman)
292
+ splitting5 = mikr_info5.split("---")
293
+ if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
294
+ answer = mikr_info5
295
+ p answer
296
+ end
279
297
  end
280
298
  rescue
281
299
  p "thr0 wrong"
@@ -291,6 +309,7 @@ class WiFiPortal_1
291
309
  answer
292
310
  end
293
311
 
312
+
294
313
  def proc_100_71_0_0(ip_address)
295
314
  begin
296
315
  p access_int = iwag_telnet_connector.return_iwag_access_interface_1(ip_address)
File without changes
File without changes
File without changes
@@ -1,4 +1,5 @@
1
1
  require 'mtik'
2
+ require 'net/ssh'
2
3
 
3
4
  class NEWhubWifiApi_1
4
5
 
@@ -11,87 +12,183 @@ class NEWhubWifiApi_1
11
12
  end
12
13
 
13
14
 
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']
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
47
49
  end
48
50
  end
49
51
  end
50
- end
51
52
 
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
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
63
95
 
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"
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
96
  end
91
97
 
92
- #endregion
93
- subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes
94
98
 
95
- end
99
+ def get_info_subs_from_mik_ssh(subs_mac, controllers_ip)
100
+ input_parameters = {:subs_mac => subs_mac, :controllers_ip => controllers_ip}
101
+ #region get additional information
102
+
103
+
104
+ subscribers_mac = subs_mac
105
+ access_point =""
106
+ ssid_ap =""
107
+ tx_rate_set = ""
108
+ tx_rate = ""
109
+ rx_rate = ""
110
+ rx_signal = ""
111
+ uptime = ""
112
+ packets = ""
113
+ bytes = ""
114
+
115
+ begin
116
+ Net::SSH.start(controllers_ip, mtik_user, :password => mtik_password) do |ssh|
117
+ #result = ssh.exec!("/interface eoip print where tunnel-id=#{tunnel_id}")
118
+ #p result
119
+ result = ssh.exec!("/caps-man registration-table print detail value-list where mac-address=#{subs_mac}")
120
+ p result
121
+ access_point_reg = /interface:\s(.+)\r\n/
122
+ access_point = result.scan(access_point_reg)[0][0]
123
+ ssid_reg = /ssid:\s(.+)\r\n/
124
+ ssid_ap = result.scan(ssid_reg)[0][0]
125
+
126
+ tx_rate_set = "unknown"
127
+ tx_rate = "0"
128
+ rx_rate = "0"
129
+ rx_signal = "0"
130
+ uptime = "0"
131
+ packets = "0"
132
+ bytes = "0"
133
+
134
+ p access_point
135
+ p ssid_ap
136
+ #regimsi = /\s+name="(.+)"\s+/
137
+ #m1 = regimsi.match(result)[1]
138
+
139
+ #result2 = ssh.exec!("interface bridge port add bridge=#{bridge_name} interface=#{tunnel_name}")
140
+ end
141
+ #Net::SSH.stop
142
+ rescue
143
+ nil
144
+ end
145
+
146
+ p "1111111111111111111"
147
+
148
+ if access_point=="" || ssid_ap=="" || packets==""
149
+ access_point = "not on mikrotik controller"
150
+ ssid_ap = "unknown"
151
+ tx_rate_set = "unknown"
152
+ tx_rate = "0"
153
+ rx_rate = "0"
154
+ rx_signal = "0"
155
+ uptime = "0"
156
+ packets = "0"
157
+ bytes = "0"
158
+ end
159
+
160
+ if access_point==nil || access_point==''
161
+ access_point= "unknown"
162
+ end
163
+ if ssid_ap==nil || ssid_ap==''
164
+ ssid_ap= "unknown"
165
+ end
166
+ if tx_rate_set==nil || tx_rate_set==''
167
+ tx_rate_set= "unknown"
168
+ end
169
+ if tx_rate==nil || tx_rate==''
170
+ tx_rate= "unknown"
171
+ end
172
+ if rx_rate==nil || rx_rate==''
173
+ rx_rate= "unknown"
174
+ end
175
+ if rx_signal==nil || rx_signal==''
176
+ rx_signal= "unknown"
177
+ end
178
+ if uptime==nil || uptime==''
179
+ uptime= "unknown"
180
+ end
181
+ if packets==nil || packets==''
182
+ packets= "unknown"
183
+ end
184
+ if bytes==nil || bytes==''
185
+ bytes= "unknown"
186
+ end
187
+
188
+ #endregion
189
+ subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes
190
+
191
+ end
192
+
96
193
 
97
194
  end
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module Freewifi_1
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.8'
3
3
  end
data/lib/freewifi.rb CHANGED
@@ -303,7 +303,9 @@ class PortalFwifi_1
303
303
  iwag2_username,
304
304
  iwag2_password,
305
305
  iwag1_port=22,
306
- iwag2_port=22
306
+ iwag2_port=22,
307
+ protocol_mtik='api',
308
+ mtik_capsman_list=['172.24.247.15', '172.24.214.155', '172.24.214.140', '172.24.214.105', '172.24.223.105']
307
309
  )
308
310
 
309
311
  @general_procedures = WiFiPortal_1.new(apigw_wsdl,
@@ -325,7 +327,9 @@ class PortalFwifi_1
325
327
  iwag2_host,
326
328
  iwag2_username,
327
329
  iwag2_password,
328
- iwag2_port
330
+ iwag2_port,
331
+ protocol_mtik,
332
+ mtik_capsman_list
329
333
  )
330
334
  @mtik_control_ips_get = mtik_control_ips_get
331
335
  @mtik_user = mtik_user
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freewifi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-04 00:00:00.000000000 Z
11
+ date: 2022-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler