freewifi 0.1.6 → 0.1.7
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/.idea/freewifi.iml +32 -0
- data/.idea/workspace.xml +230 -127
- data/freewifi.gemspec +3 -0
- data/lib/freewifi/cisco/{cisco_schemes_conf_gen.rb → any/cisco_schemes_conf_gen.rb} +0 -0
- data/lib/freewifi/cisco/iwag/iwag_telnet_connector.rb +98 -0
- data/lib/freewifi/database/mongo/mongoconnector.rb +24 -0
- data/lib/freewifi/general/wifi_portal_procedures.rb +669 -0
- data/lib/freewifi/huawei/hua_controller_class.rb +142 -0
- data/lib/freewifi/mikrotik/newhub_mtik_api.rb +97 -0
- data/lib/freewifi/version.rb +1 -1
- data/lib/freewifi.rb +109 -5
- metadata +49 -3
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'net-telnet'
|
2
|
+
require 'net/ssh'
|
3
|
+
|
4
|
+
class CSRtelnet_1
|
5
|
+
|
6
|
+
attr_accessor :iwag1_host, :iwag_username, :iwag_password
|
7
|
+
|
8
|
+
def initialize(iwag1_host, iwag_username, iwag_password)
|
9
|
+
@iwag1_host = iwag1_host
|
10
|
+
@iwag_username = iwag_username
|
11
|
+
@iwag_password = iwag_password
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_subs_mac2_1(ipaddress)
|
15
|
+
|
16
|
+
subscribers_mac = ""
|
17
|
+
|
18
|
+
begin
|
19
|
+
|
20
|
+
dump =""
|
21
|
+
connection = Net::Telnet.new( "Host" => "172.24.247.183", "Timeout" => false, "Prompt" => /.*\#/ ) { |str| }
|
22
|
+
connection.login({ "Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/ }) { |str| }
|
23
|
+
connection.cmd("show ip dhcp binding #{ipaddress}") {
|
24
|
+
|c|
|
25
|
+
dump << c
|
26
|
+
}
|
27
|
+
connection.close
|
28
|
+
as = dump.split("\n")
|
29
|
+
reer = as[4].split(" ")
|
30
|
+
|
31
|
+
ma = reer[1].to_s.upcase
|
32
|
+
pos = ma[0]+ma[1]
|
33
|
+
if pos=="01"
|
34
|
+
subscribers_mac = ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]+":"+ma[15]+ma[16]
|
35
|
+
else
|
36
|
+
subscribers_mac = ma[0]+ma[1]+":"+ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
rescue
|
41
|
+
subscribers_mac = "unknown"
|
42
|
+
end
|
43
|
+
|
44
|
+
return subscribers_mac
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
def return_iwag_access_interface_1(ipaddress)
|
51
|
+
host_iwag = iwag1_host
|
52
|
+
username_iwag = iwag_username
|
53
|
+
password_iwag = iwag_password
|
54
|
+
answer =""
|
55
|
+
|
56
|
+
dump =""
|
57
|
+
begin
|
58
|
+
connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
|
59
|
+
connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
|
60
|
+
connection.cmd("show ip dhcp binding #{ipaddress}") {
|
61
|
+
|c|
|
62
|
+
dump << c
|
63
|
+
}
|
64
|
+
connection.close
|
65
|
+
as = dump.split("\n")
|
66
|
+
|
67
|
+
if as[4] != nil && as[3] != ""
|
68
|
+
access_interface = as[4].gsub!(" ", "").split(" ").last
|
69
|
+
return access_interface
|
70
|
+
else
|
71
|
+
answer ="false"
|
72
|
+
return answer
|
73
|
+
end
|
74
|
+
rescue
|
75
|
+
begin
|
76
|
+
connection = Net::Telnet.new("Host" => host_iwag, "Timeout" => false, "Prompt" => /.*\#/) {|str| print str}
|
77
|
+
connection.login({"Name" => username_iwag, "Password" => password_iwag, "LoginPrompt" => /Username:/}) {|str| print str}
|
78
|
+
connection.cmd("show ip dhcp binding #{ipaddress}") {
|
79
|
+
|c|
|
80
|
+
dump << c
|
81
|
+
}
|
82
|
+
connection.close
|
83
|
+
as = dump.split("\n")
|
84
|
+
if as[4] != nil && as[3] != ""
|
85
|
+
access_interface = as[4].gsub!(" ", "").split(" ").last
|
86
|
+
return access_interface
|
87
|
+
else
|
88
|
+
answer ="false"
|
89
|
+
return answer
|
90
|
+
end
|
91
|
+
rescue
|
92
|
+
return "unknown"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
end
|
@@ -41,6 +41,28 @@ class MongoWifiCl_1
|
|
41
41
|
out_resp
|
42
42
|
end
|
43
43
|
|
44
|
+
def audit_logger_wifi_portal_1(proc_name, src_ip, input_json, output_json, real_ip)
|
45
|
+
out_resp = {}
|
46
|
+
begin
|
47
|
+
current = additional_func_1.datetimenow_1
|
48
|
+
collection = client[:audit_portal]
|
49
|
+
doc = {
|
50
|
+
:proc_name => proc_name,
|
51
|
+
:date => current,
|
52
|
+
:sender => {:src_ip => src_ip, :real_ip => real_ip},
|
53
|
+
:input_params => input_json,
|
54
|
+
:output_params => output_json,
|
55
|
+
:sdk_version => Freewifi_1::VERSION
|
56
|
+
}
|
57
|
+
result = collection.insert_one(doc)
|
58
|
+
out_resp = {:code => 200, :result => "audit_logger_wifi_1: Request completed successfully", :body => result, :sdk => "freewifi"}
|
59
|
+
rescue
|
60
|
+
out_resp = {:code => 507, :result => "audit_logger_wifi_1: Unknown SDK error", :sdk => "freewifi"}
|
61
|
+
end
|
62
|
+
additional_func_1.printer_texter_wifi_1(out_resp, "debug")
|
63
|
+
out_resp
|
64
|
+
end
|
65
|
+
|
44
66
|
|
45
67
|
def data_ap_auto_created_insert_1(data)
|
46
68
|
input_params = {:data => data}
|
@@ -97,4 +119,6 @@ class MongoWifiCl_1
|
|
97
119
|
out_resp
|
98
120
|
end
|
99
121
|
|
122
|
+
|
123
|
+
|
100
124
|
end
|