fog-bouncer 0.0.6 → 0.0.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.
data/fog-bouncer.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["dylanegan@gmail.com"]
7
7
  gem.description = %q{A simple way to define and manage security groups for AWS with the backing support of fog.}
8
8
  gem.summary = %q{A manage security.}
9
- gem.homepage = ""
9
+ gem.homepage = "https://github.com/dylanegan/fog-bouncer"
10
10
 
11
11
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
12
  gem.files = `git ls-files`.split("\n")
@@ -128,7 +128,9 @@ module Fog
128
128
  return if @using.empty?
129
129
 
130
130
  @using.each do |definition|
131
- add_source(definition[:source], &definition[:block])
131
+ definition[:sources].each do |source|
132
+ add_source(source, &definition[:block])
133
+ end
132
134
  end
133
135
  end
134
136
 
@@ -17,9 +17,9 @@ module Fog
17
17
  @accounts ||= { 'amazon-elb' => 'amazon-elb', 'self' => Fog::Bouncer.aws_account_id }
18
18
  end
19
19
 
20
- def define(name, source, &block)
20
+ def define(name, sources, &block)
21
21
  raise SourceBlockRequired unless block_given?
22
- @definitions[name] = { source: source, block: block }
22
+ @definitions[name] = { sources: Array(sources), block: block }
23
23
  end
24
24
 
25
25
  def definitions(name)
@@ -69,7 +69,9 @@ module Fog
69
69
 
70
70
  @using.each do |definition|
71
71
  @groups.each do |group|
72
- group.add_source(definition[:source], &definition[:block])
72
+ definition[:sources].each do |source|
73
+ group.add_source(source, &definition[:block])
74
+ end
73
75
  end
74
76
  end
75
77
  end
@@ -5,16 +5,23 @@ module Fog
5
5
  module Bouncer
6
6
  module Sources
7
7
  def self.for(source, group, &block)
8
- if source =~ /^\d+\.\d+\.\d+.\d+\/\d+$/
8
+ begin
9
9
  CIDR.new(source, group, &block)
10
- else
11
- Group.new(source, group, &block)
10
+ rescue ArgumentError => e
11
+ if e.message =~ /Invalid IP/
12
+ Group.new(source, group, &block)
13
+ else
14
+ raise e
15
+ end
12
16
  end
13
17
  end
14
18
 
15
19
  class CIDR < Fog::Bouncer::Source
20
+ attr_reader :ip
21
+
16
22
  def initialize(source, group, &block)
17
- source = IPAddress::IPv4.new(source).to_string
23
+ @ip = IPAddress::IPv4.new(source)
24
+ source = @ip.to_string
18
25
  super
19
26
  end
20
27
 
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Bouncer
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ Fog::Bouncer.security :private do
5
5
  icmp :ping
6
6
  end
7
7
 
8
- define :ssh, "0.0.0.0/0" do
8
+ define :ssh, ["0.0.0.0/0", "1.1.1.1/1"] do
9
9
  tcp 22
10
10
  end
11
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-bouncer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-12 00:00:00.000000000 Z
12
+ date: 2012-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
@@ -144,7 +144,7 @@ files:
144
144
  - spec/fog/bouncer_spec.rb
145
145
  - spec/helper.rb
146
146
  - spec/support/security/private.rb
147
- homepage: ''
147
+ homepage: https://github.com/dylanegan/fog-bouncer
148
148
  licenses: []
149
149
  post_install_message:
150
150
  rdoc_options: []