ouisearch 0.0.2
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +15 -0
- data/Rakefile +4 -0
- data/bin/ouisearch +30 -0
- data/lib/ouisearch/version.rb +3 -0
- data/lib/ouisearch.rb +105 -0
- data/ouisearch.gemspec +23 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 082380fe8427d6a213e97ed20d1ebb19da0b63d3
|
4
|
+
data.tar.gz: 2c597e815d80bd5ada201006236974eeeb8d8ff5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc454a2375da9770645ee0f0cbae48cb1d7b2116e549ba8c7ea8178bc3a996bea82b3431d2ebf7c720220fbecd58d6680a3f56308dae2ebaba8c306ab0f23ad5
|
7
|
+
data.tar.gz: 8c59ed0379b8467c28771f95536508c79392ff3dab913cb965b462359a6e5bd4a3f01908a88f545d5eac5b0b19e38ab07661abf5f52a4ae7d57840a20d4ed434
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 naoya Kaneko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 enukane
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Ouisearch
|
2
|
+
IEEE OUI registry search tools
|
3
|
+
|
4
|
+
* simple command to translate OUI into vendor name
|
5
|
+
* stores OUI list into $HOME/.oui for local search without internet access
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```
|
10
|
+
ouisearch [-r] [-d] XX:XX:XX
|
11
|
+
```
|
12
|
+
|
13
|
+
* -r : force reload OUI list cache (requires internet access)
|
14
|
+
* -d : debug output
|
15
|
+
|
data/Rakefile
ADDED
data/bin/ouisearch
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
require 'ouisearch'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
def usage
|
8
|
+
print "ouisearch [-d] [-r] XX:XX:XX\n"
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
|
12
|
+
opt = OptionParser.new
|
13
|
+
OPTS={}
|
14
|
+
opt.on('-r') {|v| OPTS[:reload] = true }
|
15
|
+
opt.on('-d') {|v| OPTS[:debug] = true }
|
16
|
+
opt.on('-h') {|v| usage }
|
17
|
+
opt.parse!(ARGV)
|
18
|
+
|
19
|
+
addr = ARGV.shift
|
20
|
+
usage if addr == nil
|
21
|
+
|
22
|
+
begin
|
23
|
+
ouisearch = OuiSearch.new(OPTS)
|
24
|
+
rescue => e
|
25
|
+
print e.message
|
26
|
+
exit 1
|
27
|
+
end
|
28
|
+
print "#{ouisearch.execute(addr)}\n"
|
29
|
+
|
30
|
+
exit 0
|
data/lib/ouisearch.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'ouisearch/version'
|
4
|
+
require 'optparse'
|
5
|
+
require 'faraday'
|
6
|
+
|
7
|
+
class OuiSearch
|
8
|
+
URL="www.ieee.org/netstorage/standards/oui.txt"
|
9
|
+
URLHOST="http://www.ieee.org"
|
10
|
+
URLPATH="/netstorage/standards/oui.txt"
|
11
|
+
CACHE="#{ENV['HOME']}/.oui"
|
12
|
+
REG=/^\s+(..)-(..)-(..)\s+\(hex\)\s+(.+)$/
|
13
|
+
|
14
|
+
def initialize args={}
|
15
|
+
@reload = args[:reload] || false
|
16
|
+
@debug = args[:debug] || false
|
17
|
+
@ouis = nil
|
18
|
+
fetch_cache
|
19
|
+
load_cache
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute oui
|
23
|
+
vendor = @ouis[oui.upcase]
|
24
|
+
if vendor
|
25
|
+
return vendor.strip
|
26
|
+
else
|
27
|
+
return "<UNKNOWN>"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def fetch_cache
|
32
|
+
if File.exists?(CACHE) and @reload == false
|
33
|
+
# nothing to do
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
37
|
+
if @reload
|
38
|
+
dprint "force cache update ($HOME/.oui) ...\n"
|
39
|
+
else
|
40
|
+
dprint "no cache ($HOME/.oui) found. creating cache ...\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
File.open(CACHE, "w") do |f|
|
44
|
+
@ouis = http_get_ouis()
|
45
|
+
f.write(Marshal.dump(@ouis))
|
46
|
+
end
|
47
|
+
|
48
|
+
dprint "cache created (#{@ouis.length} entries)\n"
|
49
|
+
end
|
50
|
+
|
51
|
+
def http_get_ouis
|
52
|
+
ouis = {}
|
53
|
+
conn = Faraday.new(:url => URLHOST)
|
54
|
+
response = conn.get(URLPATH)
|
55
|
+
raise "failed to fetch oui" if response.status != 200
|
56
|
+
response.body.split("\n").each do |line|
|
57
|
+
match = line.match(REG)
|
58
|
+
next unless match
|
59
|
+
oui = match[1] + ":" + match[2] + ":" + match[3]
|
60
|
+
vendor = match[4]
|
61
|
+
ouis[oui.upcase] = vendor
|
62
|
+
end
|
63
|
+
return ouis
|
64
|
+
end
|
65
|
+
|
66
|
+
def load_cache
|
67
|
+
return @ouis if @ouis # already fetched
|
68
|
+
File.open(CACHE, "r") do |f|
|
69
|
+
@ouis = Marshal.load(f.read)
|
70
|
+
end
|
71
|
+
dprint "cache reloading done (#{@ouis.length} entries)\n"
|
72
|
+
end
|
73
|
+
|
74
|
+
def dprint str
|
75
|
+
return nil unless @debug
|
76
|
+
print "#{str}\n"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def usage
|
81
|
+
print "ouisearch [-d] [-r] XX:XX:XX\n"
|
82
|
+
exit 1
|
83
|
+
end
|
84
|
+
|
85
|
+
if __FILE__ == $0
|
86
|
+
opt = OptionParser.new
|
87
|
+
OPTS={}
|
88
|
+
opt.on('-r') {|v| OPTS[:reload] = true }
|
89
|
+
opt.on('-d') {|v| OPTS[:debug] = true }
|
90
|
+
opt.on('-h') {|v| usage }
|
91
|
+
opt.parse!(ARGV)
|
92
|
+
|
93
|
+
addr = ARGV.shift
|
94
|
+
usage if addr == nil
|
95
|
+
|
96
|
+
begin
|
97
|
+
ouisearch = OuiSearch.new(OPTS)
|
98
|
+
rescue => e
|
99
|
+
print e.message
|
100
|
+
exit 1
|
101
|
+
end
|
102
|
+
print "#{ouisearch.execute(addr)}\n"
|
103
|
+
|
104
|
+
exit 0
|
105
|
+
end
|
data/ouisearch.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "ouisearch"
|
5
|
+
spec.version = "0.0.2"
|
6
|
+
spec.authors = ["Naoya kaneko"]
|
7
|
+
spec.email = ["enukane@glenda9.org"]
|
8
|
+
spec.summary = %q{Search for IEEE OUI list with given OUI (with local cache)}
|
9
|
+
spec.description = spec.summary
|
10
|
+
spec.homepage = "https://github.com/enukane/ouisearch"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
spec.has_rdoc = false
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
|
22
|
+
spec.add_dependency 'faraday'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ouisearch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Naoya kaneko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Search for IEEE OUI list with given OUI (with local cache)
|
56
|
+
email:
|
57
|
+
- enukane@glenda9.org
|
58
|
+
executables:
|
59
|
+
- ouisearch
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/ouisearch
|
70
|
+
- lib/ouisearch.rb
|
71
|
+
- lib/ouisearch/version.rb
|
72
|
+
- ouisearch.gemspec
|
73
|
+
homepage: https://github.com/enukane/ouisearch
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.2
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Search for IEEE OUI list with given OUI (with local cache)
|
97
|
+
test_files: []
|