ether_ping 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/bin/ether_ping +14 -4
  3. data/ether_ping.gemspec +1 -1
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -8,8 +8,8 @@ options = {}
8
8
  parser = OptionParser.new do |opts|
9
9
  opts.banner = "Usage: #{$0} [options] destination_mac"
10
10
 
11
- opts.on('-e', '--interface ETH', 'Ethernet interface name, e.g. eth0') do |i|
12
- options[:interface] = i
11
+ opts.on('-e', '--interface ETH', 'Ethernet interface name, e.g. eth0') do |e|
12
+ options[:interface] = e
13
13
  end
14
14
 
15
15
  opts.on('-t', '--type TYPE',
@@ -26,6 +26,14 @@ parser = OptionParser.new do |opts|
26
26
  options[:size] = s.to_i
27
27
  end
28
28
 
29
+ opts.on('-i', '--interval SECONDS', 'Time between successive pings') do |i|
30
+ options[:interval] = i.to_f
31
+ end
32
+
33
+ opts.on('-x', '--timeout SECONDS', 'Time before giving up on a ping') do |x|
34
+ options[:timeout] = x.to_f
35
+ end
36
+
29
37
  opts.on('-h', '--help', 'Display this screen') do
30
38
  puts opts
31
39
  exit
@@ -36,6 +44,8 @@ parser.parse!
36
44
  options[:interface] ||= Ethernet.devices.keys.sort.first
37
45
  options[:ether_type] ||= 0x88B5
38
46
  options[:size] ||= 64 unless options[:data]
47
+ options[:interval] ||= 1
48
+ options[:timeout] ||= 1
39
49
 
40
50
  if ARGV.length < 1
41
51
  puts "Missing destination MAC address"
@@ -53,7 +63,7 @@ client = EtherPing::Client.new options[:interface], options[:ether_type],
53
63
  loop do
54
64
  print "Ping... "
55
65
  STDOUT.flush
56
- result = client.ping options[:size] || options[:data]
66
+ result = client.ping options[:size] || options[:data], options[:timeout]
57
67
  if result
58
68
  if result.kind_of? Numeric
59
69
  puts "#{result * 1000000}us"
@@ -66,5 +76,5 @@ loop do
66
76
  puts "Timed out"
67
77
  end
68
78
  STDOUT.flush
69
- sleep 1
79
+ sleep options[:interval]
70
80
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ether_ping}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Victor Costan}]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ether_ping
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Victor Costan