lib/net/ip/route/collection.rb in net-ip-0.0.6 vs lib/net/ip/route/collection.rb in net-ip-0.0.7

- old
+ new

@@ -5,11 +5,11 @@ module IP class Route class Collection include Enumerable - def initialize(table = "main") + def initialize(table) @table = table end # Enumerate all routes # @yield {Route} @@ -36,21 +36,21 @@ # Net::IP::Route.update_gateways([gateway]) # @param gateways {Array<Route>} List of default gateways to use. # @return {void} def update_gateways(gateways) params = gateways.collect {|gateway| "nexthop " + gateway.to_params} - result = `ip route replace default #{params.join(" ")}` + result = `ip route replace default table #{@table} #{params.join(" ")}` raise result unless $?.success? end # Add a route to the routing table # @example Create a route to the 10.0.0.0/8 network # route = Net::IP::Route.new(:prefix => '10.0.0.0/8', :dev => 'eth0') # Net::IP::Route.add_route(route) # @param route {Route} Route to add to the table. # @return {void} def add(route) - result = `ip route add #{route.to_params}` + result = `ip route add table #{@table} #{route.to_params}` raise result unless $?.success? end # Flush the routing table based on a selector # @example Flush the routing table cache