par Yull » 21 Oct 2006 13:58
Voila voila
Si quelqu'un connait un petit .pdf qui explique ce langage, comme ca la prochaine fois je pourrais peut être trouver le bug tout seul
Merci &@+
--- connections.cgi.old 2006-08-29 13:07:08.000000000 +0200
+++ connections.cgi.new 2006-08-28 14:59:48.000000000 +0200
@@ -10,10 +10,17 @@
#
# Setup GREEN, ORANGE, IPCOP, VPN CIDR networks, masklengths and colours only once
+# ZERINA-VERSION:0.9.4b
+# (c) 2005-2006 Ufuk Altinkaynak & Olaf Westrik
+# Ipcop and OpenVPN as easy as one two three..
+#
+$Header::colourovpn = '#339999';
my @network=();
my @masklen=();
my @colour=();
+my @ports=();
+my @protocols=();
use Net::IPv4Addr qw( :all );
@@ -53,11 +60,15 @@
push(@network, $netsettings{'GREEN_ADDRESS'});
push(@masklen, "255.255.255.255" );
push(@colour, ${Header::colourfw} );
+push(@ports, '0' );
+push(@protocols, '' );
# Add Green Network to Array
push(@network, $netsettings{'GREEN_NETADDRESS'});
push(@masklen, $netsettings{'GREEN_NETMASK'} );
push(@colour, ${Header::colourgreen} );
+push(@ports, '0' );
+push(@protocols, '' );
# Add Green Routes to Array
my @routes = `/sbin/route -n | /bin/grep $netsettings{'GREEN_DEV'}`;
@@ -67,18 +78,68 @@
push(@network, $temp[0]);
push(@masklen, $temp[2]);
push(@colour, ${Header::colourgreen} );
+ push(@ports, '0' );
+ push(@protocols, '' );
}
# Add Firewall Localhost 127.0.0.1
push(@network, '127.0.0.1');
push(@masklen, '255.255.255.255' );
push(@colour, ${Header::colourfw} );
+push(@ports, '0' );
+push(@protocols, '' );
+
+### weizen_42
+# Add OpenVPN net and RED/BLUE/ORANGE entry (when appropriate)
+if (-e "${General::swroot}/ovpn/settings") {
+ my %ovpnsettings = ();
+ &General::readhash("${General::swroot}/ovpn/settings", \%ovpnsettings);
+ my @tempovpnsubnet = split("\/",$ovpnsettings{'DOVPN_SUBNET'});
+
+ # add OpenVPN net
+ push(@network, $tempovpnsubnet[0]);
+ push(@masklen, $tempovpnsubnet[1]);
+ push(@colour, ${Header::colourovpn} );
+ push(@ports, '0' );
+ push(@protocols, '' );
+
+ if ( ($ovpnsettings{'ENABLED'} eq 'on') && open(IP, "${General::swroot}/red/local-ipaddress") ) {
+ # add RED:port / proto
+ my $redip = <IP>;
+ close(IP);
+ chomp $redip;
+ push(@network, $redip );
+ push(@masklen, '255.255.255.255' );
+ push(@colour, ${Header::colourovpn} );
+ push(@ports, $ovpnsettings{'DDEST_PORT'} );
+ push(@protocols, $ovpnsettings{'DPROTOCOL'} );
+ }
+ if ( ($ovpnsettings{'ENABLED_BLUE'} eq 'on') && $netsettings{'BLUE_DEV'} ) {
+ # add BLUE:port / proto
+ push(@network, $netsettings{'BLUE_ADDRESS'} );
+ push(@masklen, '255.255.255.255' );
+ push(@colour, ${Header::colourovpn} );
+ push(@ports, $ovpnsettings{'DDEST_PORT'} );
+ push(@protocols, $ovpnsettings{'DPROTOCOL'} );
+ }
+ if ( ($ovpnsettings{'ENABLED_ORANGE'} eq 'on') && $netsettings{'ORANGE_DEV'} ) {
+ # add ORANGE:port / proto
+ push(@network, $netsettings{'ORANGE_ADDRESS'} );
+ push(@masklen, '255.255.255.255' );
+ push(@colour, ${Header::colourovpn} );
+ push(@ports, $ovpnsettings{'DDEST_PORT'} );
+ push(@protocols, $ovpnsettings{'DPROTOCOL'} );
+ }
+}
+### weizen_42 END
# Add Orange Network
if ($netsettings{'ORANGE_DEV'}) {
push(@network, $netsettings{'ORANGE_NETADDRESS'});
push(@masklen, $netsettings{'ORANGE_NETMASK'} );
push(@colour, ${Header::colourorange} );
+ push(@ports, '0' );
+ push(@protocols, '' );
# Add Orange Routes to Array
@routes = `/sbin/route -n | /bin/grep $netsettings{'ORANGE_DEV'}`;
foreach my $route (@routes) {
@@ -87,6 +148,8 @@
push(@network, $temp[0]);
push(@masklen, $temp[2]);
push(@colour, ${Header::colourorange} );
+ push(@ports, '0' );
+ push(@protocols, '' );
}
}
@@ -95,6 +158,9 @@
push(@network, $netsettings{'BLUE_NETADDRESS'});
push(@masklen, $netsettings{'BLUE_NETMASK'} );
push(@colour, ${Header::colourblue} );
+ push(@ports, '0' );
+ push(@protocols, '' );
+
# Add Blue Routes to Array
@routes = `/sbin/route -n | /bin/grep $netsettings{'BLUE_DEV'}`;
foreach my $route (@routes) {
@@ -103,6 +169,8 @@
push(@network, $temp[0]);
push(@masklen, $temp[2]);
push(@colour, ${Header::colourblue} );
+ push(@ports, '0' );
+ push(@protocols, '' );
}
}
@@ -119,6 +187,8 @@
push(@network, $temp[0]);
push(@masklen, $netsettings{'RED_NETMASK'} );
push(@colour, ${Header::colourfw} );
+ push(@ports, '0' );
+ push(@protocols, '' );
}
}
}
@@ -132,6 +202,8 @@
push(@network, $temp1[0]);
push(@masklen, ipv4_cidr2msk($temp1[1]));
push(@colour, ${Header::colourvpn} );
+ push(@ports, '0' );
+ push(@protocols, '' );
}
}
if (open(IP, "${General::swroot}/red/local-ipaddress")) {
@@ -141,6 +213,8 @@
push(@network, $redip);
push(@masklen, '255.255.255.255' );
push(@colour, ${Header::colourfw} );
+ push(@ports, '0' );
+ push(@protocols, '' );
}
@@ -374,6 +448,7 @@
<td align='center' bgcolor='${Header::colourblue}'><b><font color='#FFFFFF'>$Lang::tr{'wireless'}</font></b></td>
<td align='center' bgcolor='${Header::colourfw}'><b><font color='#FFFFFF'>IPCop</font></b></td>
<td align='center' bgcolor='${Header::colourvpn}'><b><font color='#FFFFFF'>$Lang::tr{'vpn'}</font></b></td>
+ <td align='center' bgcolor='${Header::colourovpn}'><b><font color='#FFFFFF'>$Lang::tr{'OpenVPN'}</font></b></td>
</tr>
</table>
<br />
@@ -445,9 +520,12 @@
my $line;
my $colour = ${Header::colourred};
my ($ip) = $_[0];
+ my ($port) = $_[1];
+ my ($protocol) = substr $_[2], 0, 3;
my $found = 0;
foreach $line (@network) {
- if (!$found && ipv4_in_network( $network[$id] , $masklen[$id], $ip) ) {
+# if (!$found && ipv4_in_network( $network[$id] , $masklen[$id], $ip) ) {
+ if (!$found && ipv4_in_network( $network[$id] , $masklen[$id], $ip) && ($ports[$id] eq $port || $ports[$id] eq '0' ) && ($protocols[$id] eq $protocol || $protocols[$id] eq '' )) {
$found = 1;
$colour = $colour[$id];
}