freewifi 0.2.3 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -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=\"(.+)\"\s+/
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=\"(.+)\"\s+/
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 => "check_pool_range_includes_1: Request processed", :body => {:result => res}}
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 => "check_pool_range_includes_1: Unknown SDK error"}
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 => "check_pool_range_includes_1", :file => "freewifi/mikrotik/newhub_mtik_ssh.rb", :sdk => "freewifi"}, "debug")
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=#{conf_24ghz_name} name-format=identity"
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] != "exists"
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=\"(\S+)\"/
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 => "set_capsman_config_1: Unknown SDK error"}
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
- "/interface bridge add name=bridge_tunnel",
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
- "/interface bridge port add interface=tunnel_to_hub bridge=bridge_tunnel",
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",
File without changes
@@ -1,3 +1,3 @@
1
1
  module Freewifi_1
2
- VERSION = "0.2.3"
2
+ VERSION = '0.2.7'
3
3
  end
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("../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__)
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"
@@ -135,7 +135,7 @@ module Freewifi_1
135
135
  :subscribers_contacts => subscribers_contacts,
136
136
  :wifi_ssid => wifi_ssid,
137
137
  :portalstyle => portalstyle,
138
- :ap => "MikroTik",
138
+ :ap => 'MikroTik',
139
139
  :ap_serial_number => ap_serial_number,
140
140
  :ap_model => ap_model,
141
141
  :description => description,
@@ -146,7 +146,7 @@ module Freewifi_1
146
146
  }
147
147
 
148
148
  mongo_response = mongo_connector_wifi_1.data_ap_auto_created_insert_1(data)
149
- if mongo_response[:code]==200
149
+ if mongo_response[:code] == 200
150
150
 
151
151
  newcapsman1 = NEWhubWifi_1.new
152
152
  threads_1 = []
@@ -157,27 +157,27 @@ module Freewifi_1
157
157
 
158
158
  input_intern_data = {:wifi_ssid_processed => wifi_ssid_processed, :company_name_processed => company_name_processed, :capsman => capsman}
159
159
 
160
- mongo_connector_wifi_1.audit_logger_wifi_1("add_mikrotik_ap_mobile_1", remote_ip, input_intern_data, nil, real_ip, subscriber_ip)
160
+ mongo_connector_wifi_1.audit_logger_wifi_1('add_mikrotik_ap_mobile_1', remote_ip, input_intern_data, nil, real_ip, subscriber_ip)
161
161
 
162
162
  newcapsman1.set_capsman_config_1(wifi_ssid_processed, capsman, capsman_user, capsman_password, sim_ipaddress, company_name_processed)
163
163
  end
164
164
  end
165
165
  threads_1.each(&:join)
166
166
 
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]}}
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]}}
168
168
  else
169
- output_params = {:code => 400, :result => "Something wrong with insertion to mongo"}
169
+ output_params = {:code => 400, :result => 'Something wrong with insertion to mongo'}
170
170
  end
171
171
  else
172
172
  output_params = {:code => 401, :result => tunnel_addition[:result]}
173
173
  end
174
174
  else
175
- output_params = {:code => 202, :result => "AP exists", :body => {:tunnel_id => ap_state[:tunnel_id].to_s}}
175
+ output_params = {:code => 202, :result => 'AP exists', :body => {:tunnel_id => ap_state[:tunnel_id].to_s}}
176
176
  end
177
177
  rescue
178
- output_params = {:code => 507, :result => "Unknown SDK error"}
178
+ output_params = {:code => 507, :result => 'Unknown SDK error'}
179
179
  end
180
- mongo_connector_wifi_1.audit_logger_wifi_1("add_mikrotik_ap_mobile_1", remote_ip, input_params, output_params, real_ip, subscriber_ip)
180
+ mongo_connector_wifi_1.audit_logger_wifi_1('add_mikrotik_ap_mobile_1', remote_ip, input_params, output_params, real_ip, subscriber_ip)
181
181
  #additional_func.printer_texter({:input_params => input_params, :output_params => output_params, :procedure => "add_mikrotik_ap_mobile", :file => "freewifi.rb"}, "info")
