freewifi 0.2.1 → 0.2.5
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.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.idea/freewifi.iml +96 -1
- 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 +482 -159
- 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 +91 -0
- data/lib/freewifi/cisco/iwag/iwag_database_worker.rb +24 -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 +460 -19
- 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 +68 -26
- metadata +9 -6
data/.travis.yml
CHANGED
File without changes
|
data/CODE_OF_CONDUCT.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
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 =
|
7
|
+
spec.name = 'freewifi'
|
8
8
|
spec.version = Freewifi_1::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
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 =
|
15
|
-
spec.license =
|
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[
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
|
21
21
|
else
|
22
|
-
raise
|
23
|
-
|
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 =
|
29
|
+
spec.bindir = 'exe'
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
-
spec.require_paths = [
|
31
|
+
spec.require_paths = ['lib']
|
32
32
|
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
38
|
-
spec.add_development_dependency
|
39
|
-
spec.add_development_dependency
|
40
|
-
spec.add_development_dependency
|
41
|
-
spec.add_development_dependency
|
42
|
-
spec.add_development_dependency
|
43
|
-
spec.add_development_dependency
|
44
|
-
spec.add_development_dependency
|
45
|
-
spec.add_development_dependency
|
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 =>
|
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 =>
|
30
|
+
return {:code => 507, :result => 'Unknown SDK error'}
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
File without changes
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'net/ssh'
|
2
|
+
|
3
|
+
class IwagRequester
|
4
|
+
|
5
|
+
attr_accessor :iwag_host, :iwag_login, :iwag_password, :iwag_port
|
6
|
+
|
7
|
+
def initialize(iwag_host, iwag_login, iwag_password, iwag_port)
|
8
|
+
@iwag_host = iwag_host
|
9
|
+
@iwag_login = iwag_login
|
10
|
+
@iwag_password = iwag_password
|
11
|
+
@iwag_port = iwag_port
|
12
|
+
end
|
13
|
+
|
14
|
+
def mac_parse(mac)
|
15
|
+
a = mac.upcase
|
16
|
+
pos = a[0] + a[1]
|
17
|
+
if pos == "01"
|
18
|
+
subscribers_mac = a[2] + a[3] + ":" + a[5] + a[6] + ":" + a[7] + a[8] + ":" + a[10] + a[11] + ":" + a[12] + a[13] + ":" + a[15] + a[16]
|
19
|
+
else
|
20
|
+
subscribers_mac = a[0] + a[1] + ":" + a[2] + a[3] + ":" + a[5] + a[6] + ":" + a[7] + a[8] + ":" + a[10] + a[11] + ":" + a[12] + a[13]
|
21
|
+
end
|
22
|
+
subscribers_mac
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def iwag_get_dhcp_binding_ssh(bind_ip)
|
27
|
+
mac = "Unknown"
|
28
|
+
accessinterface = "Unknown"
|
29
|
+
hostname = "Unknown"
|
30
|
+
ssid = "Unknown"
|
31
|
+
iwag_thr = Thread.new do
|
32
|
+
Net::SSH.start(iwag_host, iwag_login, :password => iwag_password, :port=>iwag_port) do |session|
|
33
|
+
answ_bind = session.exec!("show ip dhcp binding #{bind_ip}")
|
34
|
+
regexp_main = /\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s{1,20}(\w{2,4}.\w{2,4}.\w{2,4}.\w{2,4})|\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s{1,20}(\w{4}.\w{4}.\w{4})/
|
35
|
+
#regexp_main = /\r\n(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s+(\S{13,18})\s+Sep 18 2020 07:44 PM\s+Automatic\s+Active\s+Tunnel201\r\n/
|
36
|
+
ggg7 = answ_bind.match(regexp_main)
|
37
|
+
begin
|
38
|
+
if ggg7[1] != nil
|
39
|
+
mac = mac_parse(ggg7[1])
|
40
|
+
else
|
41
|
+
mac = mac_parse(ggg7[2])
|
42
|
+
end
|
43
|
+
rescue
|
44
|
+
mac = "Unknown"
|
45
|
+
end
|
46
|
+
regexp_remote_id = /Remote id :\s(\S{2,100})/
|
47
|
+
regexp_tunnel = /Active\s{2,40}(\S{2,40})|Selecting\s{2,40}(\S{2,40})/
|
48
|
+
regexp_curcuit_id = /Circuit id :\s(\S{2,100})/
|
49
|
+
ggg9 = answ_bind.match(regexp_tunnel)
|
50
|
+
|
51
|
+
begin
|
52
|
+
if ggg9[1] != nil
|
53
|
+
accessinterface = ggg9[1]
|
54
|
+
else
|
55
|
+
accessinterface = ggg9[2]
|
56
|
+
end
|
57
|
+
rescue
|
58
|
+
accessinterface = "Unknown"
|
59
|
+
end
|
60
|
+
ggg8 = answ_bind.match(regexp_remote_id)
|
61
|
+
ggg10 = answ_bind.match(regexp_curcuit_id)
|
62
|
+
begin
|
63
|
+
a1 = ggg8[1].split(":")
|
64
|
+
hostname = a1[0]
|
65
|
+
ssid = a1[1]
|
66
|
+
rescue
|
67
|
+
begin
|
68
|
+
if ggg8[1] != nil
|
69
|
+
if ggg8[1].include?("wireless_public_interface")
|
70
|
+
hostname = ggg10[1]
|
71
|
+
ssid = "Unknown"
|
72
|
+
else
|
73
|
+
hostname = ggg8[1]
|
74
|
+
ssid = "Unknown"
|
75
|
+
end
|
76
|
+
else
|
77
|
+
ssid = "Unknown"
|
78
|
+
hostname = "Unknown"
|
79
|
+
end
|
80
|
+
rescue
|
81
|
+
ssid = "Unknown"
|
82
|
+
hostname = "Unknown"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
iwag_thr.join
|
88
|
+
{"mac": mac, "iwaginterface": accessinterface, "aphostname": hostname, "SSID": ssid}
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class IwagDbCache
|
4
|
+
|
5
|
+
attr_accessor :db_host, :db_login, :db_password
|
6
|
+
|
7
|
+
def initialize(db_host, db_login, db_password)
|
8
|
+
@db_host = db_host
|
9
|
+
@db_login = db_login
|
10
|
+
@db_password = db_password
|
11
|
+
end
|
12
|
+
|
13
|
+
def check_db_exists(ip)
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def insert_new_cache()
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -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" =>
|
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" =>
|
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" =>
|
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|
|
data/lib/freewifi/config.rb
CHANGED
File without changes
|
File without changes
|