diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | lib/network/tools.pm | 11 |
2 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,5 @@ +- Make get_routes() more robust when parsing /proc/net/route + 0.93: - Make draknetcenter.desktop XDG compliant - Move autostart desktop files to /etc/xdg/autostart diff --git a/lib/network/tools.pm b/lib/network/tools.pm index 0a1d840..9636450 100644 --- a/lib/network/tools.pm +++ b/lib/network/tools.pm @@ -265,7 +265,16 @@ sub get_routes() { my %routes; foreach (cat_("/proc/net/route")) { if (/^(\S+)\s+([0-9A-F]+)\s+([0-9A-F]+)\s+[0-9A-F]+\s+\d+\s+\d+\s+(\d+)\s+([0-9A-F]+)/) { - if (defined $3) { $routes{$1}{gateway} = hex($3) ? host_hex_to_dotted($3) : $routes{$1}{network} } + next if (defined $routes{$1}{has_gateway}); + + if (defined $3) { + if (hex($3)) { + $routes{$1}{gateway} = host_hex_to_dotted($3); + $routes{$1}{has_gateway} = "yes"; + } else { + $routes{$1}{gateway} = $routes{$1}{network}; + } + } if (defined $2) { $routes{$1}{network} = host_hex_to_dotted($2) } if (defined $4) { $routes{$1}{metric} = $4 } } |