spior 0.1.5 → 0.2.8

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/rubocop-analysis.yml +47 -0
  4. data/.gitignore +1 -0
  5. data/CHANGELOG.md +21 -0
  6. data/Gemfile +5 -0
  7. data/README.md +27 -4
  8. data/Rakefile +21 -10
  9. data/lib/spior/dep.rb +59 -0
  10. data/lib/spior/helpers.rb +19 -19
  11. data/lib/spior/iptables/default.rb +19 -13
  12. data/lib/spior/iptables/root.rb +36 -41
  13. data/lib/spior/iptables/rules.rb +103 -0
  14. data/lib/spior/iptables/tor.rb +24 -26
  15. data/lib/spior/iptables.rb +3 -0
  16. data/lib/spior/menu.rb +16 -23
  17. data/lib/spior/msg.rb +22 -12
  18. data/lib/spior/options.rb +17 -20
  19. data/lib/spior/service/enable.rb +63 -0
  20. data/lib/spior/service/restart.rb +13 -0
  21. data/lib/spior/service/start.rb +14 -0
  22. data/lib/spior/service/stop.rb +12 -0
  23. data/lib/spior/service.rb +12 -0
  24. data/lib/spior/status.rb +32 -24
  25. data/lib/spior/tor/config.rb +100 -0
  26. data/lib/spior/tor/data.rb +53 -0
  27. data/lib/spior/tor/start.rb +59 -0
  28. data/lib/spior/tor/stop.rb +32 -0
  29. data/lib/spior/tor.rb +8 -2
  30. data/lib/spior/version.rb +3 -1
  31. data/lib/spior.rb +18 -23
  32. data/man/spior.1 +53 -0
  33. data/man/spior.1.html +122 -0
  34. data/man/spior.1.ronn +46 -0
  35. data/spior.gemspec +24 -21
  36. data/test/test_install.rb +2 -2
  37. data/test/test_options.rb +2 -0
  38. data.tar.gz.sig +0 -0
  39. metadata +67 -57
  40. metadata.gz.sig +0 -0
  41. data/lib/spior/clear.rb +0 -36
  42. data/lib/spior/copy.rb +0 -85
  43. data/lib/spior/install.rb +0 -33
  44. data/lib/spior/network.rb +0 -45
  45. data/lib/spior/persist.rb +0 -51
  46. data/lib/spior/tor/info.rb +0 -113
  47. data/lib/spior/tor/restart.rb +0 -13
metadata CHANGED
@@ -1,98 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spior
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - szorfein
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIETTCCArWgAwIBAgIBATANBgkqhkiG9w0BAQsFADAoMSYwJAYDVQQDDB1zem9y
14
- ZmVpbi9EQz1wcm90b25tYWlsL0RDPWNvbTAeFw0yMDA0MzAxNzAxNDBaFw0yMTA0
15
- MzAxNzAxNDBaMCgxJjAkBgNVBAMMHXN6b3JmZWluL0RDPXByb3Rvbm1haWwvREM9
16
- Y29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAxCTYZRndCTRy18rE
17
- exr2wig/staa0G5kt99xqaBYD0dnIRBr/GO5dFntlBVwmefQlTrNbygVUIYTb8Vg
18
- B1oX3v/LLW9SRQcWaZwou0tARqanm5WhgV1ZYQTs22endTazsDHw0uhM3V+FgDh+
19
- eR5wM9vU+SkRFHWzjVS1OxyTSCBVWb3+nrYTr/OKZ5Fm3Vo1dEQdwBEWLLXuUBxs
20
- dWEDmBk7iTJbvNdd5Kk2wfMKRMOl9NGicJl3Cb5yl5ITeZsXdOsrLBBPepTpNeq2
21
- k1goew3mEd/4pVXrdw6S5Qr6RTbTCLpKNRxWtx01vue9NN1cQ/Ds5FRkCp/Ntw/k
22
- Xroyofo4MW5fEPq+udgvVpdTfguQkpmuJg7TRiq9F5hDhEMnKUsdM2fSev9u8EvL
23
- OkidKy8bnhUOoG9qDxEG/IyibjRLl1i5jtyHa8Jb/We8poZ5LI8qjHwMPjTBhDgi
24
- EzaYV5rLGs5S1/m58XG6a+620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Tp1M01EDKDvAX7f3B+X6A5D7uBq
33
+ 63X6Kx09VkntVOrifd3W4TwjDlyAMpB+50OIi3ErPnH2R4i09qnCiZmcVWATBVKw
34
+ e2QSloIAUZJwEFkrRqWPNVi8sr+BcMeuKpXaOwpbkP+xq/W2EKlUQKhPXMXS4jvC
35
+ MuTi+RjpSNKZxzBrOlK2eMIpiFrugF7nzKcM9EGnWRWUb899drCcD4VJhjPtgpn+
36
+ aEJeKq4/BlIwMlXPe+W5C8zp2i8hgG1/OYbwbGE1p2iRi1NIK7G/HyRqQjOqJxzE
37
+ LLknX69FN7/G
37
38
  -----END CERTIFICATE-----
