freewifi 0.2.3 → 0.2.7

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
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/freewifi.gemspec CHANGED
@@ -4,43 +4,43 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require "freewifi/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "freewifi"
7
+ spec.name = 'freewifi'
8
8
  spec.version = Freewifi_1::VERSION
9
- spec.authors = ["Dzmitry Buynovskiy"]
10
- spec.email = ["imperituro.ard@gmail.com"]
9
+ spec.authors = ['Dzmitry Buynovskiy']
10
+ spec.email = ['imperituro.ard@gmail.com']
11
11
 
12
12
  spec.summary = %q{gem for Public WiFi}
13
13
  spec.description = %q{description for my gem}
14
- spec.homepage = "https://rubygems.org/gems/freewifi"
15
- spec.license = "MIT"
14
+ spec.homepage = 'https://rubygems.org/gems/freewifi'
15
+ spec.license = 'MIT'
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
19
  if spec.respond_to?(:metadata)
20
- spec.metadata["allowed_push_host"] = "https://rubygems.org/"
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
21
21
  else
22
- raise "RubyGems 2.0 or newer is required to protect against " \
23
- "public gem pushes."
22
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
23
+ 'public gem pushes.'
24
24
  end
25
25
 
26
26
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
27
  f.match(%r{^(test|spec|features)/})
28
28
  end
29
- spec.bindir = "exe"
29
+ spec.bindir = 'exe'
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
31
+ spec.require_paths = ['lib']
32
32
 
33
- spec.add_development_dependency "bundler", "2.1.4"
34
- spec.add_development_dependency "rake", "13.0.1"
35
- spec.add_development_dependency "minitest", "~> 5.0"
36
- spec.add_development_dependency "net-ssh", '4.0.1'
37
- spec.add_development_dependency "json", "2.3.0"
38
- spec.add_development_dependency "ipaddr", "1.2.2"
39
- spec.add_development_dependency "date", "3.0.0"
40
- spec.add_development_dependency "mysql2", "0.5.3"
41
- spec.add_development_dependency "mongo", "2.11.4"
42
- spec.add_development_dependency "translit", "0.1.5"
43
- spec.add_development_dependency "savon", "2.12.0"
44
- spec.add_development_dependency "net-telnet", "0.2.0"
45
- spec.add_development_dependency "mtik", "4.0.3"
33
+ spec.add_development_dependency 'bundler', '2.1.4'
34
+ spec.add_development_dependency 'rake', '13.0.1'
35
+ spec.add_development_dependency 'minitest', '~> 5.0'
36
+ spec.add_development_dependency 'net-ssh', '4.0.1'
37
+ spec.add_development_dependency 'json', '2.3.0'
38
+ spec.add_development_dependency 'ipaddr', '1.2.2'
39
+ spec.add_development_dependency 'date', '3.0.0'
40
+ spec.add_development_dependency 'mysql2', '0.5.3'
41
+ spec.add_development_dependency 'mongo', '2.11.4'
42
+ spec.add_development_dependency 'translit', '0.1.5'
43
+ spec.add_development_dependency 'savon', '2.12.0'
44
+ spec.add_development_dependency 'net-telnet', '0.2.0'
45
+ spec.add_development_dependency 'mtik', '4.0.3'
46
46
  end
@@ -23,11 +23,11 @@ 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
30
- return {:code => 507, :result => "Unknown SDK error"}
30
+ return {:code => 507, :result => 'Unknown SDK error'}
31
31
  end
32
32
  end
33
33
 
File without changes
File without changes
File without changes
@@ -19,7 +19,7 @@ class CSRtelnet_1
19
19
  #begin
20
20
 
21
21
  dump =""
22
- connection = Net::Telnet.new( "Host" => iwag1_host, "Timeout" => false, "Prompt" => /.*\#/ ) { |str| }
22
+ connection = Net::Telnet.new( "Host" => iwag1_host, "Timeout" => false, "Prompt" => /.*#/ ) { |str| }
23
23
  connection.login({ "Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/ }) { |str| }
24
24
  connection.cmd("show ip dhcp binding #{ipaddress}") {
25
25
  |c|
@@ -69,7 +69,7 @@ class CSRtelnet_1
69
69
 
70
70
  dump =""
71
71
  begin
72
- connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
72
+ connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*#/) {|str| print str}
73
73
  connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
74
74
  connection.cmd("show ip dhcp binding #{ipaddress}") {
75
75
  |c|
@@ -87,7 +87,7 @@ class CSRtelnet_1
87
87
  end
88
88
  rescue
89
89
  begin
90
- connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
90
+ connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*#/) {|str| print str}
91
91
  connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
92
92
  connection.cmd("show ip dhcp binding #{ipaddress}") {
93
93
  |c|
@@ -1,5 +1,5 @@
1
1
  module Freewifi_1
2
- LOGLEVEL_1 = "debug"
2
+ LOGLEVEL_1 = 'debug'
3
3
 
4
4
  end
5
5
 
File without changes
File without changes
@@ -21,52 +21,58 @@ class WiFiPortal_1
21
21
  :mtik_api_connector,
22
22
  :hua_controller_connector,
23
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
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
57
61
 
58
- @iwag1_host = iwag1_host
59
- @iwag_username = iwag1_username
60
- @iwag_password = iwag1_password
62
+ @iwag1_host = iwag1_host
63
+ @iwag_username = iwag1_username
64
+ @iwag_password = iwag1_password
61
65
 
62
- @mtik_api_connector = NEWhubWifiApi_1.new(mtik_control_ips_get, mtik_user, mtik_password)
66
+ @mtik_api_connector = NEWhubWifiApi_1.new(mtik_control_ips_get, mtik_user, mtik_password)
63
67
 
64
- @hua_controller_connector = HuaWifi_1.new(hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password)
68
+ @hua_controller_connector = HuaWifi_1.new(hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password)
65
69
 
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)
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)
68
72
 
69
- end
73
+ @protocol_mtik = protocol_mtik
74
+ @mtik_capsman_list = mtik_capsman_list
75
+ end
70
76
 
71
77
 
72
78
  def python_mac_iwag1_1(ipaddress)
@@ -125,7 +131,7 @@ class WiFiPortal_1
125
131
  begin
126
132
 
127
133
  dump =""
128
- connection = Net::Telnet.new("Host" => "172.24.247.183", "Timeout" => false, "Prompt" => /.*\#/) {|str|}
134
+ connection = Net::Telnet.new("Host" => "172.24.247.183", "Timeout" => false, "Prompt" => /.*#/) {|str|}
129
135
  connection.login({"Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/}) {|str|}
130
136
  connection.cmd("show ip dhcp binding #{ipaddress}") {
131
137
  |c|
@@ -252,13 +258,7 @@ class WiFiPortal_1
252
258
 
253
259
  def get_subs_add_info4new_1(access_interface, subscribers_mac)
254
260
 
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
- ]
261
+ capsman_list = mtik_capsman_list
262
262
 
263
263
  answer = ""
264
264
 
@@ -271,11 +271,27 @@ class WiFiPortal_1
271
271
  capsman_list.each do |capsman|
272
272
  threads_mikro_wlc << Thread.new do
273
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
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
279
295
  end
280
296
  rescue
281
297
  p "thr0 wrong"
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,89 +12,184 @@ 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
- answ = subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes
94
98
 
95
- answ
96
99
 
97
- end
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
+
192
+ end
193
+
98
194
 
99
195
  end