sheepsafe 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,18 @@
1
+ === 0.2.5
2
+
3
+ - Wait a bit before starting proxy when switching networks
4
+ - Allow specification of port for ssh (thanks Kevin Ball)
5
+ - Add wifi blacklist (thanks Tim Felgentreff)
6
+ - Add ability to trust encrypted wifi networks (thanks Tim Felgentreff)
7
+
8
+ === 0.2.4
9
+
10
+ - Ensure the ~/Library/LaunchAgents directory exists
11
+ - Docs and `sheepsafe proxy kick`
12
+ - sheepsafe list|add commands (thanks Ted Nielsen)
13
+ - Use connection response from http://example.com as indication that
14
+ we're past a paywall wifi network (idea thanks to Adam Keys)
15
+
1
16
  === 0.2.3
2
17
 
3
18
  - Recycle the proxy server on every launch when on the Untrusted
@@ -3,9 +3,9 @@ require 'yaml'
3
3
  module Sheepsafe
4
4
  class Config
5
5
  FILE = File.expand_path('~/.sheepsafe.yml')
6
- DEFAULT_CONFIG = {"untrusted_location" => "Untrusted", "socks_port" => "9999"}
7
- ATTRS = %w(trusted_location untrusted_location last_network ssh_host socks_port)
8
- ARRAY_ATTRS = %w(trusted_names)
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?)
8
+ ARRAY_ATTRS = %w(trusted_names untrusted_names)
9
9
 
10
10
  def self.load_config
11
11
  YAML.load_file(FILE)
@@ -47,7 +47,7 @@ module Sheepsafe
47
47
  end
48
48
  @config.last_network = @network
49
49
  @config.write
50
- elsif !@network.trusted?
50
+ elsif !@network.trustworthy?
51
51
  # recycle the proxy server on network changes
52
52
  bring_socks_proxy 'restart'
53
53
  end
@@ -66,11 +66,11 @@ module Sheepsafe
66
66
  end
67
67
 
68
68
  def switch_to_trusted?
69
- @network.trusted?
69
+ @network.trustworthy?
70
70
  end
71
71
 
72
72
  def switch_to_untrusted?
73
- !@network.trusted?
73
+ !@network.trustworthy?
74
74
  end
75
75
 
76
76
  def bring_socks_proxy(direction)
@@ -87,9 +87,10 @@ module Sheepsafe
87
87
  Process.kill("TERM", pid)
88
88
  exit 0
89
89
  end
90
+ sleep 2 # wait a bit before starting proxy
90
91
  loop do
91
92
  pid = fork do
92
- exec("ssh -ND #{@config.socks_port} #{@config.ssh_host}")
93
+ exec("ssh -p #{@config.ssh_port } -ND #{@config.socks_port} #{@config.ssh_host}")
93
94
  end
94
95
  Process.waitpid(pid)
95
96
  sleep 1
@@ -38,8 +38,12 @@ MSG
38
38
  q.default = config.ssh_host
39
39
  end
40
40
 
41
+ config.ssh_port = ask "SSH Port >\n" do |q|
42
+ q.default = config.ssh_port || 22
43
+ end
44
+
41
45
  say "Testing connectivitity to #{config.ssh_host}..."
42
- system "ssh #{config.ssh_host} true"
46
+ system "ssh -p #{config.ssh_port} #{config.ssh_host} true"
43
47
  unless $?.success?
44
48
  abort "Sorry! that ssh host was no good."
45
49
  end
@@ -8,10 +8,22 @@ module Sheepsafe
8
8
  @config = config || Sheepsafe::Config.new({})
9
9
  end
10
10
 
11
+ def trustworthy?
12
+ !untrusted? && (encrypted? && @config.trust_encrypted? || trusted?)
13
+ end
14
+
11
15
  def trusted?
12
16
  @config.trusted_names.include?(ssid) || @config.trusted_names.include?(bssid)
13
17
  end
14
18
 
19
+ def untrusted?
20
+ @config.untrusted_names.include?(ssid) || @config.untrusted_names.include?(bssid)
21
+ end
22
+
23
+ def encrypted?
24
+ !(@data["802.11 auth"] == "open" or @data["link auth"] == "open")
25
+ end
26
+
15
27
  def up?
16
28
  @data['AirPort'] != false
17
29
  end
data/lib/sheepsafe.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Sheepsafe
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
4
4
 
5
5
  require 'sheepsafe/config'
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.2.4'
6
- s.date = '2010-11-09'
5
+ s.version = '0.2.5'
6
+ s.date = '2010-11-19'
7
7
 
8
8
  s.rubyforge_project = %q{caldersphere}
9
9
 
@@ -33,14 +33,14 @@ describe Sheepsafe::Controller do
33
33
 
34
34
  context "#switch_to_trusted?" do
35
35
  it "is when the current network is trusted" do
36
- network.stub :trusted? => true
36
+ network.stub :trustworthy? => true
37
37
  controller.switch_to_trusted?.should be_true
38
38
  end
39
39
  end
40
40
 
41
41
  context "#switch_to_untrusted?" do
42
42
  it "is when the current network is trusted" do
43
- network.stub :trusted? => false
43
+ network.stub :trustworthy? => false
44
44
  controller.switch_to_untrusted?.should be_true
45
45
  end
46
46
  end
@@ -51,13 +51,13 @@ describe Sheepsafe::Controller do
51
51
  end
52
52
 
53
53
  it "does not touch config" do
54
- network.stub :trusted? => true
54
+ network.stub :trustworthy? => true
55
55
  config.should_not_receive(:write)
56
56
  controller.run
57
57
  end
58
58
 
59
59
  it "recycles the proxy server process when on the untrusted network" do
60
- network.stub :trusted? => false
60
+ network.stub :trustworthy? => false
61
61
  controller.should_receive(:bring_socks_proxy).with('restart')
62
62
  controller.run
63
63
  end
@@ -121,6 +121,34 @@ describe Sheepsafe::Network do
121
121
  it { should be_trusted }
122
122
  end
123
123
 
124
+ context "with untrusted SSID" do
125
+ let(:config) { Sheepsafe::Config.new({"untrusted_names" => [current_network.ssid]}) }
126
+ subject { Sheepsafe::Network.new(config) }
127
+
128
+ it { should_not be_trusted }
129
+ end
130
+
131
+ context "with untrusted BSSID" do
132
+ let(:config) { Sheepsafe::Config.new({"untrusted_names" => [current_network.bssid]}) }
133
+ subject { Sheepsafe::Network.new(config) }
134
+
135
+ it { should_not be_trusted }
136
+ end
137
+
138
+ context "with trusted encryption" do
139
+ let(:config) { Sheepsafe::Config.new({"trust_encrypted?" => true}) }
140
+ subject { Sheepsafe::Network.new(config) }
141
+
142
+ it { should be_trusted if subject.encrypted? }
143
+ end
144
+
145
+ context "with untrusted encryption" do
146
+ let(:config) { Sheepsafe::Config.new({"trust_encrypted?" => false}) }
147
+ subject { Sheepsafe::Network.new(config) }
148
+
149
+ it { should_not be_trusted }
150
+ end
151
+
124
152
  context "with no trusted names" do
125
153
  subject { Sheepsafe::Network.new }
126
154
 
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: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 4
10
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
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: 2010-11-09 00:00:00 -08:00
18
+ date: 2010-11-19 00:00:00 -06:00
19
19
  default_executable: sheepsafe
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency