hooray 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hooray/cli.rb +3 -3
- data/lib/hooray/port.rb +3 -0
- data/lib/hooray/seek.rb +17 -14
- data/lib/hooray/settings.rb +5 -1
- data/lib/hooray/version.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70895187b462c2363960525378f2616fb1d25a11
|
4
|
+
data.tar.gz: 1a5bf065e8f66a315e703c55ac39b25131b33803
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f76544c3f668672549a984f31b831fa9cf116e23bb9a3e38f419cb3903750fafdf4d698be69dd4dec5a793db800c709625ae706e9c592ac86f4495801293f75f
|
7
|
+
data.tar.gz: 1323add01b3372288b79e7df6fe3cc32f327d46ec0470eca9b24f601e260203f11ae9e5609a8b59a94abc36ea7fee44e3a11d7cfc46c2eb663e1353f88601371
|
data/lib/hooray/cli.rb
CHANGED
@@ -49,7 +49,7 @@ module Hooray
|
|
49
49
|
LONG
|
50
50
|
def watch
|
51
51
|
print_table old_seek = Seek.new(options[:network]).nodes
|
52
|
-
pa
|
52
|
+
pa 'Starting watch...', :red
|
53
53
|
loop do
|
54
54
|
sleep 5
|
55
55
|
new_seek = Seek.new(options[:network]).nodes
|
@@ -94,7 +94,7 @@ module Hooray
|
|
94
94
|
|
95
95
|
def print_table(nodes)
|
96
96
|
tp nodes, :name, :ip, :mac
|
97
|
-
puts
|
97
|
+
puts '---'
|
98
98
|
took = (Time.now - @start).round(2)
|
99
99
|
pa "#{nodes.count} devices @ #{Time.now} #{took}s", '#777', :bold
|
100
100
|
end
|
@@ -105,7 +105,7 @@ module Hooray
|
|
105
105
|
puts "Do you want to `#{params.first}` to a device?"
|
106
106
|
puts "Use #{ARGV.first} #{params.first} <device name>"
|
107
107
|
when 2 then
|
108
|
-
command, device = *params
|
108
|
+
command, *device = *params
|
109
109
|
system "#{command} "
|
110
110
|
else super
|
111
111
|
end
|
data/lib/hooray/port.rb
CHANGED
data/lib/hooray/seek.rb
CHANGED
@@ -48,32 +48,35 @@ module Hooray
|
|
48
48
|
scan
|
49
49
|
end
|
50
50
|
|
51
|
+
#
|
52
|
+
# ARP Table reader
|
53
|
+
#
|
51
54
|
def arp_table
|
52
55
|
return @arp_table if @arp_table
|
53
56
|
@arp_table ||= {}
|
54
|
-
`arp -
|
55
|
-
ip,
|
56
|
-
|
57
|
+
`arp -na`.split(/\n/).each do |l|
|
58
|
+
_q, ip, _at, mac, *iface = l.split(/\s+/)
|
59
|
+
next unless mac =~ /:\w{2}:/
|
60
|
+
ip = ip[1..-2] # (ip) -> ip
|
57
61
|
@arp_table.merge!(ip => mac) if iface
|
58
62
|
end
|
59
63
|
@arp_table
|
60
64
|
end
|
61
65
|
|
62
66
|
class << self
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
+
def my_ips
|
68
|
+
Socket.ip_address_list.select do |ip|
|
69
|
+
ip.ipv4_private? && !ip.ipv4_loopback?
|
70
|
+
end
|
67
71
|
end
|
68
|
-
end
|
69
72
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
+
def my_lan_ip
|
74
|
+
IPAddr.new(my_ips.first.ip_address)
|
75
|
+
end
|
73
76
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
+
def local_mask
|
78
|
+
my_lan_ip.mask(NET_MASK)
|
79
|
+
end
|
77
80
|
end
|
78
81
|
end
|
79
82
|
end
|
data/lib/hooray/settings.rb
CHANGED
@@ -17,6 +17,10 @@ module Hooray
|
|
17
17
|
@all = YAML.load_file(CONFIG_DIR + 'settings.yml')
|
18
18
|
@services = YAML.load_file(CONFIG_DIR + 'services.yml')
|
19
19
|
@devices = YAML.load_file(CONFIG_DIR + 'devices.yml')
|
20
|
+
read_mac_prefixes
|
21
|
+
end
|
22
|
+
|
23
|
+
def read_mac_prefixes
|
20
24
|
@macs = {}
|
21
25
|
File.read(CONFIG_DIR + 'nmap-mac-prefixes').each_line do |line|
|
22
26
|
next if line =~ /^\s*#/
|
@@ -39,7 +43,7 @@ module Hooray
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def family(mac)
|
42
|
-
prefix = mac.to_s.gsub(':', '')[0,6].upcase
|
46
|
+
prefix = mac.to_s.gsub(':', '')[0, 6].upcase
|
43
47
|
macs[prefix]
|
44
48
|
end
|
45
49
|
|
data/lib/hooray/version.rb
CHANGED