macvendors 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CHANGELOG +3 -0
- data/CODE_OF_CONDUCT.md +51 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +66 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/macvendors +5 -0
- data/bin/setup +8 -0
- data/lib/macvendors.rb +68 -0
- data/lib/macvendors/version.rb +3 -0
- data/macvendors.gemspec +22 -0
- data/tests/test.rb +4 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6b154b175a6a1cdee147b9094cf41fd462488071
|
4
|
+
data.tar.gz: 4864a04f2f0b27dd0376c529c1606d9ba0887576
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c58a7ccc5f09d47421e7a815b0d73afb71f1e5d1ca40b27045e9d34097018acc63730d38889798244229c39a07f145e7389d8bf40bdf9ce7acc9463e688ccf6a
|
7
|
+
data.tar.gz: 2dab282827c40c6f44bfb9db158b028a22caff1ae6a8d5a1819aff6fb000984d2f296d86a053c1998d80682c05e05e1150dbbd26389da09de05662103c57cef6
|
data/.gitignore
ADDED
data/CHANGELOG
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
Just be nice.
|
4
|
+
|
5
|
+
As contributors and maintainers of this project, and in the interest of
|
6
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
7
|
+
contribute through reporting issues, posting feature requests, updating
|
8
|
+
documentation, submitting pull requests or patches, and other activities.
|
9
|
+
|
10
|
+
We are committed to making participation in this project a harassment-free
|
11
|
+
experience for everyone, regardless of level of experience, gender, gender
|
12
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
13
|
+
body size, race, ethnicity, age, religion, or nationality.
|
14
|
+
|
15
|
+
Examples of unacceptable behavior by participants include:
|
16
|
+
|
17
|
+
* The use of sexualized language or imagery
|
18
|
+
* Personal attacks
|
19
|
+
* Trolling or insulting/derogatory comments
|
20
|
+
* Public or private harassment
|
21
|
+
* Publishing other's private information, such as physical or electronic
|
22
|
+
addresses, without explicit permission
|
23
|
+
* Other unethical or unprofessional conduct
|
24
|
+
|
25
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
26
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
27
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
28
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
29
|
+
threatening, offensive, or harmful.
|
30
|
+
|
31
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
32
|
+
fairly and consistently applying these principles to every aspect of managing
|
33
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
34
|
+
Conduct may be permanently removed from the project team.
|
35
|
+
|
36
|
+
This code of conduct applies both within project spaces and in public spaces
|
37
|
+
when an individual is representing the project or its community.
|
38
|
+
|
39
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
40
|
+
reported by contacting a project maintainer at ytbryan@gmail.com. All
|
41
|
+
complaints will be reviewed and investigated and will result in a response that
|
42
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
43
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
44
|
+
incident.
|
45
|
+
|
46
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
47
|
+
version 1.3.0, available at
|
48
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
49
|
+
|
50
|
+
[homepage]: http://contributor-covenant.org
|
51
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 - 2999 Bryan Lim (@ytbryan)
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Macvendors
|
2
|
+
|
3
|
+
A command line tool to find vendor name from a mac address.
|
4
|
+
|
5
|
+
No need for an external api. You can also extend it in your ruby code.
|
6
|
+
|
7
|
+
# How mac address works?
|
8
|
+
|
9
|
+
Source: [Hastur](http://superuser.com/users/257269/hastur) http://superuser.com/a/1093431
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'macvendors'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install macvendors
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
|
30
|
+
### Command line
|
31
|
+
|
32
|
+
```
|
33
|
+
macvendors find 98:e0:d9:a5:61:eb
|
34
|
+
> Apple, Inc.
|
35
|
+
|
36
|
+
macvendors update
|
37
|
+
> oui.csv removed.
|
38
|
+
> downloaded oui.csv
|
39
|
+
```
|
40
|
+
|
41
|
+
### Ruby
|
42
|
+
|
43
|
+
```
|
44
|
+
require 'macvendors'
|
45
|
+
|
46
|
+
puts MacVendors.find("98:e0:d9:a5:61:eb")
|
47
|
+
|
48
|
+
MacVendors.update() //update the oui file
|
49
|
+
|
50
|
+
```
|
51
|
+
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
56
|
+
|
57
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/macvendors. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
62
|
+
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "macvendors"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/macvendors
ADDED
data/bin/setup
ADDED
data/lib/macvendors.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require "macvendors/version"
|
2
|
+
require 'digest/md5'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'thor'
|
5
|
+
require 'csv'
|
6
|
+
|
7
|
+
module MacVendors
|
8
|
+
class Base < Thor
|
9
|
+
check_unknown_options!
|
10
|
+
package_name 'macvendors'
|
11
|
+
default_task :help
|
12
|
+
|
13
|
+
desc :find, "find the vendor for this mac address"
|
14
|
+
def find value
|
15
|
+
MacVendors.find(value)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc :update, "update/replace the mac address csv from ieee"
|
19
|
+
def update
|
20
|
+
MacVendors.update()
|
21
|
+
end
|
22
|
+
|
23
|
+
desc :install, "install your first oui.csv"
|
24
|
+
def install
|
25
|
+
MacVendors.download()
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def self.update
|
33
|
+
path_to_file = "/Users/ytbryan/.macvendors/oui.csv"
|
34
|
+
File.delete(path_to_file) if File.exist?(path_to_file)
|
35
|
+
puts "oui.csv removed."
|
36
|
+
MacVendors.download()
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def self.download
|
41
|
+
Dir.mkdir ".macvendors" if Dir[".macvendors"] == nil
|
42
|
+
open("/Users/ytbryan/.macvendors/oui.csv", 'wb') do |file|
|
43
|
+
file << open('http://standards-oui.ieee.org/oui/oui.csv').read
|
44
|
+
end
|
45
|
+
puts "downloaded oui.csv"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.search value
|
49
|
+
path = "/Users/ytbryan/.macvendors/oui.csv"
|
50
|
+
answer = CSV.read(path,:headers=> true, :encoding => "ISO8859-1:utf-8") #TODO: is this a data
|
51
|
+
column = answer["Assignment"]
|
52
|
+
name = answer["Organization Name"]
|
53
|
+
hash = Hash[column.map.with_index.to_a]
|
54
|
+
if hash[value] != nil
|
55
|
+
puts name[hash[value]]
|
56
|
+
else
|
57
|
+
puts "something went wrong."
|
58
|
+
end
|
59
|
+
return answer
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.find string
|
63
|
+
string = string.gsub(":", "")
|
64
|
+
string = string.gsub("-", "")
|
65
|
+
return search(string[0..5].upcase)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/macvendors.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'macvendors/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "macvendors"
|
8
|
+
spec.version = MacVendors::VERSION
|
9
|
+
spec.authors = ["Bryan Lim"]
|
10
|
+
spec.email = ["ytbryan@gmail.com"]
|
11
|
+
spec.summary = %q{find vendor names from mac addresses}
|
12
|
+
spec.description = %q{find vendor names from mac addresses}
|
13
|
+
spec.homepage = "https://github.com/ytbryan/macvendors"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.executables = ["macvendors"]
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
data/tests/test.rb
ADDED
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: macvendors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryan Lim
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-17 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: find vendor names from mac addresses
|
42
|
+
email:
|
43
|
+
- ytbryan@gmail.com
|
44
|
+
executables:
|
45
|
+
- macvendors
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- CHANGELOG
|
51
|
+
- CODE_OF_CONDUCT.md
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/console
|
57
|
+
- bin/macvendors
|
58
|
+
- bin/setup
|
59
|
+
- lib/macvendors.rb
|
60
|
+
- lib/macvendors/version.rb
|
61
|
+
- macvendors.gemspec
|
62
|
+
- tests/test.rb
|
63
|
+
homepage: https://github.com/ytbryan/macvendors
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.5.1
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: find vendor names from mac addresses
|
87
|
+
test_files: []
|