38
- date: 2020-11-01 00:00:00.000000000 Z
39
+ date: 2022-09-16 00:00:00.000000000 Z
39
40
  dependencies:
40
41
  - !ruby/object:Gem::Dependency
41
- name: rainbow
42
+ name: interfacez
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
- - - '='
45
+ - - "~>"
45
46
  - !ruby/object:Gem::Version
46
- version: 3.0.0
47
+ version: '1.0'
47
48
  type: :runtime
48
49
  prerelease: false
49
50
  version_requirements: !ruby/object:Gem::Requirement
50
51
  requirements:
51
- - - '='
52
+ - - "~>"
52
53
  - !ruby/object:Gem::Version
53
- version: 3.0.0
54
+ version: '1.0'
54
55
  - !ruby/object:Gem::Dependency
55
- name: interfacez
56
+ name: nomansland
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
- - - '='
59
+ - - "~>"
59
60
  - !ruby/object:Gem::Version
60
- version: 1.0.3
61
+ version: '0.0'
61
62
  type: :runtime
62
63
  prerelease: false
63
64
  version_requirements: !ruby/object:Gem::Requirement
64
65
  requirements:
65
- - - '='
66
+ - - "~>"
66
67
  - !ruby/object:Gem::Version
67
- version: 1.0.3
68
+ version: '0.0'
68
69
  - !ruby/object:Gem::Dependency
69
- name: nomansland
70
+ name: rainbow
70
71
  requirement: !ruby/object:Gem::Requirement
71
72
  requirements:
72
- - - '='
73
+ - - "~>"
73
74
  - !ruby/object:Gem::Version
74
- version: 0.0.2
75
+ version: '3.1'
75
76
  type: :runtime
76
77
  prerelease: false
77
78
  version_requirements: !ruby/object:Gem::Requirement
78
79
  requirements:
79
- - - '='
80
+ - - "~>"
80
81
  - !ruby/object:Gem::Version
81
- version: 0.0.2
82
+ version: '3.1'
82
83
  - !ruby/object:Gem::Dependency
83
84
  name: tty-which
84
85
  requirement: !ruby/object:Gem::Requirement
85
86
  requirements:
86
- - - '='
87
+ - - "~>"
87
88
  - !ruby/object:Gem::Version
88
- version: 0.4.2
89
+ version: '0.5'
89
90
  type: :runtime
90
91
  prerelease: false
91
92
  version_requirements: !ruby/object:Gem::Requirement
92
93
  requirements:
93
- - - '='
94
+ - - "~>"
94
95
  - !ruby/object:Gem::Version
95
- version: 0.4.2
96
+ version: '0.5'
96
97
  description: " A tool to make TOR your default gateway\n"
97
98
  email: szorfein@protonmail.com
98
99
  executables:
@@ -102,8 +103,10 @@ extra_rdoc_files:
102
103
  - README.md
103
104
  - CHANGELOG.md
104
105
  files:
106
+ - ".github/workflows/rubocop-analysis.yml"
105
107
  - ".gitignore"
106
108
  - CHANGELOG.md
109
+ - Gemfile
107
110
  - LICENSE
108
111
  - README.md
109
112
  - Rakefile
@@ -111,24 +114,31 @@ files:
111
114
  - ext/ipt_mod.conf
112
115
  - ext/iptables.service
113
116
  - lib/spior.rb
114
- - lib/spior/clear.rb
115
- - lib/spior/copy.rb
117
+ - lib/spior/dep.rb
116
118
  - lib/spior/helpers.rb
117
- - lib/spior/install.rb
118
119
  - lib/spior/iptables.rb
119
120
  - lib/spior/iptables/default.rb
