Skip to content

Commit 2881257

Browse files
authored
Merge pull request #254 from agrare/add_network_interface_loopback
Add network interface loopback
2 parents 016276e + 2ea00f4 commit 2881257

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/linux_admin/network_interface.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def self.new(*args)
4242
end
4343

4444
# @return [String] the interface for networking operations
45-
attr_reader :interface
45+
attr_reader :interface, :link_type
4646

4747
# @param interface [String] Name of the network interface to manage
4848
def initialize(interface)
@@ -61,7 +61,8 @@ def reload
6161
return false
6262
end
6363

64-
addr_info = ip_output["addr_info"]
64+
@link_type = ip_output["link_type"]
65+
addr_info = ip_output["addr_info"]
6566

6667
parse_ip4(addr_info)
6768
parse_ip6(addr_info, "global")
@@ -75,6 +76,10 @@ def reload
7576
true
7677
end
7778

79+
def loopback?
80+
@link_type == "loopback"
81+
end
82+
7883
# Retrieve the IPv4 address assigned to the interface
7984
#
8085
# @return [String] IPv4 address for the managed interface

0 commit comments

Comments
 (0)