chiark / gitweb /
changelog: start 0.6.8
[secnet.git] / polypath-interface-monitor-linux
index bce8436907f7be089ffda7a8582b12461084f647..3ecae59c6f437df3df6f60453882efbbe3516e72 100755 (executable)
@@ -1,4 +1,22 @@
 #!/usr/bin/perl -w
+
+# This file is part of secnet.
+# See README for full list of copyright holders.
+#
+# secnet is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# secnet is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# version 3 along with secnet; if not, see
+# https://www.gnu.org/licenses/gpl.html.
+
 use strict;
 use IO::Handle;
 
@@ -61,7 +79,19 @@ for (;;) {
            while (<$addrh>) {
                print DEBUG "#$_";
                if (m{^\d+\:\s*(\S+)\s+$afstr\s+([0-9a-z.:]+)(?:/\d+)?\s}) {
+                   my $rhs=$'; #';
                    my $outline = "$ip $1 $2";
+                   # "ip -o addr show" has a ridiculous output format.  In
+                   # particular, it mixes output keywords which introduce
+                   # values with ones which don't, and there seems to be
+                   # no way to tell without knowing all the possible
+                   # keywords.  We hope that before the \ there is nothing
+                   # which contains arbitrary text (specifically, which
+                   # might be `tentative' other than to specify IPv6
+                   # tentativeness).  We have to do this for IPv6 only
+                   # because in the IPv4 output, the interface name
+                   # appears here!
+                   next if $ip==6 && $rhs=~m{[^\\]* tentative\s};
                    $reported{$outline} .= "y";
                } else {
                    chomp;