120
121
  - lib/spior/iptables/root.rb
122
+ - lib/spior/iptables/rules.rb
121
123
  - lib/spior/iptables/tor.rb
122
124
  - lib/spior/menu.rb
123
125
  - lib/spior/msg.rb
124
- - lib/spior/network.rb
125
126
  - lib/spior/options.rb
126
- - lib/spior/persist.rb
127
+ - lib/spior/service.rb
128
+ - lib/spior/service/enable.rb
129
+ - lib/spior/service/restart.rb
130
+ - lib/spior/service/start.rb
131
+ - lib/spior/service/stop.rb
127
132
  - lib/spior/status.rb
128
133
  - lib/spior/tor.rb
129
- - lib/spior/tor/info.rb
130
- - lib/spior/tor/restart.rb
134
+ - lib/spior/tor/config.rb
135
+ - lib/spior/tor/data.rb
136
+ - lib/spior/tor/start.rb
137
+ - lib/spior/tor/stop.rb
131
138
  - lib/spior/version.rb
139
+ - man/spior.1
140
+ - man/spior.1.html
141
+ - man/spior.1.ronn
132
142
  - spior.gemspec
133
143
  - test/test_install.rb
134
144
  - test/test_options.rb
@@ -139,7 +149,7 @@ metadata:
139
149
  changelog_uri: https://github.com/szorfein/spior/blob/master/CHANGELOG.md
140
150
  bug_tracker_uri: https://github.com/szorfein/spior/issues
141
151
  wiki_uri: https://github.com/szorfein/spior
142
- post_install_message:
152
+ post_install_message:
143
153
  rdoc_options: []
144
154
  require_paths:
145
155
  - lib
@@ -147,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
157
  requirements:
148
158
  - - ">="
149
159
  - !ruby/object:Gem::Version
150
- version: '2.4'
160
+ version: '2.6'
151
161
  required_rubygems_version: !ruby/object:Gem::Requirement
152
162
  requirements:
153
163
  - - ">="
@@ -156,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
166
  requirements:
157
167
  - tor
158
168
  - iptables
159
- rubygems_version: 3.0.3
160
- signing_key:
169
+ rubygems_version: 3.3.19
170
+ signing_key:
161
171
  specification_version: 4
162
172
  summary: A tool to make TOR your default gateway
163
173
  test_files:
