sheepsafe 0.3.2 → 0.3.3

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.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sheepsafe (0.3.2)
5
+ daemons (~> 1.1)
6
+ highline (~> 1.6)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ daemons (1.1.8)
12
+ diff-lcs (1.1.3)
13
+ highline (1.6.11)
14
+ rspec (2.9.0)
15
+ rspec-core (~> 2.9.0)
16
+ rspec-expectations (~> 2.9.0)
17
+ rspec-mocks (~> 2.9.0)
18
+ rspec-core (2.9.0)
19
+ rspec-expectations (2.9.0)
20
+ diff-lcs (~> 1.1.3)
21
+ rspec-mocks (2.9.0)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ rspec (~> 2.0)
28
+ sheepsafe!
@@ -1,3 +1,8 @@
1
+ === 0.3.3
2
+
3
+ - Detect "AirPort" or "Wi-Fi" network service name in installer
4
+ - Allow disabling sheepsafe with command-line "sheepsafe <enable|disable>"
5
+
1
6
  === 0.3.2
2
7
 
3
8
  - Migrate all sheepsafe files to ~/.sheepsafe/ directory (Justin Ridgewell)
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ def date
21
21
  end
22
22
 
23
23
  def rubyforge_project
24
- "jruby-extras"
24
+ "caldersphere"
25
25
  end
26
26
 
27
27
  def gemspec_file
@@ -8,15 +8,11 @@ rescue LoadError
8
8
  require 'sheepsafe'
9
9
  end
10
10
 
11
- if ARGV.length == 1
11
+ if ARGV.length > 0 && Sheepsafe::Installer.instance_methods(false).map(&:to_s).include?(ARGV[0])
12
12
  installer = Sheepsafe::Installer.new
13
- if installer.respond_to?(ARGV.first)
14
- installer.send(ARGV.first)
15
- else
16
- abort "unknown command #{ARGV.first}. Try 'install', 'update', or 'uninstall'."
17
- end
13
+ installer.send(ARGV.first)
18
14
  else
19
15
  # Allow network changes to sink in for a couple more seconds
20
- sleep 2
16
+ sleep 2 if ARGV.length == 0
21
17
  Sheepsafe::Controller.new.run
22
18
  end
@@ -1,5 +1,5 @@
1
1
  module Sheepsafe
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
4
4
 
5
5
  require 'sheepsafe/config'
@@ -3,8 +3,8 @@ require 'yaml'
3
3
  module Sheepsafe
4
4
  class Config
5
5
  FILE = File.expand_path('~/.sheepsafe/sheepsafe.yml')
6
- DEFAULT_CONFIG = {"untrusted_location" => "Untrusted", "socks_port" => "9999", "trust_encrypted?" => "false"}
7
- ATTRS = %w(trusted_location untrusted_location last_network ssh_host ssh_port socks_port trust_encrypted?)
6
+ DEFAULT_CONFIG = {"untrusted_location" => "Untrusted", "socks_port" => "9999", "trust_encrypted?" => "false", "disabled" => "false"}
7
+ ATTRS = %w(trusted_location untrusted_location last_network ssh_host ssh_port socks_port trust_encrypted? disabled)
8
8
  ARRAY_ATTRS = %w(trusted_names untrusted_names)
9
9
 
10
10
  def self.load_config
@@ -32,16 +32,33 @@ module Sheepsafe
32
32
  $stdout = TeeStdout.new(self)
33
33
  end
34
34
 
35
- def run
35
+ def run(args = ARGV)
36
36
  log("Sheepsafe starting")
37
37
 
38
- if ARGV.first == 'proxy' # 'sheepsafe proxy up/down/kick'
39
- bring_socks_proxy ARGV[1]
38
+ case args.first
39
+ when 'proxy' # 'sheepsafe proxy up/down/kick'
40
+ bring_socks_proxy args[1]
40
41
  return
42
+ when 'disable'
43
+ @config.disabled = true
44
+ @config.write
45
+ bring_socks_proxy 'down'
46
+ system "scselect #{@config.trusted_location}"
47
+ return
48
+ when 'enable'
49
+ @config.disabled = nil
50
+ @config.write
51
+ when nil
52
+ true # continue
53
+ else
54
+ abort "unknown command #{args.first}. Try 'install', 'update', or 'uninstall'."
41
55
  end
42
56
 
43
57
  # Always recycle the proxy server on network changes
44
58
  bring_socks_proxy 'down'
59
+
60
+ return if @config.disabled
61
+
45
62
  if network_up?
46
63
  if network_changed?
47
64
  if switch_to_trusted?
@@ -92,7 +92,8 @@ MSG
92
92
 
93
93
  if agree "Next, I'll set up the SOCKS proxy in the \"Untrusted\" location for you. OK\? (yes/no)\n"
94
94
  system "networksetup -switchtolocation Untrusted"
95
- system "networksetup -setsocksfirewallproxy AirPort localhost #{config.socks_port}"
95
+ wifi_service = `networksetup -listallnetworkservices`.lines.detect {|l| l[/(AirPort|Wi-Fi)/, 1] }
96
+ system "networksetup -setsocksfirewallproxy wifi_service localhost #{config.socks_port}"
96
97
  end