182
182
  output_params
183
183
  end
@@ -211,9 +211,9 @@ module Freewifi_1
211
211
  output_params = {:code => res[:code], :result => res[:result], :body => {:ap_configuration => conf_1}}
212
212
 
213
213
  rescue
214
- output_params = {:code => 507, :result => "Unknown SDK error"}
214
+ output_params = {:code => 507, :result => 'Unknown SDK error'}
215
215
  end
216
- mongo_connector_wifi_1.audit_logger_wifi_1("mtik_sch1_config_gen_1", remote_ip, input_params, conf_1, real_ip, subscriber_ip)
216
+ mongo_connector_wifi_1.audit_logger_wifi_1('mtik_sch1_config_gen_1', remote_ip, input_params, conf_1, real_ip, subscriber_ip)
217
217
  output_params
218
218
  end
219
219
 
@@ -243,10 +243,11 @@ module Freewifi_1
243
243
  def test()
244
244
  newcapsman1 = NEWhubWifi_1.new
245
245
 
246
+ capsman_ip = ['1.1.1.1']
246
247
  threads = []
247
248
  capsman_ip.each do |capsman|
248
249
  threads << Thread.new do
249
- newcapsman1.set_capsman_config_1("test_ss", capsman, capsman_user, capsman_password, "172.25.208.14", "test_company")
250
+ newcapsman1.set_capsman_config_1('test_ss', capsman, capsman_user, capsman_password, '172.25.208.14', 'test_company')
250
251
  end
251
252
  end
252
253
  threads.each(&:join)
@@ -302,7 +303,9 @@ class PortalFwifi_1
302
303
  iwag2_username,
303
304
  iwag2_password,
304
305
  iwag1_port=22,
305
- 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']
306
309
  )
307
310
 
308
311
  @general_procedures = WiFiPortal_1.new(apigw_wsdl,
@@ -324,7 +327,9 @@ class PortalFwifi_1
324
327
  iwag2_host,
325
328
  iwag2_username,
326
329
  iwag2_password,
327
- iwag2_port
330
+ iwag2_port,
331
+ protocol_mtik,
332
+ mtik_capsman_list
328
333
  )
329
334
  @mtik_control_ips_get = mtik_control_ips_get
330
335
  @mtik_user = mtik_user
@@ -347,18 +352,18 @@ class PortalFwifi_1
347
352
  resp_procedure = general_procedures.get_subs_info_return_1(ipaddress)
348
353
  output_params = resp_procedure
349
354
  rescue
350
- output_params = {:code => 507, :result => "Unknown SDK error"}
355
+ output_params = {:code => 507, :result => 'Unknown SDK error'}
351
356
  end
352
357
  end
353
358
  subs_info_ret_1_thr1.join
354
359
 
355
360
  subs_info_ret_1_thr2 = Thread.new do
356
361
  begin
357
- p "mongo"
362
+ p 'mongo'
358
363
  #mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database)
359
364
  #mongo_connector_wifi_1.audit_logger_wifi_portal_1("wifi_get_subs_info_return_1", remote_ip, input_params, output_params, real_ip)
360
365
  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")
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')
362
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)
363
368
  end
364
369
  end
@@ -377,7 +382,7 @@ class PortalFwifi_1
377
382
  resp_procedure = general_procedures.get_subs_info_ret_ssh_1(ipaddress)
378
383
  output_params = resp_procedure
379
384
  rescue
380
- output_params = {:code => 507, :result => "Unknown SDK error"}
385
+ output_params = {:code => 507, :result => 'Unknown SDK error'}
381
386
  end
382
387
  end
383
388
  subs_info_ret_1_thr1.join
@@ -388,7 +393,7 @@ class PortalFwifi_1
388
393
  #mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database)
389
394
  #mongo_connector_wifi_1.audit_logger_wifi_portal_1("wifi_get_subs_info_return_1", remote_ip, input_params, output_params, real_ip)
390
395
  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")
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")
392
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)
393
398
  end
394
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.3
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-20 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