freewifi 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/freewifi.iml +22 -2
- data/.idea/workspace.xml +161 -182
- data/freewifi.gemspec +2 -1
- data/lib/freewifi/additional/additional_functions.rb +29 -9
- data/lib/freewifi/cisco/cisco_schemes_conf_gen.rb +12 -0
- data/lib/freewifi/config.rb +4 -0
- data/lib/freewifi/database/mongo/mongoconnector.rb +24 -19
- data/lib/freewifi/database/mysql/database_methods_wifi.rb +1 -1
- data/lib/freewifi/mikrotik/newhub_mtik_ssh.rb +321 -0
- data/lib/freewifi/mikrotik/schemes_conf_gen.rb +54 -0
- data/lib/freewifi/params.rb +6 -0
- data/lib/freewifi/version.rb +2 -2
- data/lib/freewifi.rb +119 -43
- metadata +20 -2
- data/lib/freewifi/mikrotik/hewhub_mtik_ssh.rb +0 -204
data/lib/freewifi/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "0.1.
|
1
|
+
module Freewifi_1
|
2
|
+
VERSION = "0.1.5"
|
3
3
|
end
|
data/lib/freewifi.rb
CHANGED
@@ -5,44 +5,63 @@ $LOAD_PATH.unshift File.expand_path("../database/mongo", __dir__)
|
|
5
5
|
$LOAD_PATH.unshift File.expand_path("../additional", __dir__)
|
6
6
|
|
7
7
|
require "freewifi/version"
|
8
|
-
require
|
8
|
+
require "freewifi/params"
|
9
|
+
require "freewifi/config"
|
10
|
+
require 'freewifi/mikrotik/newhub_mtik_ssh'
|
11
|
+
require 'freewifi/mikrotik/schemes_conf_gen'
|
9
12
|
require 'freewifi/database/mysql/database_methods_wifi'
|
10
13
|
require 'freewifi/database/mongo/mongoconnector'
|
11
14
|
require 'date'
|
15
|
+
require 'json'
|
12
16
|
|
13
17
|
#eoip tunnel ids generates between 10001 - 65535
|
18
|
+
#frewifi SDK with SDK id = 1
|
14
19
|
|
15
|
-
|
16
|
-
module Freewifi
|
20
|
+
module Freewifi_1
|
17
21
|
attr_accessor :mtik_hub1_ip,
|
18
22
|
:mtik_hub2_ip,
|
19
23
|
:user_hub,
|
20
24
|
:password_hub,
|
21
25
|
:cps_class,
|
22
26
|
:db_mysql,
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
27
|
+
:additional_func_wifi_1,
|
28
|
+
:ssh_mikrotik_connector_1,
|
29
|
+
:mongo_connector_wifi_1,
|
26
30
|
:remote_ip,
|
27
31
|
:real_ip,
|
28
|
-
:subscriber_ip
|
32
|
+
:subscriber_ip,
|
33
|
+
:capsman_ip_man,
|
34
|
+
:capsman_user,
|
35
|
+
:capsman_password,
|
36
|
+
:mtik_config_gen_1,
|
37
|
+
:hub_vip,
|
38
|
+
:ap_admin_password,
|
39
|
+
:capsman_ip_wifi
|
40
|
+
|
29
41
|
|
30
|
-
def initialize(hub1ip, hub2ip, username_hub, password_hub, database_username, database_password, database_host, mongo_ip, mongo_port, mongo_database, remote_ip, real_ip, subscriber_ip)
|
42
|
+
def initialize(hub1ip, hub2ip, username_hub, password_hub, database_username, database_password, database_host, mongo_ip, mongo_port, mongo_database, remote_ip, real_ip, subscriber_ip, capsman_ip, capsman_user, capsman_password, hub_vip, ap_admin_password, capsman_ip_wifi)
|
31
43
|
@mtik_hub1_ip = hub1ip
|
32
44
|
@mtik_hub2_ip = hub2ip
|
33
45
|
@user_hub = username_hub
|
34
46
|
@password_hub = password_hub
|
35
|
-
@db_mysql =
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
47
|
+
@db_mysql = DatabaseMethodsWifi_1.new(database_username, database_password, database_host)
|
48
|
+
@additional_func_wifi_1 = InternalFunc_1.new
|
49
|
+
@ssh_mikrotik_connector_1 = NEWhubWifi_1.new
|
50
|
+
@mongo_connector_wifi_1 = MongoWifiCl_1.new(mongo_ip, mongo_port, mongo_database)
|
39
51
|
@remote_ip = remote_ip
|
40
52
|
@real_ip = real_ip
|
41
53
|
@subscriber_ip = subscriber_ip
|
54
|
+
@capsman_ip = capsman_ip
|
55
|
+
@capsman_user = capsman_user
|
56
|
+
@capsman_password = capsman_password
|
57
|
+
@mtik_config_gen_1 = MtikSchemesGen_1.new
|
58
|
+
@hub_vip = hub_vip
|
59
|
+
@ap_admin_password = ap_admin_password
|
60
|
+
@capsman_ip_wifi = capsman_ip_wifi
|
42
61
|
end
|
43
62
|
|
44
63
|
|
45
|
-
def
|
64
|
+
def add_mikrotik_ap_mobile_1(sim_ipaddress, sim_msisdn, bridge_name_hub, company_name, subscribers_address, subscribers_region, subscribers_contacts, wifi_ssid, portalstyle, ap_serial_number, ap_model, description, note)
|
46
65
|
|
47
66
|
input_params = {:sim_ipaddress => sim_ipaddress,
|
48
67
|
:sim_msisdn => sim_msisdn,
|
@@ -62,18 +81,18 @@ module Freewifi
|
|
62
81
|
|
63
82
|
begin
|
64
83
|
|
65
|
-
processed_comp_name =
|
84
|
+
processed_comp_name = additional_func_wifi_1.company_check_wifi_1(company_name)
|
66
85
|
#p ap_state = db_mysql.check_mikrotik_ap_exists(sim_ipaddress, sim_msisdn).to_s
|
67
|
-
ap_state =
|
86
|
+
ap_state = mongo_connector_wifi_1.get_ap_info_sim_ip_wifi_1(sim_ipaddress, sim_msisdn)[:body]
|
68
87
|
|
69
|
-
if ap_state == "" || ap_state == nil || ap_state == "[]" || ap_state == "fttx"
|
70
|
-
tunnel_addition =
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
88
|
+
if ap_state[:all_mongo].to_s == "" || ap_state[:all_mongo].to_s == nil || ap_state[:all_mongo].to_s == "[]" || ap_state[:all_mongo].to_s == "fttx"
|
89
|
+
tunnel_addition = ssh_mikrotik_connector_1.add_eoip_for_mikr_wifi_1(bridge_name_hub,
|
90
|
+
sim_ipaddress,
|
91
|
+
processed_comp_name,
|
92
|
+
mtik_hub1_ip,
|
93
|
+
mtik_hub2_ip,
|
94
|
+
user_hub,
|
95
|
+
password_hub)
|
77
96
|
|
78
97
|
|
79
98
|
if tunnel_addition[:code] == 200
|
@@ -97,8 +116,18 @@ module Freewifi
|
|
97
116
|
:created_date => DateTime.now
|
98
117
|
}
|
99
118
|
|
100
|
-
mongo_response =
|
119
|
+
mongo_response = mongo_connector_wifi_1.data_ap_auto_created_insert_1(data)
|
101
120
|
if mongo_response[:code]==200
|
121
|
+
newcapsman1 = NEWhubWifi_1.new
|
122
|
+
|
123
|
+
threads = []
|
124
|
+
capsman_ip.each do |capsman|
|
125
|
+
threads << Thread.new do
|
126
|
+
newcapsman1.set_capsman_config_1(additional_func_wifi_1.prep_ssid_for_config_1(wifi_ssid), capsman, capsman_user, capsman_password, sim_ipaddress, additional_func_wifi_1.prep_comp_name_for_config_1(company_name))
|
127
|
+
end
|
128
|
+
end
|
129
|
+
threads.each(&:join)
|
130
|
+
|
102
131
|
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]}}
|
103
132
|
else
|
104
133
|
output_params = {:code => 400, :result => "Something wrong with insertion to mongo"}
|
@@ -107,45 +136,92 @@ module Freewifi
|
|
107
136
|
output_params = {:code => 401, :result => tunnel_addition[:result]}
|
108
137
|
end
|
109
138
|
else
|
110
|
-
output_params = {:code => 202, :result => "AP exists"}
|
139
|
+
output_params = {:code => 202, :result => "AP exists", :body => {:tunnel_id => ap_state[:tunnel_id].to_s}}
|
111
140
|
end
|
112
141
|
rescue
|
113
142
|
output_params = {:code => 507, :result => "Unknown SDK error"}
|
114
143
|
end
|
115
|
-
|
144
|
+
mongo_connector_wifi_1.audit_logger_wifi_1("add_mikrotik_ap_mobile", remote_ip, input_params, output_params, real_ip, subscriber_ip)
|
116
145
|
#additional_func.printer_texter({:input_params => input_params, :output_params => output_params, :procedure => "add_mikrotik_ap_mobile", :file => "freewifi.rb"}, "info")
|
117
146
|
output_params
|
118
147
|
end
|
119
148
|
|
120
149
|
|
150
|
+
def mtik_sch1_config_gen_1(sim_ipaddress, sim_msisdn, bridge_name_hub, company_name, subscribers_address, subscribers_region, subscribers_contacts, wifi_ssid, portalstyle, ap_serial_number, ap_model, description, note)
|
151
|
+
input_params = {:sim_ipaddress => sim_ipaddress,
|
152
|
+
:sim_msisdn => sim_msisdn,
|
153
|
+
:bridge_name_hub => bridge_name_hub,
|
154
|
+
:company_name => company_name,
|
155
|
+
:subscribers_address => subscribers_address,
|
156
|
+
:subscribers_region => subscribers_region,
|
157
|
+
:subscribers_contacts => subscribers_contacts,
|
158
|
+
:wifi_ssid => wifi_ssid,
|
159
|
+
:portalstyle => portalstyle,
|
160
|
+
:ap_serial_number => ap_serial_number,
|
161
|
+
:ap_model => ap_model,
|
162
|
+
:description => description,
|
163
|
+
:note => note
|
164
|
+
}
|
165
|
+
output_params = {}
|
166
|
+
|
167
|
+
begin
|
168
|
+
|
169
|
+
res = self.add_mikrotik_ap_mobile_1(sim_ipaddress, sim_msisdn, bridge_name_hub, company_name, subscribers_address, subscribers_region, subscribers_contacts, wifi_ssid, portalstyle, ap_serial_number, ap_model, description, note)
|
170
|
+
tun_id = res[:body][:tunnel_id]
|
171
|
+
hostname = additional_func_wifi_1.ap_hostname_generator(company_name, tun_id)
|
172
|
+
conf_1 = mtik_config_gen_1.scheme1_3g_config_gen_1(hostname, tun_id, hub_vip, ap_admin_password, wifi_ssid, capsman_ip_wifi)
|
173
|
+
output_params = {:code => 200, :result => "Request completed successfully", :body => {:ap_configuration => conf_1}}
|
174
|
+
|
175
|
+
rescue
|
176
|
+
output_params = {:code => 507, :result => "Unknown SDK error"}
|
177
|
+
end
|
178
|
+
mongo_connector_wifi_1.audit_logger_wifi_1("mtik_sch1_config_gen_1", remote_ip, input_params, conf_1, real_ip, subscriber_ip)
|
179
|
+
output_params
|
180
|
+
end
|
181
|
+
|
182
|
+
|
121
183
|
def add_eoip_for_mikr_hub(bridge_name, ap_ip_address, tunnel_name)
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
184
|
+
newhub_1 = NEWhubWifi_1.new
|
185
|
+
newhub_1.add_eoip_for_mikr_wifi_1(bridge_name,
|
186
|
+
ap_ip_address,
|
187
|
+
tunnel_name,
|
188
|
+
mtik_hub1_ip,
|
189
|
+
mtik_hub2_ip,
|
190
|
+
user_hub,
|
191
|
+
password_hub)
|
130
192
|
end
|
131
193
|
|
132
|
-
def
|
133
|
-
newhub1 =
|
134
|
-
newhub1.
|
194
|
+
def del_one_eoip_from_mikr_hub_1(tunnel_id)
|
195
|
+
newhub1 = NEWhubWifi_1.new
|
196
|
+
newhub1.del_eoip_for_mikr_1(tunnel_id, mtik_hub1_ip, mtik_hub2_ip, user_hub, password_hub)
|
135
197
|
p tid = tunnel_id.to_i
|
136
|
-
|
198
|
+
mongo_connector_wifi_1.tunnelid_remove_single_mongo_1(tid)
|
199
|
+
end
|
200
|
+
|
201
|
+
def cellular_mtik_ap_conf_gen_1(scheme_number)
|
202
|
+
|
137
203
|
end
|
138
204
|
|
139
205
|
def test()
|
140
|
-
|
141
|
-
|
142
|
-
|
206
|
+
newcapsman1 = NEWhubWifi_1.new
|
207
|
+
|
208
|
+
threads = []
|
209
|
+
capsman_ip.each do |capsman|
|
210
|
+
threads << Thread.new do
|
211
|
+
newcapsman1.set_capsman_config_1("test_ss", capsman, capsman_user, capsman_password, "172.25.208.14", "test_company")
|
212
|
+
end
|
213
|
+
end
|
214
|
+
threads.each(&:join)
|
215
|
+
|
216
|
+
#newhub1.hub_get_all_eoip_tunnels_1("172.24.223.132", "soapgw", "fr8Hn3Ed2k0Im4gWmav2Nh7Y1qAm8KlmRh3Dcu2Wcok5gBdm")
|
217
|
+
#mongo_connector_wifi_1.data_ap_auto_created_insert_1(:test => "test")
|
143
218
|
end
|
219
|
+
|
144
220
|
end
|
145
221
|
|
146
222
|
|
147
|
-
class
|
148
|
-
include
|
223
|
+
class Fwifi_1
|
224
|
+
include Freewifi_1
|
149
225
|
end
|
150
226
|
|
151
227
|
|
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dzmitry Buynovskiy
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 2.11.4
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: translit
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.1.5
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.1.5
|
139
153
|
description: description for my gem
|
140
154
|
email:
|
141
155
|
- imperituro.ard@gmail.com
|
@@ -161,10 +175,14 @@ files:
|
|
161
175
|
- freewifi.gemspec
|
162
176
|
- lib/freewifi.rb
|
163
177
|
- lib/freewifi/additional/additional_functions.rb
|
178
|
+
- lib/freewifi/cisco/cisco_schemes_conf_gen.rb
|
179
|
+
- lib/freewifi/config.rb
|
164
180
|
- lib/freewifi/database/mongo/mongoconnector.rb
|
165
181
|
- lib/freewifi/database/mysql/database_methods_wifi.rb
|
166
182
|
- lib/freewifi/mikrotik/getsubscribermikrotik.rb
|
167
|
-
- lib/freewifi/mikrotik/
|
183
|
+
- lib/freewifi/mikrotik/newhub_mtik_ssh.rb
|
184
|
+
- lib/freewifi/mikrotik/schemes_conf_gen.rb
|
185
|
+
- lib/freewifi/params.rb
|
168
186
|
- lib/freewifi/version.rb
|
169
187
|
homepage: https://rubygems.org/gems/freewifi
|
170
188
|
licenses:
|