-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn into a Gem and complete the PDU5 spec
Added a gemspec so it can be used by Bundler straight out of git. Switched from jewler to bundler for simplicity Fleshed out the Netflow v5 packet spec
- Loading branch information
Showing
13 changed files
with
123 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm --create 1.9.2@netflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
source "http://rubygems.org" | ||
# Add dependencies required to use your gem here. | ||
# Example: | ||
# gem "activesupport", ">= 2.3.5" | ||
source :rubygems | ||
|
||
# Add dependencies to develop your gem here. | ||
# Include everything needed to run rake, tests, features, etc. | ||
group :development do | ||
gem "rspec", "~> 2.3.0" | ||
gem "bundler", "~> 1.0.0" | ||
gem "jeweler", "~> 1.5.2" | ||
gem "rcov", ">= 0" | ||
end | ||
# Specify your gem's dependencies in netflow.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
bindata (1.4.1) | ||
diff-lcs (1.1.2) | ||
eventmachine (0.12.10) | ||
git (1.2.5) | ||
jeweler (1.5.2) | ||
bundler (~> 1.0.0) | ||
git (>= 1.2.5) | ||
rake | ||
rake (0.9.2) | ||
rcov (0.9.9) | ||
rspec (2.3.0) | ||
rspec-core (~> 2.3.0) | ||
rspec-expectations (~> 2.3.0) | ||
rspec-mocks (~> 2.3.0) | ||
rspec-core (2.3.1) | ||
rspec-expectations (2.3.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.3.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bindata | ||
bundler (~> 1.0.0) | ||
eventmachine | ||
jeweler (~> 1.5.2) | ||
rcov | ||
rspec (~> 2.3.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1 @@ | ||
require 'rubygems' | ||
require 'bundler' | ||
begin | ||
Bundler.setup(:default, :development) | ||
rescue Bundler::BundlerError => e | ||
$stderr.puts e.message | ||
$stderr.puts "Run `bundle install` to install missing gems" | ||
exit e.status_code | ||
end | ||
require 'rake' | ||
|
||
require 'jeweler' | ||
Jeweler::Tasks.new do |gem| | ||
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options | ||
gem.name = "netflow" | ||
gem.homepage = "http://github.com/seeingidog/netflow" | ||
gem.license = "MIT" | ||
gem.summary = %Q{Ruby Netflow collector based on EventMachine} | ||
gem.description = %Q{Listens and parses netflow datagrams sent from network devices. More information on Netflow format: http://tools.ietf.org/html/rfc3954} | ||
gem.email = "ian@ruby-code.com" | ||
gem.authors = ["seeingidog"] | ||
gem.add_runtime_dependency 'bindata' | ||
gem.add_runtime_dependency 'eventmachine' | ||
end | ||
Jeweler::RubygemsDotOrgTasks.new | ||
|
||
require 'rspec/core' | ||
require 'rspec/core/rake_task' | ||
RSpec::Core::RakeTask.new(:spec) do |spec| | ||
spec.pattern = FileList['spec/**/*_spec.rb'] | ||
end | ||
|
||
RSpec::Core::RakeTask.new(:rcov) do |spec| | ||
spec.pattern = 'spec/**/*_spec.rb' | ||
spec.rcov = true | ||
end | ||
|
||
task :default => :spec | ||
|
||
require 'rake/rdoctask' | ||
Rake::RDocTask.new do |rdoc| | ||
version = File.exist?('VERSION') ? File.read('VERSION') : "" | ||
|
||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = "netflow #{version}" | ||
rdoc.rdoc_files.include('README*') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
require 'bundler/gem_tasks' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), '..','lib','netflow')) | ||
#!/usr/bin/env ruby | ||
|
||
puts "Help" unless ARGV[0] != nil | ||
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..','lib')) | ||
|
||
ARGV.each do |arg| | ||
puts "Arguement #{arg}" | ||
end | ||
require 'netflow/collector' | ||
|
||
Netflow.start_collector | ||
NetflowCollector.start_collector |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
require 'bindata' | ||
require 'eventmachine' | ||
|
||
require File.expand_path(File.join(File.dirname(__FILE__), 'netflow','models','binary_models')) | ||
require File.expand_path(File.join(File.dirname(__FILE__), 'netflow','parsers','parsers')) | ||
require File.expand_path(File.join(File.dirname(__FILE__), 'netflow','storage','storage')) | ||
require File.expand_path(File.join(File.dirname(__FILE__), 'netflow','collector')) | ||
require 'netflow/version' | ||
|
||
require 'netflow/models/binary_models' | ||
require 'netflow/parsers/parsers' | ||
require 'netflow/storage/storage' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
class Netflow | ||
class Netflow | ||
def self.parse_packet(data) | ||
begin | ||
header = Header.read(data) | ||
if header.version == 9 | ||
flowset = Netflow9PDU.read(data) | ||
puts flowset.inspect | ||
elsif header.version == 5 | ||
puts header.inspect | ||
#read data | ||
|
||
flowset = Netflow5PDU.read(data) | ||
else | ||
raise "Unsupported Netflow version" | ||
end | ||
rescue | ||
raise "Error reading header." | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
class Netflow | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Netflow | ||
VERSION = "0.0.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "netflow/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "netflow" | ||
s.version = Netflow::VERSION | ||
s.authors = ["seeingidog"] | ||
s.email = ["ian@ruby-code.com"] | ||
s.homepage = "http://github.com/seeingidog/netflow" | ||
s.license = "MIT" | ||
s.summary = %q{Ruby Netflow collector based on EventMachine} | ||
s.description = %q{Listens and parses netflow datagrams sent from network devices. More information on Netflow format: http://tools.ietf.org/html/rfc3954} | ||
|
||
s.rubyforge_project = "netflow" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
|
||
s.add_runtime_dependency 'bindata' | ||
s.add_runtime_dependency 'eventmachine' | ||
end |