freewifi 0.1.6 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,142 @@
1
+ require 'net-telnet'
2
+
3
+ class HuaWifi_1
4
+
5
+ attr_accessor :hua_wlc_1_ip, :hua_wlc_2_ip, :hua_wlc_login, :hua_wlc_password
6
+
7
+ def initialize(hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password)
8
+ @hua_wlc_1_ip = hua_wlc_1_ip
9
+ @hua_wlc_2_ip = hua_wlc_2_ip
10
+ @hua_wlc_login = hua_wlc_login
11
+ @hua_wlc_password = hua_wlc_password
12
+ end
13
+
14
+
15
+ def get_sub_info_1(mac)
16
+
17
+ subscribers_mac =mac
18
+ access_point = "unknown"
19
+ ssid_ap = "unknown"
20
+ tx_rate_set = "unknown"
21
+ tx_rate = "unknown"
22
+ rx_rate = "unknown"
23
+ rx_signal = "unknown"
24
+ uptime = "unknown"
25
+ packets = "unknown"
26
+ bytes = "unknown"
27
+
28
+
29
+ begin
30
+ p macaddr1 = mac.downcase
31
+ p macaddr2 = macaddr1[0]+macaddr1[1]+macaddr1[3]+macaddr1[4]+"-"+macaddr1[6]+macaddr1[7]+macaddr1[9]+macaddr1[10]+"-"+macaddr1[12]+macaddr1[13]+macaddr1[15]+macaddr1[16]
32
+
33
+ dump = ""
34
+ connection = Net::Telnet.new( "Host" => hua_wlc_1_ip, "Timeout" => 10, "Prompt" => /.*>/ ) { |str| print str }
35
+ connection.login({ "Name" => hua_wlc_login, "Password" => hua_wlc_password, "LoginPrompt" => /Username:/ }) { |str| }
36
+ connection.cmd("system-view\n display station sta-mac #{macaddr2}\n quit \n") {
37
+ |c|
38
+ dump << c
39
+ }
40
+ connection.close
41
+
42
+
43
+ iter1 = dump.split("\n")
44
+ ssid_ap = iter1[7].split(" ")[3]
45
+ temmmm=""
46
+ temmmm1="1"
47
+ i=0
48
+ while i < iter1.length
49
+ if iter1[i].include? "AP Name"
50
+ temmmm = iter1[i]
51
+ elsif iter1[i].include? "Station's Channel Band-width" && "20MHz"
52
+ temmmm1="0"
53
+ end
54
+ i+=1
55
+ end
56
+
57
+ if temmmm1=="0"
58
+ access_point = temmmm.gsub!("Station's AP Name","").gsub!(" ","").gsub(":","")+"-1"
59
+ else
60
+ access_point = temmmm.gsub!("Station's AP Name","").gsub!(" ","").gsub(":","")+"-2"
61
+ end
62
+ tx_rate_set = iter1[11].split(" ")[4]
63
+ rx_signal = iter1[10].split(" ")[6]
64
+ uptime = iter1[8].split(" ")[4]
65
+ # p iter1 = dump.split("----------------------------------------------------------------------------------------------------")
66
+ # p iter2 = iter1[2]
67
+ # p iter3 = iter2.split("\n")
68
+ # i = 1
69
+ # while i<iter3.length
70
+ # p iter4 = iter3[i].split(" ")
71
+ # i+=1
72
+ # end
73
+
74
+ rescue
75
+
76
+ p "failed to get info from huawei controller1"
77
+ end
78
+
79
+ return subscribers_mac+ ",,," + access_point + ",,," + ssid_ap + ",,," + tx_rate_set + ",,,"+ tx_rate + ",,,"+ rx_rate + ",,,"+ rx_signal + ",,,"+ uptime + ",,,"+ packets + ",,,"+ bytes
80
+
81
+ end
82
+
83
+
84
+
85
+ def get_sub_info2_1(mac)
86
+
87
+ subscribers_mac =mac
88
+ access_point = "unknown"
89
+ ssid_ap = "unknown"
90
+ tx_rate_set = "unknown"
91
+ tx_rate = "unknown"
92
+ rx_rate = "unknown"
93
+ rx_signal = "unknown"
94
+ uptime = "unknown"
95
+ packets = "unknown"
96
+ bytes = "unknown"
97
+
98
+
99
+ begin
100
+ macaddr1 = mac.downcase
101
+ macaddr2 = macaddr1[0]+macaddr1[1]+macaddr1[3]+macaddr1[4]+"-"+macaddr1[6]+macaddr1[7]+macaddr1[9]+macaddr1[10]+"-"+macaddr1[12]+macaddr1[13]+macaddr1[15]+macaddr1[16]
102
+
103
+ dump = ""
104
+ connection = Net::Telnet.new( "Host" => hua_wlc_2_ip, "Timeout" => 10, "Prompt" => /.*>/ ) { |str| print str }
105
+ connection.login({ "Name" => hua_wlc_login, "Password" => hua_wlc_password, "LoginPrompt" => /Username:/ }) { |str| }
106
+ connection.cmd("system-view\n display station sta-mac #{macaddr2}\n quit \n") {
107
+ |c|
108
+ dump << c
109
+ }
110
+ connection.close
111
+
112
+
113
+ iter1 = dump.split("\n")
114
+ ssid_ap = iter1[7].split(" ")[3]
115
+ if iter1[41].gsub!(" ","").split(":")[1]=="20MHz"
116
+ access_point = iter1[35].gsub!("Station's AP Name","").gsub!(" ","").gsub(":","")+"-1"
117
+ else
118
+ access_point = iter1[35].gsub!("Station's AP Name","").gsub!(" ","").gsub(":","")+"-2"
119
+ end
120
+ tx_rate_set = iter1[11].split(" ")[4]
121
+ rx_signal = iter1[10].split(" ")[6]
122
+ uptime = iter1[8].split(" ")[4]
123
+ # p iter1 = dump.split("----------------------------------------------------------------------------------------------------")
124
+ # p iter2 = iter1[2]
125
+ # p iter3 = iter2.split("\n")
126
+ # i = 1
127
+ # while i<iter3.length
128
+ # p iter4 = iter3[i].split(" ")
129
+ # i+=1
130
+ # end
131
+
132
+ rescue
133
+
134
+ p "failed to get info from huawei controller1"
135
+ end
136
+
137
+ return subscribers_mac+ ",,," + access_point + ",,," + ssid_ap + ",,," + tx_rate_set + ",,,"+ tx_rate + ",,,"+ rx_rate + ",,,"+ rx_signal + ",,,"+ uptime + ",,,"+ packets + ",,,"+ bytes
138
+
139
+ end
140
+
141
+
142
+ end
@@ -0,0 +1,99 @@
1
+ require 'mtik'
2
+
3
+ class NEWhubWifiApi_1
4
+
5
+ attr_accessor :mtik_control_ips_get, :mtik_user, :mtik_password
6
+
7
+ def initialize(mtik_control_ips_get, mtik_user, mtik_password)
8
+ @mtik_control_ips_get = mtik_control_ips_get
9
+ @mtik_user = mtik_user
10
+ @mtik_password = mtik_password
11
+ end
12
+
13
+
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']
47
+ end
48
+ end
49
+ end
50
+ end
51
+
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
63
+
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
+ end
91
+
92
+ #endregion
93
+ answ = subscribers_mac+ "---" + access_point + "---" + ssid_ap + "---" + tx_rate_set + "---"+ tx_rate + "---"+ rx_rate + "---"+ rx_signal + "---"+ uptime + "---"+ packets + "---"+ bytes
94
+
95
+ answ
96
+
97
+ end
98
+
99
+ end
@@ -243,9 +243,9 @@ class NEWhubWifi_1
243
243
  conf_5ghz_name = "auto_cfg_5ghz_#{companyname}_#{wifissid}"
