imperituroard 0.5.1 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/imperituroard.gemspec +27 -14
- data/lib/imperituroard.rb +49 -19
- data/lib/imperituroard/add_functions/logger/any_functions.rb +22 -0
- data/lib/imperituroard/platforms/staros/get_data_ssh.rb +54 -0
- data/lib/imperituroard/platforms/staros/staros_parser.rb +141 -0
- data/lib/imperituroard/projects/dns.rb +1 -1
- data/lib/imperituroard/projects/iot.rb +66 -4
- data/lib/imperituroard/projects/iot/add_functions.rb +27 -27
- data/lib/imperituroard/projects/mhub.rb +12 -6
- data/lib/imperituroard/projects/mhub/infobip.rb +1 -1
- data/lib/imperituroard/projects/mhub/subs/dabrab/dabrab_platform.rb +2 -0
- data/lib/imperituroard/projects/ukaz60.rb +138 -0
- data/lib/imperituroard/projects/ukaz60/belgim.rb +217 -0
- data/lib/imperituroard/projects/ukaz60/dns.rb +18 -0
- data/lib/imperituroard/projects/{dns/ukaz60 → ukaz60}/dns_update.rb +2 -134
- data/lib/imperituroard/projects/ukaz60/fortigate.rb +187 -0
- data/lib/imperituroard/projects/ukaz60/staros.rb +126 -0
- data/lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb +297 -0
- data/lib/imperituroard/projects/vpn/ezuev_fun/functions_ezuev.rb +29 -0
- data/lib/imperituroard/version.rb +1 -1
- metadata +39 -15
@@ -96,27 +96,27 @@ class AdditionalFunc
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def check_input_1(login, imei_list)
|
99
|
-
{:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
|
99
|
+
{:code => 200, :result => "Request completed successfully", :body => "Data checked"}
|
100
100
|
end
|
101
101
|
|
102
102
|
def check_input_2(login, imei_list)
|
103
|
-
{:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
|
103
|
+
{:code => 200, :result => "Request completed successfully", :body => "Data checked"}
|
104
104
|
end
|
105
105
|
|
106
106
|
def check_input_3(login, imei_list)
|
107
|
-
{:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
|
107
|
+
{:code => 200, :result => "Request completed successfully", :body => "Data checked"}
|
108
108
|
end
|
109
109
|
|
110
110
|
def check_input_4(login, imei_list)
|
111
|
-
{:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
|
111
|
+
{:code => 200, :result => "Request completed successfully", :body => "Data checked"}
|
112
112
|
end
|
113
113
|
|
114
114
|
def check_input_5(login, imei_list)
|
115
|
-
{:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
|
115
|
+
{:code => 200, :result => "Request completed successfully", :body => "Data checked"}
|
116
116
|
end
|
117
117
|
|
118
118
|
def check_input_6(login, imei_list)
|
119
|
-
{:code=>200, :result=>"Request completed successfully", :body=>"Data checked"}
|
119
|
+
{:code => 200, :result => "Request completed successfully", :body => "Data checked"}
|
120
120
|
end
|
121
121
|
|
122
122
|
def iot_query_dev_soapgw_answer(input_params, output_answer)
|
@@ -127,28 +127,28 @@ class AdditionalFunc
|
|
127
127
|
|
128
128
|
begin
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
130
|
+
if output_answer[:code]==200
|
131
|
+
dataaa = []
|
132
|
+
dataaa_failed = []
|
133
|
+
|
134
|
+
ddd = answ_dev_query_format_process(output_answer[:data])[:body]
|
135
|
+
p ddd
|
136
|
+
|
137
|
+
answ = {:code => output_answer[:code],
|
138
|
+
:result => output_answer[:result],
|
139
|
+
:data => ddd[:ok],
|
140
|
+
:error_list => ddd[:failed]
|
141
|
+
}
|
142
|
+
else
|
143
|
+
answ = {:code => output_answer[:code],
|
144
|
+
:result => output_answer[:result],
|
145
|
+
:data => [],
|
146
|
+
:error_list => input_params[:imei]
|
147
|
+
}
|
148
|
+
end
|
149
149
|
rescue
|
150
|
-
answ = {
|
151
|
-
|
150
|
+
answ = {:code => 500,
|
151
|
+
:result => "Unknown error"
|
152
152
|
}
|
153
153
|
end
|
154
154
|
|
@@ -23,9 +23,10 @@ class MhubFunctions_2
|
|
23
23
|
:dabrab_connecter,
|
24
24
|
:static_callback,
|
25
25
|
:crm_connector,
|
26
|
-
:telegram_connector
|
26
|
+
:telegram_connector,
|
27
|
+
:sms_alphaname
|
27
28
|
|
28
|
-
def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password)
|
29
|
+
def initialize(sk_url_simple, sk_login, sk_password, telegram_api_url, telegram_chat_id, sk_url_broadcast, static_callback, crm_callback_url, crm_login, crm_password, sms_alphaname)
|
29
30
|
@sk_url = sk_url_simple
|
30
31
|
@sk_login = sk_login
|
31
32
|
@sk_password = sk_password
|
@@ -36,6 +37,7 @@ class MhubFunctions_2
|
|
36
37
|
@telegram_connector = Telegram_2.new(telegram_api_url, telegram_chat_id)
|
37
38
|
@static_callback = static_callback
|
38
39
|
@crm_connector = Crm_2.new(crm_callback_url, crm_login, crm_password, telegram_api_url, telegram_chat_id)
|
40
|
+
@sms_alphaname = sms_alphaname
|
39
41
|
end
|
40
42
|
|
41
43
|
|
@@ -91,13 +93,13 @@ class MhubFunctions_2
|
|
91
93
|
msisdn2 = dabrab_connecter.num_formatter(params["destinations"], params["notifyUrl"].split(":")[2])
|
92
94
|
|
93
95
|
if null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
|
94
|
-
hub_resp = mhub_connector.sk_send_sms_list(msisdn2, static_callback, params["sms"]["text"],
|
96
|
+
hub_resp = mhub_connector.sk_send_sms_list(msisdn2, static_callback, params["sms"]["text"], sms_alphaname)
|
95
97
|
elsif !null_statement.include?(params["viber"]) && null_statement.include?(params["sms"])
|
96
98
|
hub_resp = mhub_connector.sk_send_viber_list(msisdn2, static_callback, params["viber"]["text"])
|
97
99
|
elsif !null_statement.include?(params["viber"]) && !null_statement.include?(params["sms"])
|
98
100
|
p "vibersms"
|
99
101
|
p msisdn2
|
100
|
-
hub_resp = mhub_connector.sk_send_viber_sms_list(msisdn2, static_callback, params["sms"]["text"], params["viber"]["text"],
|
102
|
+
hub_resp = mhub_connector.sk_send_viber_sms_list(msisdn2, static_callback, params["sms"]["text"], params["viber"]["text"], sms_alphaname)
|
101
103
|
else
|
102
104
|
output_params = {"code": 502, "result": "Invalid input data st2", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
|
103
105
|
end
|
@@ -128,8 +130,12 @@ class MhubFunctions_2
|
|
128
130
|
|
129
131
|
begin
|
130
132
|
mes_report = dabrab_connecter.delivery_report_transform(params)[:body][:report_to_recip]
|
131
|
-
result = crm_connector.
|
132
|
-
|
133
|
+
result = crm_connector.crm_status_2(mes_report)
|
134
|
+
if result[:body][:res_body]["GetReportsResult"]==""
|
135
|
+
output_params = {"code": 200, "result": "Data processed", "body": {"answer": {"code": 200, "status": "Success"}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
|
136
|
+
else
|
137
|
+
output_params = {"code": 202, "result": "CRM returned error #{result[:body][:res_body]["GetReportsResult"].to_s}", "body": {"answer": {"code": 200, "status": "Success"}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
|
138
|
+
end
|
133
139
|
rescue
|
134
140
|
output_params = {"code": 500, "result": "MhubFunctions_2.rec_deliv_report_2: Unknown SDK error", "body": {"answer": {}, "sender": {"ip_src": ip_src, "ip_real": ip_real, "ip_vip": ip_vip}}}
|
135
141
|
telegram_connector.telegram_message(output_params)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
|
8
|
-
class
|
8
|
+
class Infobip_2
|
9
9
|
|
10
10
|
def test
|
11
11
|
gg = "{\"destinations\"=>[{\"to\"=>{\"phoneNumber\"=>\"375297116638\", \"emailAddress\"=>nil}}], \"scenarioKey\"=>\"1\", \"viber\"=>nil, \"sms\"=>{\"text\"=>\"карточка готова\"}, \"sendAt\"=>\"2019-08-15T08:40:00.000\", \"notifyUrl\"=>\"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports\", \"notifyContentType\"=>\"application/json\", \"controller\"=>\"bank\", \"action\"=>\"api\", \"bank\"=>{\"destinations\"=>[{\"to\"=>{\"phoneNumber\"=>\"375297116638\", \"emailAddress\"=>nil}}], \"scenarioKey\"=>\"1\", \"viber\"=>nil, \"sms\"=>{\"text\"=>\"карточка готова\"}, \"sendAt\"=>\"2019-08-15T08:40:00.000\", \"notifyUrl\"=>\"https://bpmonline.bankdabrabyt.by:444/0/ServiceModel/ScGetReports.svc/GetReports\", \"notifyContentType\"=>\"application/json\"}}"
|
@@ -0,0 +1,138 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../projects/ukaz60", __dir__)
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require 'imperituroard/projects/ukaz60/belgim'
|
6
|
+
require 'imperituroard/projects/ukaz60/fortigate'
|
7
|
+
require 'imperituroard/projects/ukaz60/staros'
|
8
|
+
|
9
|
+
class Ukaz60All_2
|
10
|
+
|
11
|
+
attr_accessor :telegram_messanger,
|
12
|
+
:belgim_login,
|
13
|
+
:belgim_password,
|
14
|
+
:belgim_url,
|
15
|
+
:ukaz60_add_func,
|
16
|
+
:belgim_connector,
|
17
|
+
:forti_connector,
|
18
|
+
:staros_connector
|
19
|
+
|
20
|
+
def initialize(telegram_api_url,
|
21
|
+
telegram_chat_id,
|
22
|
+
belgim_login,
|
23
|
+
belgim_password,
|
24
|
+
belgim_url,
|
25
|
+
ansible_tmp_folder,
|
26
|
+
local_tmp_directory,
|
27
|
+
ansible_ssh_user,
|
28
|
+
ansible_ssh_password,
|
29
|
+
ansible_host,
|
30
|
+
url_backup_dir,
|
31
|
+
staros_login,
|
32
|
+
staros_password,
|
33
|
+
ukaz60_http_groups,
|
34
|
+
ukaz60_https_groups,
|
35
|
+
staros_hosts
|
36
|
+
|
37
|
+
)
|
38
|
+
@telegram_messanger = Telegram_2.new(telegram_api_url, telegram_chat_id)
|
39
|
+
@belgim_login = belgim_login
|
40
|
+
@belgim_password = belgim_password
|
41
|
+
@belgim_url = belgim_url
|
42
|
+
@ukaz60_add_func = AddFuncUkaz60_2.new
|
43
|
+
@belgim_connector = Belgim_2.new(telegram_api_url, telegram_chat_id, belgim_login, belgim_password, belgim_url)
|
44
|
+
@forti_connector = FortiUkaz60_2.new(ansible_tmp_folder, local_tmp_directory, ansible_ssh_user, ansible_ssh_password, ansible_host, url_backup_dir)
|
45
|
+
@staros_connector = Ukaz60Staros_2.new(staros_login, staros_password, ukaz60_http_groups, ukaz60_https_groups, staros_hosts)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def forti_process(get_belgim_data)
|
50
|
+
forti_answer = {}
|
51
|
+
begin
|
52
|
+
format_for_forti = forti_connector.prepare_url_config_fortigate(get_belgim_data)
|
53
|
+
if format_for_forti[:code] == 200
|
54
|
+
url_uploading = forti_connector.upload_url(format_for_forti[:body][:to_fortigate])
|
55
|
+
if url_uploading[:code] == 200
|
56
|
+
update_fortigate_ansible = forti_connector.update_weburl_fortigate
|
57
|
+
if update_fortigate_ansible[:code] == 200
|
58
|
+
forti_answer = {:code => 200, :result => "Fortigate processed", :data => update_fortigate_ansible[:body][:body], :num_uploaded_to_forti => format_for_forti[:body][:num_list]}
|
59
|
+
else
|
60
|
+
forti_answer = {:code => update_fortigate_ansible[:code], :result => update_fortigate_ansible[:result]}
|
61
|
+
end
|
62
|
+
forti_connector.clean_tmp_folders
|
63
|
+
else
|
64
|
+
forti_answer = {:code => 401, :result => "Failed for uploading data to ansible server"}
|
65
|
+
end
|
66
|
+
else
|
67
|
+
forti_answer = {:code => 400, :result => "Error while processing data"}
|
68
|
+
end
|
69
|
+
rescue
|
70
|
+
forti_answer = {:code => 507, :result => "Unknown error with Forti"}
|
71
|
+
end
|
72
|
+
forti_answer
|
73
|
+
end
|
74
|
+
|
75
|
+
def staros_process(get_belgim_data)
|
76
|
+
|
77
|
+
output_starprocess = {}
|
78
|
+
|
79
|
+
begin
|
80
|
+
#get data from staros
|
81
|
+
staros_blocks_current = staros_connector.get_all_staros_ukaz60
|
82
|
+
|
83
|
+
if staros_blocks_current[:code] == 200
|
84
|
+
#compare data with belgim
|
85
|
+
answ = ukaz60_add_func.staros_compare_http(staros_blocks_current, get_belgim_data)
|
86
|
+
|
87
|
+
if answ[:code] == 200
|
88
|
+
#output_starprocess = {:code => 200, :result => "Staros processed", :data => {:block_me => answ[:body][:for_block][:notblocked_stat], :unblock_me =>answ[:body][:for_unblock][:for_unblock_stat]}}
|
89
|
+
output_starprocess = ukaz60_add_func.format_star_processed_answ(answ)[:body][:to_message]
|
90
|
+
else
|
91
|
+
output_starprocess = answ
|
92
|
+
end
|
93
|
+
|
94
|
+
else
|
95
|
+
output_starprocess = staros_blocks_current
|
96
|
+
end
|
97
|
+
rescue
|
98
|
+
output_starprocess = {:code => 507, :result => "staros_process: Something wrong"}
|
99
|
+
end
|
100
|
+
|
101
|
+
output_starprocess
|
102
|
+
end
|
103
|
+
|
104
|
+
def no_pasaran
|
105
|
+
|
106
|
+
answer_output = {}
|
107
|
+
forti_answer = {}
|
108
|
+
staros_answer = {}
|
109
|
+
|
110
|
+
begin
|
111
|
+
get_belgim_data = belgim_connector.belgim_ukaz60_get
|
112
|
+
|
113
|
+
if get_belgim_data[:code] == 200
|
114
|
+
|
115
|
+
thr_forti = Thread.new do
|
116
|
+
forti_answer = self.forti_process(get_belgim_data)
|
117
|
+
end
|
118
|
+
|
119
|
+
thr_staros = Thread.new do
|
120
|
+
staros_answer = staros_process(get_belgim_data)
|
121
|
+
end
|
122
|
+
|
123
|
+
thr_staros.join
|
124
|
+
thr_forti.join
|
125
|
+
|
126
|
+
answer_output = {:code => 200, :result => "No pasaran", :fortigate => forti_answer, :staros => staros_answer, :info_belgim => get_belgim_data[:number]}
|
127
|
+
else
|
128
|
+
answer_output = {:code => 404, :result => "Failed to receive data from Belgim"}
|
129
|
+
end
|
130
|
+
|
131
|
+
rescue
|
132
|
+
answer_output = {:code => 507, :result => "no_pasaran: Unknown SDK error"}
|
133
|
+
end
|
134
|
+
telegram_messanger.telegram_message(JSON.pretty_generate(answer_output))
|
135
|
+
answer_output
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
require 'imperituroard/platforms/public/telegram'
|
2
|
+
require 'imperituroard/projects/ukaz60/ukaz60_add_func'
|
3
|
+
|
4
|
+
require 'simpleidn'
|
5
|
+
|
6
|
+
class Belgim_2
|
7
|
+
|
8
|
+
|
9
|
+
attr_accessor :telegram_messanger,
|
10
|
+
:belgim_login,
|
11
|
+
:belgim_password,
|
12
|
+
:belgim_url,
|
13
|
+
:ukaz60_add_func
|
14
|
+
|
15
|
+
def initialize(telegram_api_url,
|
16
|
+
telegram_chat_id,
|
17
|
+
belgim_login,
|
18
|
+
belgim_password,
|
19
|
+
belgim_url
|
20
|
+
)
|
21
|
+
@telegram_messanger = Telegram_2.new(telegram_api_url, telegram_chat_id)
|
22
|
+
@belgim_login = belgim_login
|
23
|
+
@belgim_password = belgim_password
|
24
|
+
@belgim_url = belgim_url
|
25
|
+
@ukaz60_add_func = AddFuncUkaz60_2.new
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
#get domains from belgim and parse data
|
30
|
+
#return all domains urls ips. Selection specific data for dns or firewall do by additional functions
|
31
|
+
#full ready for dns and firewall
|
32
|
+
def belgim_ukaz60_get
|
33
|
+
|
34
|
+
output_data = {}
|
35
|
+
|
36
|
+
begin
|
37
|
+
|
38
|
+
#data peremennye
|
39
|
+
regexp_redns = /<dns>(.{1,100})dns>/
|
40
|
+
regexp_reurl = /<url>(.{1,100})url>/
|
41
|
+
regexp_reip = /<ip>(.{1,100})ip>/
|
42
|
+
|
43
|
+
#processed data in correct format
|
44
|
+
domain_parsed = []
|
45
|
+
url_parsed = []
|
46
|
+
ipv4_parsed = []
|
47
|
+
ipv6_parsed = []
|
48
|
+
https_parsed = []
|
49
|
+
url_all = []
|
50
|
+
|
51
|
+
f2 =[]
|
52
|
+
results = {}
|
53
|
+
|
54
|
+
# Get data from Belgim site by curl
|
55
|
+
return_from_belgim = `curl -d "name=#{belgim_login}&pass=#{belgim_password}" -H "Content-Type: application/x-www-form-urlencoded" -X POST #{belgim_url}`
|
56
|
+
return_from_belgim = return_from_belgim.gsub!("\n", "")
|
57
|
+
|
58
|
+
#parse Belgim file by regexpression
|
59
|
+
# and split by 3 categories: url, dns, ip
|
60
|
+
belgim_domains = return_from_belgim.scan(regexp_redns)
|
61
|
+
belgim_urls = return_from_belgim.scan(regexp_reurl)
|
62
|
+
belgim_ips = return_from_belgim.scan(regexp_reip)
|
63
|
+
|
64
|
+
#process only domains.
|
65
|
+
for i in belgim_domains
|
66
|
+
a1 = i[0]
|
67
|
+
elem = a1.gsub("</", "")
|
68
|
+
|
69
|
+
if elem.include? " "
|
70
|
+
elem = elem.gsub(" ", "")
|
71
|
+
end
|
72
|
+
|
73
|
+
if elem.match(/а|б|в|г|д|е|ж|ё|Ё|з|и|й|к|л|м|н|о|п|р|с|т|у|ф|х|ц|ч|ш|щ|ь|ы|ъ|э|ю|я|А|Б|В|Г|Д|Е|Ж|З|И|Й|К|Л|М|Н|О|П|Р|С|Т|У|Ф|Х|Ц|Ч|Ш|Щ|Ь|Ы|Ъ|Э|Ю|Я/)
|
74
|
+
elem = SimpleIDN.to_ascii(elem)
|
75
|
+
end
|
76
|
+
|
77
|
+
if elem != "-" && elem != ""
|
78
|
+
domain_parsed.push(elem)
|
79
|
+
if_www = elem[0]+elem[1]+elem[2]+elem[3]
|
80
|
+
|
81
|
+
#if not contain www - add domain with www
|
82
|
+
if if_www != "www."
|
83
|
+
domain_parsed.push("www."+elem)
|
84
|
+
end
|
85
|
+
|
86
|
+
#if contain www - add domain without www
|
87
|
+
if if_www == "www."
|
88
|
+
gar = elem[4..elem.length]
|
89
|
+
domain_parsed.push(gar)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
#process only urls
|
95
|
+
for s in belgim_urls
|
96
|
+
|
97
|
+
#process every domain. Find if https or http and domain
|
98
|
+
func_processed = ukaz60_add_func.delete_dump_symbols_url(s[0])
|
99
|
+
|
100
|
+
if func_processed[:code] == 200
|
101
|
+
processed_url = func_processed[:domain_only]
|
102
|
+
processed_domain_in_url = func_processed[:processed_domain_in_url]
|
103
|
+
|
104
|
+
if func_processed[:type] == "domain"
|
105
|
+
domain_parsed.push(processed_url)
|
106
|
+
check_if_www = processed_url[0]+processed_url[1]+processed_url[2]+processed_url[3]
|
107
|
+
|
108
|
+
#if not contains www then add with www too
|
109
|
+
if check_if_www != "www."
|
110
|
+
domain_parsed.push("www."+processed_url)
|
111
|
+
end
|
112
|
+
|
113
|
+
#if contains www then add without www too
|
114
|
+
if check_if_www == "www."
|
115
|
+
gar2domain = processed_url[4..processed_url.length]
|
116
|
+
domain_parsed.push(gar2domain)
|
117
|
+
end
|
118
|
+
elsif func_processed[:type] == "url" && func_processed[:protocol] != "https"
|
119
|
+
#p "Step4 processed_domain_in_url: #{processed_domain_in_url}"
|
120
|
+
#p "Step5 func_processed: #{func_processed.to_s}"
|
121
|
+
|
122
|
+
url_parsed.push(func_processed[:protocol] + "://" + processed_domain_in_url)
|
123
|
+
check_if_www2 = processed_domain_in_url[0]+processed_domain_in_url[1]+processed_domain_in_url[2]+processed_domain_in_url[3]
|
124
|
+
if check_if_www2 != "www."
|
125
|
+
url_parsed.push(func_processed[:protocol] + "://" + "www."+processed_domain_in_url)
|
126
|
+
end
|
127
|
+
if check_if_www2 == "www."
|
128
|
+
gar1url = processed_domain_in_url[4..processed_domain_in_url.length]
|
129
|
+
url_parsed.push(func_processed[:protocol] + "://" + gar1url)
|
130
|
+
end
|
131
|
+
elsif func_processed[:protocol] == "https"
|
132
|
+
#additional section for https urls
|
133
|
+
https_parsed.push(func_processed[:protocol] + "://" + processed_domain_in_url)
|
134
|
+
check_if_www2https = processed_domain_in_url[0]+processed_domain_in_url[1]+processed_domain_in_url[2]+processed_domain_in_url[3]
|
135
|
+
if check_if_www2https != "www."
|
136
|
+
https_parsed.push(func_processed[:protocol] + "://" + "www."+processed_domain_in_url)
|
137
|
+
end
|
138
|
+
if check_if_www2https == "www."
|
139
|
+
gar1url_https = processed_domain_in_url[4..processed_domain_in_url.length]
|
140
|
+
https_parsed.push(func_processed[:protocol] + "://" + gar1url_https)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
#process only IPs
|
147
|
+
for f in belgim_ips
|
148
|
+
|
149
|
+
a2ip = f[0]
|
150
|
+
|
151
|
+
if a2ip.include? " "
|
152
|
+
a2ip = a2ip.gsub(" ", "")
|
153
|
+
end
|
154
|
+
|
155
|
+
elem_ip = a2ip.gsub("</", "")
|
156
|
+
|
157
|
+
if elem_ip != "-" && elem_ip != ""
|
158
|
+
if elem_ip.include?(":")
|
159
|
+
ipv6_parsed.push(elem_ip)
|
160
|
+
else
|
161
|
+
ipv4_parsed.push(elem_ip)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
domain_parsed = domain_parsed.uniq
|
167
|
+
url_parsed = url_parsed.uniq
|
168
|
+
ipv6_parsed = ipv6_parsed.uniq
|
169
|
+
ipv4_parsed = ipv4_parsed.uniq
|
170
|
+
https_parsed = https_parsed.uniq
|
171
|
+
|
172
|
+
https_parsed_tmmp = []
|
173
|
+
https_parsed.each do |tmp_tmp|
|
174
|
+
https_parsed_tmmp.push(tmp_tmp.gsub("https://", "http://"))
|
175
|
+
end
|
176
|
+
url_all = https_parsed_tmmp + url_parsed
|
177
|
+
url_all = url_all.uniq
|
178
|
+
url_all_num = url_all.length
|
179
|
+
|
180
|
+
|
181
|
+
dns_num = domain_parsed.length
|
182
|
+
ipv4_num = ipv4_parsed.length
|
183
|
+
ipv6_num = ipv6_parsed.length
|
184
|
+
url_num = url_parsed.length
|
185
|
+
https_num = https_parsed.length
|
186
|
+
|
187
|
+
all_num = dns_num + ipv4_num + ipv6_num + url_num + https_num
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
output_data = {:code => 200,
|
192
|
+
:result => "Request completed successfully",
|
193
|
+
:number => {:domain_num => dns_num,
|
194
|
+
:url_http_num => url_num,
|
195
|
+
:ipv4_num => ipv4_num,
|
196
|
+
:ipv6_num => ipv6_num,
|
197
|
+
:url_https_num => https_num,
|
198
|
+
:url_all_num => url_all_num,
|
199
|
+
:all_num => all_num
|
200
|
+
},
|
201
|
+
:domains_for_block => domain_parsed,
|
202
|
+
:url_for_block => url_parsed,
|
203
|
+
:ipv6_parsed => ipv6_parsed,
|
204
|
+
:ipv4_parsed => ipv4_parsed,
|
205
|
+
:https_parsed => https_parsed,
|
206
|
+
:url_all => url_all
|
207
|
+
}
|
208
|
+
|
209
|
+
rescue
|
210
|
+
output_data = {:code => 507, :result => "belgim_ukaz60_get: Unknown error"}
|
211
|
+
end
|
212
|
+
output_data
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
end
|