metadata.gz.sig CHANGED
Binary file
data/lib/spior/clear.rb DELETED
@@ -1,36 +0,0 @@
1
- require 'tty-which'
2
- require 'nomansland'
3
-
4
- module Spior
5
- module Clear
6
- extend self
7
-
8
- def all
9
- iptables
10
- Spior::Copy.new.restore
11
- end
12
-
13
- private
14
-
15
- def iptables
16
- puts "Clearing rules.."
17
- ipt = Spior::Iptables::Default.new
18
- ipt.stop!
19
- #if File.exist?("/var/lib/iptables/rules-save")
20
- # ipt_restore "/var/lib/iptables/rules-save"
21
- #elsif File.exist?("/etc/iptables/rules.save")
22
- # ipt_restore "/etc/iptables/iptables.rules"
23
- #elsif File.exist?("/etc/iptables.rules")
24
- # ipt_restore "/etc/iptables.rules"
25
- #else
26
- #Msg.p "Couldn't find any previous rules for iptables, create basic rules..."
27
- ipt.run!
28
- #end
29
- end
30
-
31
- def ipt_restore(path)
32
- puts "Restoring rules #{path}..."
33
- Helpers::Exec.new("iptables-restore").run("#{path}")
34
- end
35
- end
36
- end
data/lib/spior/copy.rb DELETED
@@ -1,85 +0,0 @@
1
- require 'digest'
2
-
3
- module Spior
4
- class Copy
5
- def initialize
6
- @cp = Helpers::Exec.new("cp -a")
7
- @files = []
8
- search_conf_dir
9
- config_files
10
- list
11
- end
12
-
13
- def save
14
- @files.each { |f|
15
- backup = "#{f}_backup"
16
- if ! File.exist? backup
17
- Msg.p "#{f} saved"
18
- @cp.run("#{f} #{backup}")
19
- end
20
- }
21
- end
22
-
23
- def restore
24
- @files.each { |f|
25
- backup = "#{f}_backup"
26
- if File.exist? backup
27
- Msg.p "#{f} restored"
28
- @cp.run("#{backup} #{f}")
29
- end
30
- }
31
- end
32
-
33
- private
34
-
35
- def config_files
36
- copy_file("#{@conf_dir}/ipt_mod.conf", "/etc/modules-load.d/ipt_mod.conf")
37
- end
38
-
39
- def list
40
- add "/etc/resolv.conf"
41
- add "/etc/tor/torrc"
42
- add "/etc/systemd/resolved.conf"
43
- add "/var/lib/iptables/rules-save" # gentoo
44
- add "/etc/iptables/iptables.rules" # arch
45
- add "/etc/iptables/rules.v4" # debian
46
- end
47
-
48
- def add(file)
49
- @files << file if File.exist? file
50
- end
51
-
52
- def search_conf_dir
53
- # ebuild on gentoo copy the ext dir at lib/ext
54
- @conf_dir = File.expand_path('../..' + '/lib/ext', __dir__)
55
- if ! Dir.exist?(@conf_dir)
56
- @conf_dir = File.expand_path('../..' + '/ext', __dir__)
57
- end
58
- end
59
-
60
- def previous_copy(target)
61
- backup=`ls #{target}.backup-* | head -1`.chomp
62
- return false if ! File.exist? backup
63
- check_hash(backup, target)
64
- end
65
-
66
- def add_file(target)
67
- @cp.run("#{@config_file} #{target}")
68
- Msg.p "File #{@config_file} has been successfully copied at #{target}"
69
- end
70
-
71
- def copy_file(conf, target)
72
- @config_file = conf
73
- add_file target if ! File.exist? target
74
- return if check_hash(@config_file, target)
75
- add_file target
76
- end
77
-
78
- def check_hash(src, target)
79
- return if not File.exist?(target)
80
- sha256conf = Digest::SHA256.file src
81
- sha256target = Digest::SHA256.file target
82
- sha256conf === sha256target
83
- end
84
- end
85
- end
data/lib/spior/install.rb DELETED
@@ -1,33 +0,0 @@
1
- require 'nomansland'
2
- require 'tty-which'
3
-
4
- module Spior
5
- class Install
6
- class << self
7
- def check_deps
8
- base_packages
9
- end
10
-
11
- private
12
-
13
- def base_packages
14
- if not TTY::Which.exist?('iptables') or not TTY::Which.exist?('tor')
15
- case Nomansland::installer?
16
- when :emerge
17
- emerge = Helpers::Exec.new("emerge -av --changed-use")
18
- emerge.run("tor iptables")
19
- when :pacman
20
- pacman = Helpers::Exec.new("pacman -S --needed")
21
- pacman.run("tor iptables")
22
- when :yum
23
- yum = Helpers::Exec.new("yum install")
24
- yum.run("tor iptables")
25
- else
26
- apt_get = Helpers::Exec.new("apt-get install")
27
- apt_get.run("tor iptables iptables-persistent")
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
data/lib/spior/network.rb DELETED
@@ -1,45 +0,0 @@
1
- require 'interfacez'
2
-
3
- module Spior
4
- class Network
5
- attr_accessor :card
6
-
7
- def initialize(name = false)
8
- @name = name
9
- @check = false
10
- end
11
-
12
- def card
13
- verify_card
14
- if @check == false then
15
- ask_for_card
16
- end
17
- @name
18
- end
19
-
20
- private
21
-
22
- def verify_card
23
- return if @check or not @name
24
- Interfacez.all do |interface|
25
- if interface == @name then
26
- @check = true
27
- end
28
- end
29
- if not @check then
30
- Msg.err "Your interface #{@name} is no found"
31
- end
32
- end
33
-
34
- def ask_for_card
35
- until @check == true
36
- Interfacez.all do |interface|
37
- print interface + " "
38
- end
39
- printf "\nWhat is the name of the card to be used? "
40
- @name = gets.chomp
41
- verify_card
42
- end
43
- end
44
- end
45
- end
data/lib/spior/persist.rb DELETED
@@ -1,51 +0,0 @@
1
- require 'nomansland'
2
- require 'tty-which'
3
-
4
- module Spior
5
- module Persist
6
- extend self
7
-
8
- def enable
9
- case Nomansland::distro?
10
- when :gentoo
11
- for_gentoo
12
- else
13
- Msg.p "Your distro is not yet supported."
14
- end
15
- end
16
-
17
- private
18
-
19
- def for_gentoo
20
- if TTY::Which.exist?('systemctl')
21
- systemd_start("iptables-store")
22
- systemd_enable("iptables-restore")
23
- systemd_enable("tor")
24
- else
25
- system("sudo /etc/init.d/iptables save")
26
- rc_upd = Helpers::Exec.new("rc-update")
27
- rc_upd.run("rc-update add iptables boot")
28
- rc_upd.run("rc-update add tor")
29
- rc_upd.run("rc-update add tor default")
30
- end
31
- end
32
-
33
- def systemd_enable(service)
34
- systemctl = Helpers::Exec.new("systemctl")
35
- Msg.p "Search for service #{service}..."
36
- `systemctl is-enabled #{service}`
37
- if not $?.success? then
38
- systemctl.run("enable #{service}")
39
- end
40
- end
41
-
42
- def systemd_start(service)
43
- systemctl = Helpers::Exec.new("systemctl")
44
- Msg.p "Search for service #{service}..."
45
- `systemctl is-active #{service}`
46
- if not $?.success? then
47
- systemctl.run("start #{service}")
48
- end
49
- end
50
- end
51
- end
@@ -1,113 +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
- check_deps
13
- @dns = search_dns
14
- @uid = search_uid
15
- @trans_port = search_trans_port
16
- @virt_addr = search_virt_addr
17
- end
18
-
19
- private
20
-
21
- def check_deps
22
- Spior::Install::check_deps
23
- Spior::Copy.new.save
24
- add_resolv
25
- add_torrc
26
- verify_service
27
- end
28
-
29
- def add_resolv
30
- string = "nameserver 127.0.0.1"
31
- new_file = Helpers::NewFile.new(string, "resolv.conf", "/etc")
32
- new_file.add
33
- new_file.perm("root", "644")
34
- end
35
-
36
- def self.grep?(file, regex)
37
- is_found = false
38
- return is_found if ! File.exist? file
39
- File.open(file) do |f|
40
- f.each do |line|
41
- is_found = true if line.match(regex)
42
- end
43
- end
44
- is_found
45
- end
46
-
47
- def add_torrc
48
- user = ""
49
- pid = ""
50
- dir = "DataDirectory /var/lib/tor/data"
51
- case Nomansland::distro?
52
- when :gentoo
53
- user = "User tor"
54
- pid = "PIDFile /run/tor/tor.pid"
55
- end
56
- string = <<EOF
57
- # Generated by Spior
58
- #{user}
59
- #{pid}
60
- #{dir}
61
- GeoIPExcludeUnknown 1
62
- DNSPort 127.0.0.1:9061
63
- AutomapHostsOnResolve 1
64
- AutomapHostsSuffixes .exit,.onion
65
- SocksPort 9050
66
- VirtualAddrNetworkIPv4 10.192.0.0/10
67
- TransPort 9040 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
68
- TestSocks 1
69
- MaxCircuitDirtiness 600
70
- EOF
71
- new_file = Helpers::NewFile.new(string, "torrc", "/etc/tor")
72
- new_file.add
73
- new_file.perm("root", "644")
74
- end
75
-
76
- def search_dns
77
- 9061
78
- end
79
-
80
- def search_uid
81
- case Nomansland::distro?
82
- when :debian
83
- `id -u debian-tor`.chomp
84
- when :ubuntu
85
- `id -u debian-tor`.chomp
86
- else
87
- `id -u tor`.chomp
88
- end
89
- end
90
-
91
- def search_trans_port
92
- 9040
93
- end
94
-
95
- def search_virt_addr
96
- "10.192.0.0/10"
97
- end
98
-
99
- def verify_service
100
- if TTY::Which.exist?('systemctl')
101
- state = `systemctl is-active tor`.chomp
102
- if state == 'active'
103
- @systemctl.run('restart tor')
104
- else
105
- @systemctl.run('start tor')
106
- end
107
- else
108
- Msg.for_no_systemd
109
- end
110
- end
111
- end
112
- end
113
- end
@@ -1,13 +0,0 @@
1
- require 'tty-which'
2
-
3
- module Spior
4
- module Tor
5
- module_function
6
- def restart
7
- if TTY::Which.exist?('systemctl')
8
- Helpers::Exec.new("systemctl").run("restart tor")
9
- Msg.p "ip changed"
10
- end
11
- end
12
- end
13
- end