onesnooper-server 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddde539b87f2e399138adb90fb527f961c7f93e6
4
- data.tar.gz: 56056665bb72f2947b9c8bead3d03a897fed3a68
3
+ metadata.gz: f37b299a996de04590e37698e8653e38524621da
4
+ data.tar.gz: 2111589b7f09581c5f91f3873d0ca561f2553ebc
5
5
  SHA512:
6
- metadata.gz: 9f9454da3a5245bd293ca38dfe284716b36de2640e98c276ddcafb6ef18945d7731c93a6ca08a2181fad4049dfc5ffcc1e8020d3ca3fcbc5d20a118597d27f06
7
- data.tar.gz: 76d09bd95c7dcedfa7abd081ba560f66974eaea1f2ee5a73aecf9804a34559da02fe0746c38e2c5fc6b2286fa403e510108b08eb94b1c3c9872297eced542529
6
+ metadata.gz: 2dd3a98270426888068976d57e84fe6bbc40c0936bb48bac922ba1cd87414dc4d7ab3be36df85a0695228b52dd4d7f33fec0b369876e59a4db0380ef60a5181e
7
+ data.tar.gz: 6e5add9f0fad2db2030bebf00fbc672c2632e437f6222bf20654906762738fb9d2d833a212fc59bba52e4d6be985a3e94cfe407646368d28a7dc395da325dd0f
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1
7
+ - ruby-head
8
+
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
12
+ fast_finish: true
13
+
14
+ branches:
15
+ only:
16
+ - master
@@ -5,6 +5,7 @@ module OnesnooperServer; end
5
5
  # internal ruby dependencies
6
6
  require 'date'
7
7
  require 'ipaddr'
8
+ require 'resolv'
8
9
  require 'base64'
9
10
 
10
11
  # active support stuff
@@ -32,7 +32,7 @@ class OnesnooperServer::RequestHandler
32
32
  # @param source_port [String] port number of the client
33
33
  def self.parse(monitoring_datagram, source_ip, source_port)
34
34
  unless valid_data?(monitoring_datagram)
35
- ::OnesnooperServer::Log.fatal "[#{self.name}] Dropping invalid monitoring data #{monitoring_datagram.inspect}"
35
+ ::OnesnooperServer::Log.error "[#{self.name}] Dropping invalid monitoring data #{monitoring_datagram.inspect}"
36
36
  return DATAGRAMS.default.new
37
37
  end
38
38
 
@@ -68,7 +68,21 @@ private
68
68
  # @param source_ip [String] IP address to match
69
69
  # @return [Boolean] result
70
70
  def self.valid_peer?(source_ip)
71
- ::OnesnooperServer::Settings.allowed_sources.include? source_ip
71
+ begin
72
+ source_ip = ::IPAddr.new(::Resolv.getaddress(source_ip))
73
+ ::OnesnooperServer::Log.debug "[#{self.name}] Resolved source IP" \
74
+ " address to #{source_ip.inspect}"
75
+ rescue => ex
76
+ ::OnesnooperServer::Log.error "[#{self.name}] Invalid source IP" \
77
+ " address #{source_ip.inspect}, dropping"
78
+ return false
79
+ end
80
+
81
+ ::OnesnooperServer::Settings.allowed_sources.each do |allowed_source|
82
+ return true if ::IPAddr.new(allowed_source).include?(source_ip)
83
+ end
84
+
85
+ false
72
86
  end
73
87
 
74
88
  # Retrieves a list of instances for allowed store backends.
@@ -8,5 +8,5 @@ class OnesnooperServer::Settings < ::Settingslogic
8
8
  source "/etc/onesnooper-server/onesnooper-server.yml" if File.readable?("/etc/onesnooper-server/onesnooper-server.yml")
9
9
  source "#{gem_root}/config/onesnooper-server.yml"
10
10
 
11
- namespace ENV['RAILS_ENV'] ? ENV['RAILS_ENV'] : 'production'
11
+ namespace ENV['RAILS_ENV'].blank? ? 'production' : ENV['RAILS_ENV']
12
12
  end
@@ -1,4 +1,4 @@
1
1
  module OnesnooperServer
2
2
  # Static version information
3
- VERSION = "0.0.1" unless defined?(::OnesnooperServer::VERSION)
3
+ VERSION = "0.0.2" unless defined?(::OnesnooperServer::VERSION)
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onesnooper-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Parak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2015-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -202,6 +202,7 @@ extensions: []
202
202
  extra_rdoc_files: []
203
203
  files:
204
204
  - ".gitignore"
205
+ - ".travis.yml"
205
206
  - Gemfile
206
207
  - LICENSE
207
208
  - README.md