aaalex-ruby-ifconfig 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +5 -2
- data/lib/ifconfig.rb +4 -4
- data/lib/ifconfig/common/interface_types.rb +11 -0
- data/lib/ifconfig/linux/ifconfig.rb +1 -1
- metadata +1 -1
data/Changelog
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
Version 1.2.3
|
2
|
+
- added addrs_with_mask method in NetworkAdapter (Alex Peuchert)
|
3
|
+
|
1
4
|
Version 1.2.2
|
2
|
-
- increase of build number for GitHub to create GEM
|
5
|
+
- increase of build number for GitHub to create GEM (Alex Peuchert)
|
3
6
|
|
4
7
|
Version 1.2.1
|
5
8
|
- import into GitHub (Alex Peuchert)
|
6
|
-
- added .gemspec for automatic GEM creation
|
9
|
+
- added .gemspec for automatic GEM creation (Alex Peuchert)
|
7
10
|
|
8
11
|
Version 1.2
|
9
12
|
- All IP addresses (v4 and v6) are ipaddr objects now.
|
data/lib/ifconfig.rb
CHANGED
@@ -14,13 +14,13 @@
|
|
14
14
|
#
|
15
15
|
# cfg = IfconfigWrapper.new.parse # parses the output of ifconfig
|
16
16
|
#
|
17
|
-
# cfg.interfaces
|
17
|
+
# cfg.interfaces # returns list of interfaces
|
18
18
|
#
|
19
|
-
# cfg[eth0].addresses('inet') # returns ipv4 address of eth0
|
19
|
+
# cfg['eth0'].addresses('inet') # returns ipv4 address of eth0
|
20
20
|
#
|
21
|
-
# cfg.
|
21
|
+
# cfg.addresses('inet') # returns list of all ipv4 addresses
|
22
22
|
#
|
23
|
-
# cfg[eth0].status # returns true if interface is up
|
23
|
+
# cfg['eth0'].status # returns true if interface is up
|
24
24
|
#
|
25
25
|
# cfg.each { block } # run a block on each interface object
|
26
26
|
|
@@ -76,6 +76,17 @@ class NetworkAdapter
|
|
76
76
|
return types
|
77
77
|
end
|
78
78
|
|
79
|
+
# returns array of arrays
|
80
|
+
# [ [address , mask ] ]
|
81
|
+
#
|
82
|
+
def addrs_with_mask
|
83
|
+
addrs = []
|
84
|
+
@networks.each_value { |network|
|
85
|
+
addrs.push([network.addr.to_s,network.mask])
|
86
|
+
}
|
87
|
+
return addrs
|
88
|
+
end
|
89
|
+
|
79
90
|
def has_addr?(addr)
|
80
91
|
return self.addresses.include?(addr)
|
81
92
|
end
|
@@ -13,7 +13,7 @@ class Ifconfig
|
|
13
13
|
def initialize(input=nil,verbose=nil)
|
14
14
|
if input.nil?
|
15
15
|
cmd = IO.popen('which ifconfig'){ |f| f.readlines[0] }
|
16
|
-
|
16
|
+
raise RuntimeError.new("ifconfig not in PATH") unless !cmd.nil?
|
17
17
|
@ifconfig = IO.popen("/sbin/ifconfig -a"){ |f| f.readlines.join }
|
18
18
|
else
|
19
19
|
@ifconfig = input
|