]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/connections.cgi
Merge remote-tracking branch 'origin/next' into thirteen
[people/teissler/ipfire-2.x.git] / html / cgi-bin / connections.cgi
index 54089d0bbc6ebd6b684957a07ea8f46dbbf3a03e..1edf3e5d437ed7f4237de3b33a045232fd9f77d4 100644 (file)
@@ -32,6 +32,8 @@ require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
+my $colour_multicast = "#A0A0A0";
+
 &Header::showhttpheaders();
 
 my @network=();
@@ -131,6 +133,11 @@ if ($netsettings{'BLUE_DEV'}) {
        }
 }
 
+# Add Orange Firewall Interface
+push(@network, $netsettings{'ORANGE_ADDRESS'});
+push(@masklen, "255.255.255.255" );
+push(@colour, ${Header::colourfw} );
+
 # Add Orange Network
 if ($netsettings{'ORANGE_DEV'}) {
        push(@network, $netsettings{'ORANGE_NETADDRESS'});
@@ -147,6 +154,11 @@ if ($netsettings{'ORANGE_DEV'}) {
        }
 }
 
+# Highlight multicast connections.
+push(@network, "224.0.0.0");
+push(@masklen, "239.0.0.0");
+push(@colour, $colour_multicast);
+
 # Add OpenVPN net and RED/BLUE/ORANGE entry (when appropriate)
 if (-e "${General::swroot}/ovpn/settings") {
        my %ovpnsettings = ();
@@ -173,7 +185,7 @@ if (-e "${General::swroot}/ovpn/settings") {
        }
 }
 
-open(IPSEC, "/var/ipfire/vpn/config");
+open(IPSEC, "${General::swroot}/vpn/config");
 my @ipsec = <IPSEC>;
 close(IPSEC);
 
@@ -190,6 +202,26 @@ foreach my $line (@ipsec) {
        push(@colour, ${Header::colourvpn});
 }
 
+if (-e "${General::swroot}/ovpn/n2nconf") {
+       open(OVPNN2N, "${General::swroot}/ovpn/ovpnconfig");
+       my @ovpnn2n = <OVPNN2N>;
+       close(OVPNN2N);
+
+       foreach my $line (@ovpnn2n) {
+               my @ovpn = split(',', $line);
+               next if ($ovpn[4] ne 'net');
+
+               my ($network, $mask) = split("/", $ovpn[12]);
+               if (!&General::validip($mask)) {
+                       $mask = ipv4_cidr2msk($mask);
+               }
+
+               push(@network, $network);
+               push(@masklen, $mask);
+               push(@colour, ${Header::colourovpn});
+       }
+}
+
 # Show the page.
 &Header::openpage($Lang::tr{'connections'}, 1, '');
 &Header::openbigbox('100%', 'left');
@@ -223,6 +255,9 @@ print <<END;
                        <td align='center' bgcolor='${Header::colourovpn}'>
                                <b><font color='#FFFFFF'>$Lang::tr{'OpenVPN'}</font></b>
                        </td>
+                       <td align='center' bgcolor='$colour_multicast'>
+                               <b><font color='#FFFFFF'>Multicast</font></b>
+                       </td>
                </tr>
        </table>
        <br>
