Skip to content

Commit 2504724

Browse files
author
lsanchez-r7
committed
updating the list_interfaces.rb to use the gem
1 parent 94db2dc commit 2504724

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

tools/list_interfaces.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
if RUBY_PLATFORM == "i386-mingw32"
2525
begin
26-
require 'pcaprub'
26+
require 'network_interface'
2727
rescue ::Exception => e
28-
$stderr.puts "Error: pcaprub is not installed..."
28+
$stderr.puts "Error: NetworkInterface is not installed..."
2929
exit
30-
end
30+
end
3131

3232
unless (
3333
NetworkInterface.respond_to?(:interfaces) and
@@ -48,13 +48,13 @@
4848
puts "NAME : " + detail["name"]
4949
puts "DESCRIPTION : " + detail["description"]
5050
puts "GUID : " + detail["guid"]
51-
if addr[Pcap::AF_LINK][0]['addr']
52-
puts "MAC ADDRESSE : #{addr[Pcap::AF_LINK][0]['addr']}"
51+
if addr[NetworkInterface::AF_LINK][0]['addr']
52+
puts "MAC ADDRESSE : #{addr[NetworkInterface::AF_LINK][0]['addr']}"
5353
else
5454
puts "MAC ADDRESSE : NONE"
5555
end
56-
if addr[Pcap::AF_INET][0]['addr'] and addr[Pcap::AF_INET][0]['netmask']
57-
puts "IP ADDRESSE : #{addr[Pcap::AF_INET][0]['addr']}/#{addr[Pcap::AF_INET][0]['netmask']}"
56+
if addr[NetworkInterface::AF_INET][0]['addr'] and addr[NetworkInterface::AF_INET][0]['netmask']
57+
puts "IP ADDRESSE : #{addr[NetworkInterface::AF_INET][0]['addr']}/#{addr[NetworkInterface::AF_INET][0]['netmask']}"
5858
else
5959
puts "IP ADDRESSE : NONE"
6060
end
@@ -69,5 +69,3 @@
6969
$stderr.puts "Error: This script is usefull only on Windows, under other OS just use the built-in commands (ifconfig, ip link show, ...)"
7070
exit
7171
end
72-
73-

0 commit comments

Comments
 (0)