-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathyyrp.rake
48 lines (42 loc) · 1.31 KB
/
yyrp.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'whirly'
require_relative 'lib/yyrp/utils/download_progress'
mmdb_gz_file = File.expand_path('./mmdb/GeoLite2-Country.mmdb.gz', File.dirname(__FILE__))
mmdb_file = File.expand_path('./mmdb/GeoLite2-Country.mmdb', File.dirname(__FILE__))
task :down_mmdb do
Whirly.start do
Whirly.status = 'Start download mmdb'
url = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz'
down(url, mmdb_gz_file)
Whirly.status = 'MMDB downloaded'
end
end
require 'zlib'
task :unzip_mmdb do
Whirly.start do
Whirly.status = 'Start unzip mmdb'
Zlib::GzipReader.open(mmdb_gz_file) do | input_stream |
File.open(mmdb_file, 'w') do |output_stream|
IO.copy_stream(input_stream, output_stream)
end
end
end
end
require_relative 'lib/yyrp/mitm/lib/ritm/certs/ca'
task :gen_ca do
Whirly.start do
Whirly.status = 'Start generate mitm CA'
ca = Ritm::CA.create common_name: 'InsecureCA'
File.write('certs/insecure_ca.crt', ca.pem)
File.write('certs/insecure_ca.key', ca.private_key.to_s)
end
end
require 'os'
task :install_ca do
if OS.mac?
sh 'sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./certs/insecure_ca.crt'
else
Whirly.start do
Whirly.status = 'No support for your system'
end
end
end