freewifi 0.2.2 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.idea/freewifi.iml +78 -2
- data/.idea/inspectionProfiles/Project_Default.xml +0 -0
- data/.idea/misc.xml +0 -0
- data/.idea/modules.xml +0 -0
- data/.idea/runConfigurations/get_iwag_data.xml +21 -0
- data/.idea/vcs.xml +0 -0
- data/.idea/workspace.xml +330 -199
- data/.travis.yml +0 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/freewifi.gemspec +23 -23
- data/lib/freewifi/additional/additional_functions.rb +2 -2
- data/lib/freewifi/cisco/any/cisco_schemes_conf_gen.rb +0 -0
- data/lib/freewifi/cisco/iwag/get_iwag_data.rb +4 -12
- data/lib/freewifi/cisco/iwag/iwag_database_worker.rb +4 -0
- data/lib/freewifi/cisco/iwag/iwag_telnet_connector.rb +3 -3
- data/lib/freewifi/config.rb +1 -1
- data/lib/freewifi/database/mongo/mongoconnector.rb +0 -0
- data/lib/freewifi/database/mysql/database_methods_wifi.rb +0 -0
- data/lib/freewifi/general/wifi_portal_procedures.rb +70 -51
- data/lib/freewifi/huawei/hua_controller_class.rb +0 -0
- data/lib/freewifi/mikrotik/automation/get_data_ssh_fun.rb +0 -0
- data/lib/freewifi/mikrotik/getsubscribermikrotik.rb +0 -0
- data/lib/freewifi/mikrotik/newhub_mtik_api.rb +171 -75
- data/lib/freewifi/mikrotik/newhub_mtik_ssh.rb +11 -11
- data/lib/freewifi/mikrotik/schemes_conf_gen.rb +2 -2
- data/lib/freewifi/params.rb +0 -0
- data/lib/freewifi/version.rb +1 -1
- data/lib/freewifi.rb +32 -25
- metadata +3 -2
@@ -25,7 +25,7 @@ class NEWhubWifi_1
|
|
25
25
|
#result = ssh.exec!("/interface eoip print where tunnel-id=#{tunnel_id}")
|
26
26
|
#p result
|
27
27
|
result = ssh.exec!("/interface eoip print where tunnel-id=#{tunnel_id}")
|
28
|
-
regimsi = /\s+name
|
28
|
+
regimsi = /\s+name="(.+)"\s+/
|
29
29
|
m1 = regimsi.match(result)[1]
|
30
30
|
sleep 0.2
|
31
31
|
result2 = ssh.exec!("/interface bridge port remove [/interface bridge port find interface=#{m1}]")
|
@@ -42,7 +42,7 @@ class NEWhubWifi_1
|
|
42
42
|
begin
|
43
43
|
Net::SSH.start(hub2, user_hub, :password => password_hub) do |ssh|
|
44
44
|
result = ssh.exec!("/interface eoip print where tunnel-id=#{tunnel_id}")
|
45
|
-
regimsi = /\s+name
|
45
|
+
regimsi = /\s+name="(.+)"\s+/
|
46
46
|
m1 = regimsi.match(result)[1]
|
47
47
|
sleep 0.2
|
48
48
|
result2 = ssh.exec!("/interface bridge port remove [/interface bridge port find interface=#{m1}]")
|
@@ -222,12 +222,12 @@ class NEWhubWifi_1
|
|
222
222
|
end
|
223
223
|
end
|
224
224
|
end
|
225
|
-
output_params = {:code => 200, :result =>
|
225
|
+
output_params = {:code => 200, :result => 'check_pool_range_includes_1: Request processed', :body => {:result => res}}
|
226
226
|
rescue
|
227
|
-
output_params = {:code => 507, :result =>
|
227
|
+
output_params = {:code => 507, :result => 'check_pool_range_includes_1: Unknown SDK error'}
|
228
228
|
end
|
229
229
|
|
230
|
-
additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => output_params, :procedure =>
|
230
|
+
additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => output_params, :procedure => 'check_pool_range_includes_1', :file => 'freewifi/mikrotik/newhub_mtik_ssh.rb', :sdk => 'freewifi'}, 'debug')
|
231
231
|
output_params
|
232
232
|
end
|
233
233
|
|
@@ -245,7 +245,7 @@ class NEWhubWifi_1
|
|
245
245
|
|
246
246
|
command_provisioning_24ghz = "/caps-man provisioning add hw-supported-modes=b,g,gn ip-address-ranges=#{ap_ip} action=create-dynamic-enabled place-before=30 master-configuration=#{conf_24ghz_name} name-format=identity"
|
247
247
|
|
248
|
-
command_provisioning_5ghz = "/caps-man provisioning add hw-supported-modes=a,ac,an ip-address-ranges=#{ap_ip} action=create-dynamic-enabled place-before=30 master-configuration=#{
|
248
|
+
command_provisioning_5ghz = "/caps-man provisioning add hw-supported-modes=a,ac,an ip-address-ranges=#{ap_ip} action=create-dynamic-enabled place-before=30 master-configuration=#{conf_5ghz_name} name-format=identity"
|
249
249
|
|
250
250
|
Net::SSH.start(capsman1, capsman_user1, :password => capsman_pass1) do |ssh|
|
251
251
|
result = ssh.exec!(command_conf_24ghz)
|
@@ -270,8 +270,8 @@ class NEWhubWifi_1
|
|
270
270
|
result = ssh.exec!(command)
|
271
271
|
s1 = result.split("\r\n\r\n")
|
272
272
|
for a in s1
|
273
|
-
a1 = a.gsub("\r\n",
|
274
|
-
a2 = a1.gsub(
|
273
|
+
a1 = a.gsub("\r\n", '')
|
274
|
+
a2 = a1.gsub(', ', ',')
|
275
275
|
reg_addr_range = / (\d) .+ ip-address-ranges=(\d{1,3}.+\.\d{1,3}|\d{1,3}.+\.\d{1,3}\/\d{1,2})\s+/
|
276
276
|
m1 = a2.scan(reg_addr_range)
|
277
277
|
num = m1[0][0]
|
@@ -280,7 +280,7 @@ class NEWhubWifi_1
|
|
280
280
|
final_provision_old << triplet
|
281
281
|
exists_check = self.check_pool_range_includes_1(triplet[1], ap_ip)
|
282
282
|
|
283
|
-
if exists_check[:body][:result] !=
|
283
|
+
if exists_check[:body][:result] != 'exists'
|
284
284
|
#self.capsman_set_ip_range_1(capsman1, capsman_user1, capsman_pass1, ap_ip)
|
285
285
|
#set data to capsman
|
286
286
|
rewrite_ip_command = "/caps-man provisioning set numbers=#{triplet[0]} ip-address-ranges=#{triplet[1]},#{ap_ip}"
|
@@ -314,7 +314,7 @@ class NEWhubWifi_1
|
|
314
314
|
else
|
315
315
|
p result
|
316
316
|
conf_names = []
|
317
|
-
reg_config_name = /name
|
317
|
+
reg_config_name = /name="(\S+)"/
|
318
318
|
m1 = result.scan(reg_config_name)
|
319
319
|
for a1 in m1
|
320
320
|
if a1[0] != []
|
@@ -326,7 +326,7 @@ class NEWhubWifi_1
|
|
326
326
|
end
|
327
327
|
end
|
328
328
|
rescue
|
329
|
-
output_params = {:code => 507, :result =>
|
329
|
+
output_params = {:code => 507, :result => 'set_capsman_config_1: Unknown SDK error'}
|
330
330
|
end
|
331
331
|
|
332
332
|
additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => output_params, :procedure => "set_capsman_config_1", :file => "freewifi/mikrotik/newhub_mtik_ssh.rb", :sdk => "freewifi"}, "debug")
|
@@ -15,9 +15,9 @@ class MtikSchemesGen_1
|
|
15
15
|
|
16
16
|
[
|
17
17
|
"/system identity set name=#{hostname}",
|
18
|
-
|
18
|
+
'/interface bridge add name=bridge_tunnel',
|
19
19
|
"/interface eoip add remote-address=#{hub_vip.to_s} tunnel-id=#{tunnel_id.to_s} name=tunnel_to_hub",
|
20
|
-
|
20
|
+
'/interface bridge port add interface=tunnel_to_hub bridge=bridge_tunnel',
|
21
21
|
"/interface bridge port add interface=wlan1 bridge=bridge_tunnel",
|
22
22
|
"/interface wireless set wlan1 mode=ap-bridge ssid=#{ap_ssid} disabled=no name=wireless_public_interface frequency=2442",
|
23
23
|
"/interface ppp-client set ppp-out1 apn=vpn pin=1111 disabled=no",
|
data/lib/freewifi/params.rb
CHANGED
File without changes
|
data/lib/freewifi/version.rb
CHANGED
data/lib/freewifi.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#$LOAD_PATH.unshift File.expand_path("../freewifi", __dir__)
|
2
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
-
$LOAD_PATH.unshift File.expand_path(
|
4
|
-
$LOAD_PATH.unshift File.expand_path(
|
5
|
-
$LOAD_PATH.unshift File.expand_path(
|
6
|
-
$LOAD_PATH.unshift File.expand_path(
|
7
|
-
$LOAD_PATH.unshift File.expand_path(
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../mikrotik', __dir__)
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../database/mysql', __dir__)
|
4
|
+
$LOAD_PATH.unshift File.expand_path('../database/mongo', __dir__)
|
5
|
+
$LOAD_PATH.unshift File.expand_path('../additional', __dir__)
|
6
|
+
$LOAD_PATH.unshift File.expand_path('../general', __dir__)
|
7
|
+
$LOAD_PATH.unshift File.expand_path('../huawei', __dir__)
|
8
8
|
|
9
9
|
require "freewifi/version"
|
10
10
|
require "freewifi/params"
|
@@ -86,8 +86,6 @@ module Freewifi_1
|
|
86
86
|
@hub_vip = hub_vip
|
87
87
|
@ap_admin_password = ap_admin_password
|
88
88
|
@capsman_ip_wifi = capsman_ip_wifi
|
89
|
-
|
90
|
-
|
91
89
|
end
|
92
90
|
|
93
91
|
|
@@ -137,7 +135,7 @@ module Freewifi_1
|
|
137
135
|
:subscribers_contacts => subscribers_contacts,
|
138
136
|
:wifi_ssid => wifi_ssid,
|
139
137
|
:portalstyle => portalstyle,
|
140
|
-
:ap =>
|
138
|
+
:ap => 'MikroTik',
|
141
139
|
:ap_serial_number => ap_serial_number,
|
142
140
|
:ap_model => ap_model,
|
143
141
|
:description => description,
|
@@ -148,7 +146,7 @@ module Freewifi_1
|
|
148
146
|
}
|
149
147
|
|
150
148
|
mongo_response = mongo_connector_wifi_1.data_ap_auto_created_insert_1(data)
|
151
|
-
if mongo_response[:code]==200
|
149
|
+
if mongo_response[:code] == 200
|
152
150
|
|
153
151
|
newcapsman1 = NEWhubWifi_1.new
|
154
152
|
threads_1 = []
|
@@ -159,27 +157,27 @@ module Freewifi_1
|
|
159
157
|
|
160
158
|
input_intern_data = {:wifi_ssid_processed => wifi_ssid_processed, :company_name_processed => company_name_processed, :capsman => capsman}
|
161
159
|
|
162
|
-
mongo_connector_wifi_1.audit_logger_wifi_1(
|
160
|
+
mongo_connector_wifi_1.audit_logger_wifi_1('add_mikrotik_ap_mobile_1', remote_ip, input_intern_data, nil, real_ip, subscriber_ip)
|
163
161
|
|
164
162
|
newcapsman1.set_capsman_config_1(wifi_ssid_processed, capsman, capsman_user, capsman_password, sim_ipaddress, company_name_processed)
|
165
163
|
end
|
166
164
|
end
|
167
165
|
threads_1.each(&:join)
|
168
166
|
|
169
|
-
output_params = {:code => 200, :result =>
|
167
|
+
output_params = {:code => 200, :result => 'Request completed successfully', :body => {:tunnel_id => tunnel_addition[:body][:eoip_tunnel_id], :tunnel_name => tunnel_addition[:body][:eoip_tunnel_name]}}
|
170
168
|
else
|
171
|
-
output_params = {:code => 400, :result =>
|
169
|
+
output_params = {:code => 400, :result => 'Something wrong with insertion to mongo'}
|
172
170
|
end
|
173
171
|
else
|
174
172
|
output_params = {:code => 401, :result => tunnel_addition[:result]}
|
175
173
|
end
|
176
174
|
else
|
177
|
-
output_params = {:code => 202, :result =>
|
175
|
+
output_params = {:code => 202, :result => 'AP exists', :body => {:tunnel_id => ap_state[:tunnel_id].to_s}}
|
178
176
|
end
|
179
177
|
rescue
|
180
|
-
output_params = {:code => 507, :result =>
|
178
|
+
output_params = {:code => 507, :result => 'Unknown SDK error'}
|
181
179
|
end
|
182
|
-
mongo_connector_wifi_1.audit_logger_wifi_1(
|
180
|
+
mongo_connector_wifi_1.audit_logger_wifi_1('add_mikrotik_ap_mobile_1', remote_ip, input_params, output_params, real_ip, subscriber_ip)
|
183
181
|
#additional_func.printer_texter({:input_params => input_params, :output_params => output_params, :procedure => "add_mikrotik_ap_mobile", :file => "freewifi.rb"}, "info")
|
184
182
|
output_params
|
185
183
|
end
|
@@ -213,9 +211,9 @@ module Freewifi_1
|
|
213
211
|
output_params = {:code => res[:code], :result => res[:result], :body => {:ap_configuration => conf_1}}
|
214
212
|
|
215
213
|
rescue
|
216
|
-
output_params = {:code => 507, :result =>
|
214
|
+
output_params = {:code => 507, :result => 'Unknown SDK error'}
|
217
215
|
end
|
218
|
-
mongo_connector_wifi_1.audit_logger_wifi_1(
|
216
|
+
mongo_connector_wifi_1.audit_logger_wifi_1('mtik_sch1_config_gen_1', remote_ip, input_params, conf_1, real_ip, subscriber_ip)
|
219
217
|
output_params
|
220
218
|
end
|
221
219
|
|
@@ -245,10 +243,11 @@ module Freewifi_1
|
|
245
243
|
def test()
|
246
244
|
newcapsman1 = NEWhubWifi_1.new
|
247
245
|
|
246
|
+
capsman_ip = ['1.1.1.1']
|
248
247
|
threads = []
|
249
248
|
capsman_ip.each do |capsman|
|
250
249
|
threads << Thread.new do
|
251
|
-
newcapsman1.set_capsman_config_1(
|
250
|
+
newcapsman1.set_capsman_config_1('test_ss', capsman, capsman_user, capsman_password, '172.25.208.14', 'test_company')
|
252
251
|
end
|
253
252
|
end
|
254
253
|
threads.each(&:join)
|
@@ -302,7 +301,11 @@ class PortalFwifi_1
|
|
302
301
|
telegram_chat_id,
|
303
302
|
iwag2_host,
|
304
303
|
iwag2_username,
|
305
|
-
iwag2_password
|
304
|
+
iwag2_password,
|
305
|
+
iwag1_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']
|
306
309
|
)
|
307
310
|
|
308
311
|
@general_procedures = WiFiPortal_1.new(apigw_wsdl,
|
@@ -313,6 +316,7 @@ class PortalFwifi_1
|
|
313
316
|
iwag1_host,
|
314
317
|
iwag_username,
|
315
318
|
iwag_password,
|
319
|
+
iwag1_port,
|
316
320
|
mtik_control_ips_get,
|
317
321
|
mtik_user,
|
318
322
|
mtik_password,
|
@@ -323,6 +327,9 @@ class PortalFwifi_1
|
|
323
327
|
iwag2_host,
|
324
328
|
iwag2_username,
|
325
329
|
iwag2_password,
|
330
|
+
iwag2_port,
|
331
|
+
protocol_mtik,
|
332
|
+
mtik_capsman_list
|
326
333
|
)
|
327
334
|
@mtik_control_ips_get = mtik_control_ips_get
|
328
335
|
@mtik_user = mtik_user
|
@@ -345,18 +352,18 @@ class PortalFwifi_1
|
|
345
352
|
resp_procedure = general_procedures.get_subs_info_return_1(ipaddress)
|
346
353
|
output_params = resp_procedure
|
347
354
|
rescue
|
348
|
-
output_params = {:code => 507, :result =>
|
355
|
+
output_params = {:code => 507, :result => 'Unknown SDK error'}
|
349
356
|
end
|
350
357
|
end
|
351
358
|
subs_info_ret_1_thr1.join
|
352
359
|
|
353
360
|
subs_info_ret_1_thr2 = Thread.new do
|
354
361
|
begin
|
355
|
-
p
|
362
|
+
p 'mongo'
|
356
363
|
#mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database)
|
357
364
|
#mongo_connector_wifi_1.audit_logger_wifi_portal_1("wifi_get_subs_info_return_1", remote_ip, input_params, output_params, real_ip)
|
358
365
|
rescue
|
359
|
-
additional_func_wifi_1.printer_texter_wifi_1({:input_params => input_params, :output_params => {:result =>
|
366
|
+
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')
|
360
367
|
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)
|
361
368
|
end
|
362
369
|
end
|
@@ -375,7 +382,7 @@ class PortalFwifi_1
|
|
375
382
|
resp_procedure = general_procedures.get_subs_info_ret_ssh_1(ipaddress)
|
376
383
|
output_params = resp_procedure
|
377
384
|
rescue
|
378
|
-
output_params = {:code => 507, :result =>
|
385
|
+
output_params = {:code => 507, :result => 'Unknown SDK error'}
|
379
386
|
end
|
380
387
|
end
|
381
388
|
subs_info_ret_1_thr1.join
|
@@ -386,7 +393,7 @@ class PortalFwifi_1
|
|
386
393
|
#mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database)
|
387
394
|
#mongo_connector_wifi_1.audit_logger_wifi_portal_1("wifi_get_subs_info_return_1", remote_ip, input_params, output_params, real_ip)
|
388
395
|
rescue
|
389
|
-
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 =>
|
396
|
+
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")
|
390
397
|
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)
|
391
398
|
end
|
392
399
|
end
|
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
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dzmitry Buynovskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- ".idea/inspectionProfiles/Project_Default.xml"
|
205
205
|
- ".idea/misc.xml"
|
206
206
|
- ".idea/modules.xml"
|
207
|
+
- ".idea/runConfigurations/get_iwag_data.xml"
|
207
208
|
- ".idea/vcs.xml"
|
208
209
|
- ".idea/workspace.xml"
|
209
210
|
- ".travis.yml"
|