@@ -270,21 +305,45 @@ foreach my $line (@conntrack) {
        # L4 protocol (tcp, udp, ...).
        my $l4proto = $conn[2];
 
+       # Translate unknown protocols.
        if ($l4proto eq 'unknown') {
-               $l4proto = '';
+               my $l4protonum = $conn[3];
+               if ($l4protonum eq '2') {
+                       $l4proto = 'IGMP';
+               } elsif ($l4protonum eq '4') {
+                       $l4proto = 'IPv4 Encap';
+               } elsif ($l4protonum eq '33') {
+                       $l4proto = 'DCCP';
+               } elsif ($l4protonum eq '41') {
+                       $l4proto = 'IPv6 Encap';
+               } elsif ($l4protonum eq '50') {
+                       $l4proto = 'ESP';
+               } elsif ($l4protonum eq '51') {
+                       $l4proto = 'AH';
+               } elsif ($l4protonum eq '132') {
+                       $l4proto = 'SCTP';
+               } else {
+                       $l4proto = $l4protonum;
+               }
+       } else {
+               $l4proto = uc($l4proto);
        }
 
        # Source and destination.
        my $sip;
+       my $sip_ret;
        my $dip;
+       my $dip_ret;
        my $sport;
+       my $sport_ret;
        my $dport;
+       my $dport_ret;
        my @packets;
        my @bytes;
 
        my $ttl = $conn[4];
        my $state;
-       if ($l4proto eq 'tcp') {
+       if ($l4proto eq 'TCP') {
                $state = $conn[5];
        }
 
@@ -294,16 +353,32 @@ foreach my $line (@conntrack) {
 
                switch ($key) {
                        case "src" {
-                               $sip = $val;
+                               if ($sip == "") {
+                                       $sip = $val;
+                               } else {
+                                       $dip_ret = $val;
+                               }
                        }
                        case "dst" {
-                               $dip = $val;
+                               if ($dip == "") {
+                                       $dip = $val;
+                               } else {
+                                       $sip_ret = $val;
+                               }
                        }
                        case "sport" {
-                               $sport = $val;
+                               if ($sport == "") {
+                                       $sport = $val;
+                               } else {
+                                       $dport_ret = $val;
+                               }
                        }
                        case "dport" {
-                               $dport = $val;
+                               if ($dport == "") {
+                                       $dport = $val;
+                               } else {
+                                       $sport_ret = $val;
+                               }
                        }
                        case "packets" {
                                push(@packets, $val);
@@ -317,21 +392,15 @@ foreach my $line (@conntrack) {
        my $sip_colour = ipcolour($sip);
        my $dip_colour = ipcolour($dip);
 
-    my $sserv = '';
-    if ($sport < 1024) {
+       my $sserv = '';
+       if ($sport < 1024) {
                $sserv = uc(getservbyport($sport, lc($l4proto)));
-               if ($sserv ne '') {
-                       $sserv = "&nbsp;($sserv)";
-               }
-    }
+       }
 
-    my $dserv = '';
-    if ($dport < 1024) {
+       my $dserv = '';
+       if ($dport < 1024) {
                $dserv = uc(getservbyport($dport, lc($l4proto)));
-               if ($dserv ne '') {
-                       $dserv = "&nbsp;($dserv)";
-               }
-    }
+       }
 
        my $bytes_in = format_bytes($bytes[0]);
        my $bytes_out = format_bytes($bytes[1]);
@@ -339,6 +408,49 @@ foreach my $line (@conntrack) {
        # Format TTL
        $ttl = format_time($ttl);
 
+       my $sip_extra;
+       if ($sip ne $sip_ret) {
+               $sip_extra = "<font color='#FFFFFF'>&gt;</font> ";
+               $sip_extra .= "<a href='/cgi-bin/ipinfo.cgi?ip=$sip_ret'>";
+               $sip_extra .= " <font color='#FFFFFF'>$sip_ret</font>";
+               $sip_extra .= "</a>";
+       }
+
+       my $dip_extra;
+       if ($dip ne $dip_ret) {
+               $dip_extra = "<font color='#FFFFFF'>&gt;</font> ";
+               $dip_extra .= "<a href='/cgi-bin/ipinfo.cgi?ip=$dip_ret'>";
+               $dip_extra .= " <font color='#FFFFFF'>$dip_ret</font>";
+               $dip_extra .= "</a>";
+       }
+
+
+       my $sport_extra;
+       if ($sport ne $sport_ret) {
+               my $sserv_ret = '';
+               if ($sport_ret < 1024) {
+                       $sserv_ret = uc(getservbyport($sport_ret, lc($l4proto)));
+               }
+
+               $sport_extra = "<font color='#FFFFFF'>&gt;</font> ";
+               $sport_extra .= "<a href='http://isc.sans.org/port_details.php?port=$sport_ret' target='top' title='$sserv_ret'>";
+               $sport_extra .= " <font color='#FFFFFF'>$sport_ret</font>";
+               $sport_extra .= "</a>";
+       }
+
+       my $dport_extra;
+       if ($dport ne $dport_ret) {
+               my $dserv_ret = '';
+               if ($dport_ret < 1024) {
+                       $dserv_ret = uc(getservbyport($dport_ret, lc($l4proto)));
+               }
+
+               $dport_extra = "<font color='#FFFFFF'>&gt;</font> ";
+               $dport_extra .= "<a href='http://isc.sans.org/port_details.php?port=$dport_ret' target='top' title='$dserv_ret'>";
+               $dport_extra .= " <font color='#FFFFFF'>$dport_ret</font>";
+               $dport_extra .= "</a>";
+       }
+
        print <<END;
        <tr>
                <td align='center'>$l4proto</td>
@@ -346,21 +458,25 @@ foreach my $line (@conntrack) {
                        <a href='/cgi-bin/ipinfo.cgi?ip=$sip'>
                                <font color='#FFFFFF'>$sip</font>
                        </a>
+                       $sip_extra
                </td>
                <td align='center' bgcolor='$sip_colour'>
-                       <a href='http://isc.sans.org/port_details.php?port=$sport' target='top'>
-                               <font color='#FFFFFF'>$sport$sserv</font>
+                       <a href='http://isc.sans.org/port_details.php?port=$sport' target='top' title='$sserv'>
+                               <font color='#FFFFFF'>$sport</font>
                        </a>
+                       $sport_extra
                </td>
                <td align='center' bgcolor='$dip_colour'>
                        <a href='/cgi-bin/ipinfo.cgi?ip=$dip'>
                                <font color='#FFFFFF'>$dip</font>
                        </a>
+                       $dip_extra
                </td>
                <td align='center' bgcolor='$dip_colour'>
-                       <a href='http://isc.sans.org/port_details.php?port=$dport' target='top'>
-                               <font color='#FFFFFF'>$dport$dserv</font>
+                       <a href='http://isc.sans.org/port_details.php?port=$dport' target='top' title='$dserv'>
+                               <font color='#FFFFFF'>$dport</font>
                        </a>
+                       $dport_extra
                </td>
                <td align='center'>
                        $bytes_in / $bytes_out