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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 802bcd728c96f076a536c4adeb98f0497079758f
4
- data.tar.gz: 99422fa325a830dae6ce61597c80c886320bbbfc
3
+ metadata.gz: 70895187b462c2363960525378f2616fb1d25a11
4
+ data.tar.gz: 1a5bf065e8f66a315e703c55ac39b25131b33803
5
5
  SHA512:
6
- metadata.gz: b55f595a75a77f04a92c9cec33abcc01c248b05307ae25851db036c3678add355c5e729ce53a247e872b7b6b454345c287428d8b9133aca78f83cc6d1bc531c5
7
- data.tar.gz: 1aea417879176c639d150c9404de92baee5419316ba8dab6aa433d7f55d2d6f547c3d5b443de4886c08d36187ae2d9b0d6630186697e4ded12e0808b9a91b4fb
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 "Starting watch...", :red
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
@@ -1,4 +1,7 @@
1
1
  module Hooray
2
+ #
3
+ # Socket Port
4
+ #
2
5
  class Port < Struct.new(:number, :protocol, :name)
3
6
  def name
4
7
  @name || Settings.services[number][protocol]
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 -n`.split(/\n/).each do |l|
55
- ip, _hw, mac, _flag, iface = l.split(/\s+/)
56
- # p "#{ip} #{mac} #{iface}"
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
- def my_ips
65
- Socket.ip_address_list.select do |ip|
66
- ip.ipv4_private? && !ip.ipv4_loopback?
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
- def my_lan_ip
71
- IPAddr.new(my_ips.first.ip_address)
72
- end
73
+ def my_lan_ip
74
+ IPAddr.new(my_ips.first.ip_address)
75
+ end
73
76
 
74
- def local_mask
75
- my_lan_ip.mask(NET_MASK)
76
- end
77
+ def local_mask
78
+ my_lan_ip.mask(NET_MASK)
79
+ end
77
80
  end
78
81
  end
79
82
  end
@@ -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
 
@@ -1,3 +1,4 @@
1
+ # Hooray version
1
2
  module Hooray
2
- VERSION = '0.0.5'
3
+ VERSION = '0.0.7'
3
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hooray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Piccinini