97
98
  end
98
99
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'sheepsafe'
5
- s.version = '0.3.2'
6
- s.date = '2011-06-05'
5
+ s.version = '0.3.3'
6
+ s.date = '2012-04-01'
7
7
 
8
8
  s.rubyforge_project = %q{caldersphere}
9
9
 
@@ -35,6 +35,8 @@ current configuration, run \`sheepsafe update\'.
35
35
 
36
36
  # = MANIFEST =
37
37
  s.files = %w[
38
+ Gemfile
39
+ Gemfile.lock
38
40
  History.txt
39
41
  LICENSE
40
42
  README.md
@@ -4,7 +4,7 @@ require 'sheepsafe'
4
4
  describe Sheepsafe::Controller do
5
5
  let(:config) do
6
6
  double("config", :trusted_location => "trusted_location", :untrusted_location => "untrusted_location",
7
- :last_network= => nil, :write => nil)
7
+ :last_network= => nil, :write => nil, :disabled => nil)
8
8
  end
9
9
 
10
10
  let (:network) do
@@ -53,14 +53,14 @@ describe Sheepsafe::Controller do
53
53
  it "does not touch config" do
54
54
  network.stub :trustworthy? => true
55
55
  config.should_not_receive(:write)
56
- controller.run
56
+ controller.run([])
57
57
  end
58
58
 
59
59
  it "recycles the proxy server process when on the untrusted network" do
60
60
  network.stub :trustworthy? => false
61
61
  controller.should_receive(:bring_socks_proxy).with('down')
62
62
  controller.should_receive(:bring_socks_proxy).with('up')
63
- controller.run
63
+ controller.run([])
64
64
  end
65
65
  end
66
66
 
@@ -68,7 +68,16 @@ describe Sheepsafe::Controller do
68
68
  it "does nothing" do
69
69
  network.should_receive(:up?).and_return false
70
70
  config.should_not_receive(:write)
71
- controller.run
71
+ controller.run([])
72
+ end
73
+ end
74
+
75
+ context "disabled in config" do
76
+ it "does nothing" do
77
+ config.stub :disabled => true
78
+ controller.should_receive(:bring_socks_proxy).with('down')
79
+ config.should_not_receive(:write)
80
+ controller.run([])
72
81
  end
73
82
  end
74
83
 
@@ -81,7 +90,7 @@ describe Sheepsafe::Controller do
81
90
  it "writes the last network to the configuration" do
82
91
  config.should_receive(:last_network=).ordered
83
92
  config.should_receive(:write).ordered
84
- controller.run
93
+ controller.run([])
85
94
  end
86
95
 
87
96
  context "to trusted" do
@@ -89,7 +98,7 @@ describe Sheepsafe::Controller do
89
98
  controller.should_receive(:switch_to_trusted?).and_return true
90
99
  controller.should_receive(:system).with("scselect trusted_location")
91
100
  controller.should_receive(:bring_socks_proxy).with('down')
92
- controller.run
101
+ controller.run([])
93
102
  end
94
103
  end
95
104
 
@@ -100,10 +109,28 @@ describe Sheepsafe::Controller do
100
109
  controller.should_receive(:system).with("scselect untrusted_location")
101
110
  controller.should_receive(:bring_socks_proxy).with('down')
102
111
  controller.should_receive(:bring_socks_proxy).with('up')
103
- controller.run
112
+ controller.run([])
104
113
  end
105
114
  end
106
115
  end
116
+
117
+ context "sheepsafe proxy down" do
118
+ it "brings the proxy down and then exits" do
119
+ controller.should_receive(:bring_socks_proxy).with('down')
120
+ config.should_not_receive(:write)
121
+ controller.run(["proxy", "down"])
122
+ end
123
+ end
124
+
125
+ context "sheepsafe disable" do
126
+ it "writes disabled:true to the config" do
127
+ config.should_receive(:disabled=).with(true)
128
+ config.should_receive(:write)
129
+ controller.should_receive(:bring_socks_proxy).with('down')
130
+ controller.should_receive(:system).with("scselect trusted_location")
131
+ controller.run(["disable"])
132
+ end
133
+ end
107
134
  end
108
135
 
109
136
  describe Sheepsafe::Config, "#ssh_args" 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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
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-06-05 00:00:00 Z
18
+ date: 2012-04-01 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: highline
@@ -72,6 +72,8 @@ extra_rdoc_files:
72
72
  - README.md
73
73
  - LICENSE
74
74
  files:
75
+ - Gemfile
76
+ - Gemfile.lock
75
77
  - History.txt
76
78
  - LICENSE
77
79
  - README.md
@@ -123,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
125
  requirements: []
124
126
 
125
127
  rubyforge_project: caldersphere
126
- rubygems_version: 1.7.2
128
+ rubygems_version: 1.8.21
127
129
  signing_key:
128
130
  specification_version: 3
129
131
  summary: Makes sure you're safe from FireSheep!