sheepsafe 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/lib/sheepsafe/config.rb +2 -2
- data/lib/sheepsafe/controller.rb +4 -4
- data/lib/sheepsafe/installer.rb +24 -1
- data/lib/sheepsafe.rb +1 -1
- data/sheepsafe.gemspec +2 -3
- data/spec/sheepsafe_spec.rb +2 -1
- metadata +4 -4
data/History.txt
CHANGED
data/lib/sheepsafe/config.rb
CHANGED
@@ -2,7 +2,7 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module Sheepsafe
|
4
4
|
class Config
|
5
|
-
FILE = File.expand_path('~/.sheepsafe.yml')
|
5
|
+
FILE = File.expand_path('~/.sheepsafe/sheepsafe.yml')
|
6
6
|
DEFAULT_CONFIG = {"untrusted_location" => "Untrusted", "socks_port" => "9999", "trust_encrypted?" => "false"}
|
7
7
|
ATTRS = %w(trusted_location untrusted_location last_network ssh_host ssh_port socks_port trust_encrypted?)
|
8
8
|
ARRAY_ATTRS = %w(trusted_names untrusted_names)
|
@@ -10,7 +10,7 @@ module Sheepsafe
|
|
10
10
|
def self.load_config
|
11
11
|
YAML.load_file(FILE)
|
12
12
|
rescue Errno::ENOENT
|
13
|
-
raise "Unable to read ~/.sheepsafe.yml; please run sheepsafe-install"
|
13
|
+
raise "Unable to read ~/.sheepsafe/sheepsafe.yml; please run sheepsafe-install"
|
14
14
|
end
|
15
15
|
|
16
16
|
attr_reader :config
|
data/lib/sheepsafe/controller.rb
CHANGED
@@ -51,8 +51,8 @@ module Sheepsafe
|
|
51
51
|
notified = false
|
52
52
|
loop do
|
53
53
|
require 'open-uri'
|
54
|
-
|
55
|
-
break if
|
54
|
+
is_google_com = open("http://www.google.com") {|f| f.meta['server'] == 'gws'} rescue nil
|
55
|
+
break if is_google_com
|
56
56
|
notify_warning("Waiting for internet connection before switching") unless notified
|
57
57
|
notified = true
|
58
58
|
sleep 5
|
@@ -96,7 +96,7 @@ module Sheepsafe
|
|
96
96
|
else
|
97
97
|
direction
|
98
98
|
end
|
99
|
-
Daemons.run_proc('
|
99
|
+
Daemons.run_proc('sheepsafe.proxy', :ARGV => [cmd], :dir_mode => :normal, :dir => "#{ENV['HOME']}/.sheepsafe") do
|
100
100
|
pid = nil
|
101
101
|
trap("TERM") do
|
102
102
|
Process.kill("TERM", pid)
|
@@ -120,7 +120,7 @@ module Sheepsafe
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def proxy_running?
|
123
|
-
File.exist?("#{ENV['HOME']}/.sheepsafe.proxy.pid") && File.read("#{ENV['HOME']}/.sheepsafe.proxy.pid").to_i > 0
|
123
|
+
File.exist?("#{ENV['HOME']}/.sheepsafe/sheepsafe.proxy.pid") && File.read("#{ENV['HOME']}/.sheepsafe/sheepsafe.proxy.pid").to_i > 0
|
124
124
|
end
|
125
125
|
|
126
126
|
def notify_ok(msg)
|
data/lib/sheepsafe/installer.rb
CHANGED
@@ -5,6 +5,7 @@ module Sheepsafe
|
|
5
5
|
attr_reader :config, :network, :controller
|
6
6
|
|
7
7
|
def initialize(config = nil, network = nil, controller = nil)
|
8
|
+
check_config_path
|
8
9
|
require 'highline/import'
|
9
10
|
@config = config || (File.readable?(Sheepsafe::Config::FILE) ? Sheepsafe::Config.new : Sheepsafe::Config.new({}))
|
10
11
|
@network = network || Sheepsafe::Network.new(@config)
|
@@ -13,6 +14,7 @@ module Sheepsafe
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def install
|
17
|
+
migrate_old_config_path
|
16
18
|
intro_message
|
17
19
|
config_prompts
|
18
20
|
setup_network_location
|
@@ -22,6 +24,27 @@ module Sheepsafe
|
|
22
24
|
announce_done
|
23
25
|
end
|
24
26
|
|
27
|
+
def check_config_path
|
28
|
+
if !File.directory? "#{ENV['HOME']}/.sheepsafe/"
|
29
|
+
Dir.mkdir("#{ENV['HOME']}/.sheepsafe/")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def migrate_old_config_path
|
34
|
+
reinitialize = false
|
35
|
+
if File.exist?("#{ENV['HOME']}/.sheepsafe.log")
|
36
|
+
reinitialize = true
|
37
|
+
say "Moving old sheepsafe.log file to new directory."
|
38
|
+
system "mv ~/.sheepsafe.log ~/.sheepsafe/sheepsafe.log"
|
39
|
+
end
|
40
|
+
if File.exist?("#{ENV['HOME']}/.sheepsafe.yml")
|
41
|
+
reinitialize = true
|
42
|
+
say "Moving old sheepsafe.yml file to new directory."
|
43
|
+
system "mv ~/.sheepsafe.yml ~/.sheepsafe/sheepsafe.yml"
|
44
|
+
end
|
45
|
+
initialize if reinitialize
|
46
|
+
end
|
47
|
+
|
25
48
|
def intro_message
|
26
49
|
say(<<-MSG)
|
27
50
|
Welcome to Sheepsafe!
|
@@ -133,7 +156,7 @@ PLIST
|
|
133
156
|
system "launchctl unload #{PLIST_FILE}"
|
134
157
|
File.unlink PLIST_FILE rescue nil
|
135
158
|
end
|
136
|
-
|
159
|
+
system "rm -r ~/.sheepsafe"
|
137
160
|
say "Uninstall finished."
|
138
161
|
end
|
139
162
|
|
data/lib/sheepsafe.rb
CHANGED
data/sheepsafe.gemspec
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'sheepsafe'
|
5
|
-
s.version = '0.3.
|
6
|
-
s.date = '2011-05
|
5
|
+
s.version = '0.3.2'
|
6
|
+
s.date = '2011-06-05'
|
7
7
|
|
8
8
|
s.rubyforge_project = %q{caldersphere}
|
9
9
|
|
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.rdoc_options = ["--charset=UTF-8"]
|
18
18
|
s.extra_rdoc_files = %w[README.md LICENSE]
|
19
19
|
s.executables = ["sheepsafe"]
|
20
|
-
s.default_executable = "sheepsafe"
|
21
20
|
|
22
21
|
s.post_install_message = %[
|
23
22
|
===========================================================================
|
data/spec/sheepsafe_spec.rb
CHANGED
@@ -179,7 +179,7 @@ describe Sheepsafe::Installer do
|
|
179
179
|
let(:config) { double("config").as_null_object }
|
180
180
|
let(:network) { double("network", :up? => true, :ssid => "current", :bssid => "current_bssid") }
|
181
181
|
let(:controller) { double "controller" }
|
182
|
-
let
|
182
|
+
let(:installer) do
|
183
183
|
@messages = []
|
184
184
|
@commands = []
|
185
185
|
Sheepsafe::Installer.new(config, network, controller).tap do |ins|
|
@@ -203,6 +203,7 @@ describe Sheepsafe::Installer do
|
|
203
203
|
|
204
204
|
before :each do
|
205
205
|
$?.stub :success? => true
|
206
|
+
File.stub!(:exist?).and_return false
|
206
207
|
end
|
207
208
|
|
208
209
|
it "asks questions, runs commands, writes the config to disk and runs the controller" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sheepsafe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nick Sieger
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05
|
18
|
+
date: 2011-06-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: highline
|