spior 0.1.6 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,96 +0,0 @@
1
- require 'pathname'
2
- require 'nomansland'
3
- require 'tty-which'
4
-
5
- module Spior
6
- module Tor
7
- class Info
8
- attr_accessor :dns, :uid, :trans_port, :virt_addr
9
-
10
- def initialize
11
- @systemctl = Helpers::Exec.new("systemctl")
12
- @dns = search_dns
13
- @uid = search_uid
14
- @trans_port = search_trans_port
15
- @virt_addr = search_virt_addr
16
- end
17
-
18
- private
19
-
20
- def check_deps
21
- Spior::Copy.new.save
22
- add_torrc
23
- Spior::Service.start
24
- end
25
-
26
- def self.grep?(file, regex)
27
- is_found = false
28
- return is_found if ! File.exist? file
29
- File.open(file) do |f|
30
- f.each do |line|
31
- is_found = true if line.match(regex)
32
- end
33
- end
34
- is_found
35
- end
36
-
37
- def add_torrc
38
- user = 'User tor'
39
- pid = ''
40
- dir = 'DataDirectory /var/lib/tor'
41
-
42
- case Nomansland::distro?
43
- when :gentoo
44
- pid = 'PIDFile /run/tor/tor.pid'
45
- dir = 'DataDirectory /var/lib/tor/data'
46
- when :debian
47
- user = 'debian-tor'
48
- when :ubuntu
49
- user = 'debian-tor'
50
- end
51
-
52
- string = <<EOF
53
- # Generated by Spior
54
- #{user}
55
- #{pid}
56
- #{dir}
57
- GeoIPExcludeUnknown 1
58
- DNSPort 127.0.0.1:9061
59
- AutomapHostsOnResolve 1
60
- AutomapHostsSuffixes .exit,.onion
61
- SocksPort 9050
62
- VirtualAddrNetworkIPv4 10.192.0.0/10
63
- TransPort 9040 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
64
- TestSocks 1
65
- MaxCircuitDirtiness 600
66
- EOF
67
- new_file = Helpers::NewFile.new(string, "torrc", "/etc/tor")
68
- new_file.add
69
- new_file.perm("root", "644")
70
- end
71
-
72
- def search_dns
73
- 9061
74
- end
75
-
76
- def search_uid
77
- case Nomansland::distro?
78
- when :debian
79
- `id -u debian-tor`.chomp
80
- when :ubuntu
81
- `id -u debian-tor`.chomp
82
- else
83
- `id -u tor`.chomp
84
- end
85
- end
86
-
87
- def search_trans_port
88
- 9040
89
- end
90
-
91
- def search_virt_addr
92
- "10.192.0.0/10"
93
- end
94
- end
95
- end
96
- end