244
244
  command_conf_5ghz = "/caps-man configuration add name=#{conf_5ghz_name} ssid=#{wifissid} country=belarus mode=ap hw-retries=15 channel=5_channel_5GHz_number1_power23 datapath=1_datapath_MTS_Local-forwarding security=security_without_passphrase_default_FREE-WiFi"
245
245
 
246
- command_provisioning_24ghz = "/caps-man provisioning add hw-supported-modes=b,g,gn ip-address-ranges=#{ap_ip} action=create-dynamic-enabled master-configuration=#{conf_24ghz_name} name-format=identity"
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 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_24ghz_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)
@@ -1,3 +1,3 @@
1
1
  module Freewifi_1
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.1"
3
3
  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.1.6
4
+ version: 0.2.1
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-04-27 00:00:00.000000000 Z
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,6 +150,48 @@ dependencies:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.1.5
153
+ - !ruby/object:Gem::Dependency
154
+ name: savon
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 2.12.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 2.12.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: net-telnet
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.2.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 0.2.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: mtik
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 4.0.3
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 4.0.3
153
195
  description: description for my gem
154
196
  email:
155
197
  - imperituro.ard@gmail.com
@@ -175,11 +217,16 @@ files:
175
217
  - freewifi.gemspec
176
218
  - lib/freewifi.rb
177
219
  - lib/freewifi/additional/additional_functions.rb
178
- - lib/freewifi/cisco/cisco_schemes_conf_gen.rb
220
+ - lib/freewifi/cisco/any/cisco_schemes_conf_gen.rb
221
+ - lib/freewifi/cisco/iwag/iwag_telnet_connector.rb
179
222
  - lib/freewifi/config.rb
180
223
  - lib/freewifi/database/mongo/mongoconnector.rb
181
224
  - lib/freewifi/database/mysql/database_methods_wifi.rb
225
+ - lib/freewifi/general/wifi_portal_procedures.rb
226
+ - lib/freewifi/huawei/hua_controller_class.rb
227
+ - lib/freewifi/mikrotik/automation/get_data_ssh_fun.rb
182
228
  - lib/freewifi/mikrotik/getsubscribermikrotik.rb
229
+ - lib/freewifi/mikrotik/newhub_mtik_api.rb
183
230
  - lib/freewifi/mikrotik/newhub_mtik_ssh.rb
184
231
  - lib/freewifi/mikrotik/schemes_conf_gen.rb
185
232
  - lib/freewifi/params.rb