sandboxer 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/sandbox.rb +12 -4
- metadata +3 -3
data/README.md
CHANGED
@@ -8,11 +8,12 @@ Available commands:
|
|
8
8
|
* `sandbox add {domain} {ip}` — adds the specified domain pointing to the specified IP
|
9
9
|
* `sandbox destination {ip}` - sets the default sandbox IP
|
10
10
|
* `sandbox remove {domain}` — removes the specified domain
|
11
|
+
* `sandbox clear` - removes all current entries
|
11
12
|
* `sandbox on` — enables all saved entries
|
12
13
|
* `sandbox off` — disables all saved entries
|
13
14
|
* `sandbox status` — shows the current status of the tool (on/off status and current default destination IP)
|
14
15
|
|
15
|
-
Note: if sandbox development is on, `add` and `
|
16
|
+
Note: if sandbox development is on, `add`, `remove`, and `clear` commands will immediately update the hosts file and trigger a DNS flush.
|
16
17
|
|
17
18
|
## Installation
|
18
19
|
|
data/lib/sandbox.rb
CHANGED
@@ -26,7 +26,7 @@ require 'digest/md5'
|
|
26
26
|
|
27
27
|
|
28
28
|
class Sandbox
|
29
|
-
VERSION = '0.1.
|
29
|
+
VERSION = '0.1.3'
|
30
30
|
def initialize
|
31
31
|
@debug = false
|
32
32
|
@sandbox = '/etc/hosts-sandbox'
|
@@ -35,7 +35,7 @@ class Sandbox
|
|
35
35
|
@default_destination = '127.0.0.1'
|
36
36
|
@start = '#==SANDBOX==#'
|
37
37
|
@end = '#/==SANDBOX==#'
|
38
|
-
if !ARGV.first.nil? && [:on, :off, :add, :remove, :destination].include?( ARGV.first.to_sym )
|
38
|
+
if !ARGV.first.nil? && [:on, :off, :add, :remove, :destination, :clear].include?( ARGV.first.to_sym )
|
39
39
|
require_sudo
|
40
40
|
ensure_sandbox_exists
|
41
41
|
end
|
@@ -46,7 +46,7 @@ class Sandbox
|
|
46
46
|
case command
|
47
47
|
when :"--v", :"--version"
|
48
48
|
info
|
49
|
-
when :on, :off, :status
|
49
|
+
when :on, :off, :status, :clear
|
50
50
|
send command
|
51
51
|
when :add
|
52
52
|
require_sudo
|
@@ -67,7 +67,7 @@ class Sandbox
|
|
67
67
|
ensure_sandbox_exists
|
68
68
|
send command, object
|
69
69
|
when nil, '--help', '-h'
|
70
|
-
exit_message "Usage: sandbox [on|off|status]\n sandbox [destination] newdefault\n sandbox [add|remove] domain destination"
|
70
|
+
exit_message "Usage: sandbox [on|off|status|clear]\n sandbox [destination] newdefault\n sandbox [add|remove] domain destination"
|
71
71
|
else
|
72
72
|
exit_error_message "Invalid command"
|
73
73
|
end
|
@@ -223,6 +223,14 @@ class Sandbox
|
|
223
223
|
return status
|
224
224
|
end
|
225
225
|
|
226
|
+
def clear
|
227
|
+
File.open( @sandbox, 'w' ) do |file|
|
228
|
+
file.truncate(0)
|
229
|
+
end
|
230
|
+
enable
|
231
|
+
puts "All sandbox entries have been removed"
|
232
|
+
end
|
233
|
+
|
226
234
|
def status
|
227
235
|
puts "Sandbox is #{get_status}"
|
228
236
|
puts "Current default sandbox destination is #{get_destination}"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandboxer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Shreve
|