Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

IPv6 support

  • Loading branch information...
commit d66c41b31d857c8e98ec625e6c9cb93e58d511e6 1 parent 825fb39
@jcameron jcameron authored
View
10 squid/acl.cgi
@@ -67,16 +67,16 @@ if ($type eq "src" || $type eq "dst") {
"<td><b>$text{'acl_toip'}</b></td>\n";
print " <td><b>$text{'acl_nmask'}</b></td> </tr>\n";
for($i=0; $i<=@vals; $i++) {
- if ($vals[$i] =~ /^([\d\.]+)-([\d\.]+)\/([\d\.]+)$/) {
+ if ($vals[$i] =~ /^([a-z0-9\.\:]+)-([a-z0-9\.\:]+)\/([\d\.]+)$/) {
$from = $1; $to = $2; $mask = $3;
}
- elsif ($vals[$i] =~ /^([\d\.]+)-([\d\.]+)$/) {
+ elsif ($vals[$i] =~ /^([a-z0-9\.\:]+)-([a-z0-9\.\:]+)$/) {
$from = $1; $to = $2; $mask = "";
}
- elsif ($vals[$i] =~ /^([\d\.]+)\/([\d\.]+)$/) {
+ elsif ($vals[$i] =~ /^([a-z0-9\.\:]+)\/([\d\.]+)$/) {
$from = $1; $to = ""; $mask = $2;
}
- elsif ($vals[$i] =~ /^([\d\.]+)$/) {
+ elsif ($vals[$i] =~ /^([a-z0-9\.\:]+)$/) {
$from = $1; $to = ""; $mask = "";
}
else { $from = $to = $mask = ""; }
@@ -93,7 +93,7 @@ elsif ($type eq "myip") {
print "<tr> <td><b>$text{'acl_ipaddr'}</b></td> ",
"<td><b>$text{'acl_nmask'}</b></td> </tr>\n";
for($i=0; $i<=@vals; $i++) {
- if ($vals[$i] =~ /^([\d\.]+)\/([\d\.]+)$/) {
+ if ($vals[$i] =~ /^([a-z0-9\.\:]+)\/([\d\.]+)$/) {
$ip = $1; $mask = $2;
}
else { $ip = $mask = ""; }
View
4 squid/acl_save.cgi
@@ -64,8 +64,10 @@ else {
$to = $in{"to_$i"}; $mask = $in{"mask_$i"};
next if (!$from && !$to && !$mask);
&check_ipaddress($from) ||
+ &check_ip6address($from) ||
&error(&text('aclsave_efrom',$from));
!$to || &check_ipaddress($to) ||
+ &check_ip6address($to) ||
&error(&text('aclsave_eto',$to));
$mask =~ /^\d*$/ || &check_ipaddress($mask) ||
&error(&text('aclsave_enmask',$mask));
@@ -79,7 +81,7 @@ else {
for($i=0; defined($ip = $in{"ip_$i"}); $i++) {
$mask = $in{"mask_$i"};
next if (!$mask || !$ip);
- &check_ipaddress($ip) ||
+ &check_ipaddress($ip) || &check_ip6address($ip) ||
&error(&text('aclsave_eip',$ip));
$mask =~ /^\d+$/ || &check_ipaddress($mask) ||
&error(&text('aclsave_enmask',$mask));
View
2  squid/edit_ports.cgi
@@ -113,7 +113,7 @@ foreach $p (@ports, '') {
printf "<input type=radio name=$_[0]_addr_def_$i value=0 %s>\n",
$p =~ /:/ ? 'checked' : '';
printf "<input name=$_[0]_addr_$i size=20 value='%s'></td>\n",
- $p =~ /^(\S+):/ ? $1 : '';
+ $p =~ /^\[(\S+)\]:/ || $p =~ /^(\S+):/ ? $1 : '';
if ($squid_version >= 2.5) {
# Show port options
printf "<td><input name=$_[0]_opts_$i size=40 value='%s'></td>\n",
View
58 squid/edit_sports.cgi
@@ -1,58 +0,0 @@
-#!/usr/local/bin/perl
-# edit_sports.cgi
-# A form for editing simple networking options
-
-require './squid-lib.pl';
-$access{'portsnets'} || &error($text{'eports_ecannot'});
-&ui_print_header(undef, $text{'eports_header'}, "", "", 0, 0, 0, &restart_button());
-$conf = &get_config();
-
-print "<form action=save_sports.cgi>\n";
-print "<table border width=100%>\n";
-print "<tr $tb> <td><b>$text{'eports_pano'}</b></td> </tr>\n";
-print "<tr $cb> <td><table width=100%>\n";
-
-print "<tr>\n";
-if ($squid_version >= 2.3) {
- print "<td valign=top><b>$text{'eports_paap'}</b></td>\n";
- print "<td colspan=3><table border>\n";
- print "<tr $tb> <td><b>$text{'eports_p'}</b></td>\n",
- "<td><b>$text{'eports_hia'}</b></td> </tr>\n";
- foreach $p (&find_config('http_port', $conf)) {
- push(@ports, @{$p->{'values'}});
- }
- $i = 0;
- foreach $p (@ports, '') {
- print "<tr $cb>\n";
- printf "<td><input name=port_$i size=6 value='%s'></td> <td>\n",
- $p =~ /(\d+)$/ ? $1 : '';
- printf "<input type=radio name=addr_def_$i value=1 %s> All\n",
- $p =~ /:/ ? '' : 'checked';
- printf "<input type=radio name=addr_def_$i value=0 %s>\n",
- $p =~ /:/ ? 'checked' : '';
- printf "<input name=addr_$i size=20 value='%s'></td>\n",
- $p =~ /^(\S+):/ ? $1 : '';
- print "</tr>\n";
- $i++;
- }
-
- print "</table></td></tr>\n";
- }
-else {
- print &opt_input($text{'eports_pp'}, "http_port",
- $conf, $text{'default'}, 6);
- print &opt_input($text{'eports_ita'}, "tcp_incoming_address",
- $conf, $text{'eports_a'}, 15);
- print "</tr>\n";
- }
-
-print "<tr>\n";
-print &opt_input($text{'emisc_sdta'}, "dns_testnames", $conf,
- $text{'default'}, 40);
-print "</tr>\n";
-
-print "</table></td></tr></table>\n";
-print "<input type=submit value='$text{'buttsave'}'></form>\n";
-
-&ui_print_footer("", $text{'eports_return'});
-
View
2  squid/save_cache.cgi
@@ -213,7 +213,7 @@ return $_[0] =~ /^\d+$/ ? undef : &text('scache_emsg12',$_[0]);
sub check_host
{
-return gethostbyname($_[0]) || &check_ipaddress($_[0]) ? undef
+return &to_ipaddress($_[0]) || &to_ip6address($_[0]) ? undef
: &text('scache_emsg13',$_[0]);
}
View
2  squid/save_cache_host.cgi
@@ -27,7 +27,7 @@ if ($in{'delete'}) {
else {
# validate inputs
$whatfailed = $text{'schost_ftsc'};
- gethostbyname($in{'host'}) || &check_ipaddress($in{'host'}) ||
+ &to_ipaddress($in{'host'}) || &to_ip6address($in{'host'}) ||
&error(&text('schost_emsg1',$in{'host'}));
$in{'proxy'} =~ /^\d+$/ ||
&error(&text('schost_emsg2',$in{'proxy'}));
View
2  squid/save_iptables.cgi
@@ -10,7 +10,7 @@ $port = &get_squid_port();
# Validate inputs
if ($in{'enabled'} == 1) {
- gethostbyname($in{'net'}) ||
+ &to_ipaddress($in{'net'}) ||
($in{'net'} =~ /^([0-9\.]+)\/(\d+)$/ &&
&check_ipaddress($1) && $2 > 0 && $2 <= 32) ||
&error($text{'iptables_enet'});
View
5 squid/save_ports.cgi
@@ -51,7 +51,7 @@ return $_[0] =~ /^\d+$/ ? undef : &text('sport_emsg1',$_[0]);
sub check_address
{
-return &check_ipaddress($_[0]) || gethostbyname($_[0]) ? undef :
+return &to_ipaddress($_[0]) || &to_ip6address($_[0]) ? undef :
&text('sport_emsg2',$_[0]);
}
@@ -74,8 +74,9 @@ for($i=0; defined($port = $in{"$_[0]_port_$i"}); $i++) {
}
else {
$addr = $in{"$_[0]_addr_$i"};
- gethostbyname($addr) || &check_ipaddress($addr) ||
+ &to_ipaddress($addr) || &to_ip6address($addr) ||
&error("'$addr' is not a valid proxy address");
+ $addr = "[$addr]" if (&check_ip6address($addr));
push(@ports, { 'name' => $_[0],
'values' => [ "$addr:$port" ] } );
}
View
58 squid/save_sports.cgi
@@ -1,58 +0,0 @@
-#!/usr/local/bin/perl
-# save_sports.cgi
-# Save simple ports and other networking options
-
-require './squid-lib.pl';
-$access{'portsnets'} || &error($text{'eports_ecannot'});
-&ReadParse();
-&lock_file($config{'squid_conf'});
-$conf = &get_config();
-$whatfailed = $text{'sport_ftspo'};
-
-if ($squid_version >= 2.3) {
- for($i=0; defined($port = $in{"port_$i"}); $i++) {
- next if (!$port);
- $port =~ /^\d+$/ || &error("'$port' is not a valid port");
- if ($in{"addr_def_$i"}) {
- push(@ports, { 'name' => 'http_port',
- 'values' => [ $port ] } );
- }
- else {
- $addr = $in{"addr_$i"};
- gethostbyname($addr) || &check_ipaddress($addr) ||
- &error("'$addr' is not a valid proxy address");
- push(@ports, { 'name' => 'http_port',
- 'values' => [ "$addr:$port" ] } );
- }
- }
- &save_directive($conf, 'http_port', \@ports);
- }
-else {
- &save_opt("http_port", \&check_port, $conf);
- &save_opt("tcp_incoming_address", \&check_address, $conf);
- }
-
-&save_opt("dns_testnames", undef, $conf);
-
-&flush_file_lines();
-&unlock_file($config{'squid_conf'});
-&webmin_log("ports", undef, undef, \%in);
-&redirect("");
-
-sub check_port
-{
-return $_[0] =~ /^\d+$/ ? undef : &text('sport_emsg1',$_[0]);
-}
-
-sub check_address
-{
-return &check_ipaddress($_[0]) || gethostbyname($_[0]) ? undef :
- &text('sport_emsg2',$_[0]);
-
-}
-
-sub check_bufsize
-{
-return $_[0] =~ /^\d+$/ ? undef : &text('sport_emsg3',$_[0]);
-}
-
View
5 squid/start.cgi
@@ -16,8 +16,9 @@ if ($config{'squid_start'}) {
$errs = &read_file_contents($temp);
unlink($temp);
&reset_environment();
- if ($errs && $errs =~ /\d+\/\d+\/\d+/) {
- &system_logged("$config{'squid_stop'} >/dev/null 2>&1 </dev/null");
+ if (!&is_squid_running()) {
+ &system_logged(
+ "$config{'squid_stop'} >/dev/null 2>&1 </dev/null");
&error("<pre>$errs</pre>");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.