louis 2.0.6 → 2.0.7
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 +4 -4
- data/.travis.yml +0 -2
- data/lib/louis.rb +5 -7
- data/lib/louis/version.rb +1 -1
- data/spec/louis_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7090e2ccc5dc371c32ba14b4f1a614493b751f30
|
4
|
+
data.tar.gz: 4beb1e00fe0a15adddc8a3b81a15f9464c8a0d5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 757c160bb189fecddf2b7a6355afb947abe2380b5d3ae63bdca8b82442ee88264c116d516ef841fc6920379429d2b1d2fa00295860888d1efec4f857f148b92d
|
7
|
+
data.tar.gz: 47503685ccdf6cba569d9dc27a8561dbeb0c92e7a02417bbcfd3a808ec3487758f542dd2b47fda5d9594d69e4c13d059e2f79a1e317f49b3f05a9822e8eb6465
|
data/.travis.yml
CHANGED
data/lib/louis.rb
CHANGED
@@ -14,16 +14,14 @@ module Louis
|
|
14
14
|
|
15
15
|
# Loads the lookup table, parsing out the uncommented non-blank lines into
|
16
16
|
# objects we can compare MACs against to find their vendor.
|
17
|
-
|
18
|
-
@lookup_table ||= JSON.parse(File.read(Louis::PARSED_DATA_FILE))
|
19
|
-
end
|
17
|
+
LOOKUP_TABLE = JSON.parse(File.read(Louis::PARSED_DATA_FILE))
|
20
18
|
|
21
19
|
# Collect the recorded mask and order it appropriately from most specific to
|
22
20
|
# least.
|
23
21
|
#
|
24
22
|
# @param [Array<Fixnum>]
|
25
23
|
def self.mask_keys
|
26
|
-
@mask_keys ||=
|
24
|
+
@mask_keys ||= LOOKUP_TABLE.keys.map(&:to_i).sort.reverse
|
27
25
|
end
|
28
26
|
|
29
27
|
# Returns the name of the vendor that has the most specific prefix
|
@@ -47,11 +45,11 @@ module Louis
|
|
47
45
|
end
|
48
46
|
|
49
47
|
def self.search_table(encoded_mac)
|
50
|
-
|
48
|
+
mask_keys.each{|mask|
|
49
|
+
table = LOOKUP_TABLE[mask.to_s]
|
51
50
|
prefix = (encoded_mac & calculate_mask(nil, mask)).to_s
|
52
51
|
return table[prefix] if table.include?(prefix)
|
53
|
-
|
54
|
-
|
52
|
+
}
|
55
53
|
nil
|
56
54
|
end
|
57
55
|
end
|
data/lib/louis/version.rb
CHANGED
data/spec/louis_spec.rb
CHANGED
@@ -33,6 +33,9 @@ RSpec.describe Louis do
|
|
33
33
|
let(:unknown_mac) { 'c5:00:00:00:00:00' }
|
34
34
|
let(:local_mac) { '3e:97:0e' }
|
35
35
|
let(:multicast_mac) { '3d:97:0e' }
|
36
|
+
let(:multi_match_mac) { 'E4:95:6E:40:00:00'}
|
37
|
+
let(:most_specific_match) { 'Guang Lian Zhi Tong Technology Limited'}
|
38
|
+
let(:least_specific_match) { 'IEEE Registration Authority'}
|
36
39
|
|
37
40
|
it 'should return a hash' do
|
38
41
|
expect(Louis.lookup(base_mac)).to be_a(Hash)
|
@@ -73,6 +76,11 @@ RSpec.describe Louis do
|
|
73
76
|
it 'should return "Unknown" as the long vendor string for unknown MAC prefixes' do
|
74
77
|
expect(Louis.lookup(unknown_mac)['long_vendor']).to eq('Unknown')
|
75
78
|
end
|
79
|
+
|
80
|
+
it 'should return the most specific vendor match for MAC prefixes that match multiple mask keys' do
|
81
|
+
expect(Louis.lookup(multi_match_mac)['long_vendor']).to_not eq(least_specific_match)
|
82
|
+
expect(Louis.lookup(multi_match_mac)['long_vendor']).to eq(most_specific_match)
|
83
|
+
end
|
76
84
|
end
|
77
85
|
|
78
86
|
# For future reference, these may change and are depedent on the
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: louis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stelfox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|