[1/2] squid / WPAD: Add GUI for exception-files for generationof proxy.pac

Message ID 1555883819-3329-1-git-send-email-ipfire@starkstromkonsument.de
State Accepted
Commit ce1c170b0c38015c88d2ff2966853d7cd6d65952
Headers
Series [1/2] squid / WPAD: Add GUI for exception-files for generationof proxy.pac |

Commit Message

Alexander Koch April 22, 2019, 7:56 a.m. UTC
  This patch adds the missing Web-GUI for the WPAD-Exceptions to proxy.cgi

Note: The translations are only done for "en" and "de" yet!

Signed-off-by: Alexander Koch <ipfire@starkstromkonsument.de>
---
 html/cgi-bin/proxy.cgi | 110 +++++++++++++++++++++++++++++++++++++++++++++++--
 langs/de/cgi-bin/de.pl |   7 ++++
 langs/en/cgi-bin/en.pl |   7 ++++
 3 files changed, 120 insertions(+), 4 deletions(-)
  

Comments

Matthias Fischer April 22, 2019, 6:02 p.m. UTC | #1
Hi,

first: happy eastern(!) and thanks(!) for your work ... but:

Could you please remove the apostrophs!? Its one of the most common
failures in spelling - and otherwise my oldest daughter will come after
you. She is married (no chance!) and knows some terrible torture
methods...  ;-))

On 21.04.2019 23:56, Alexander Koch wrote:
> +'advproxy wpad label dst_noproxy_url' => 'Ausgenommene URL\'s (eine pro Zeile)',
...
> +'advproxy wpad label dst_noproxy_url' => 'Excluded URL\'s (one per
line)',

They should be:

de.pl:
+'advproxy wpad label dst_noproxy_url' => 'Ausgenommene URLs (eine pro
Zeile)',

en.pl:
+'advproxy wpad label dst_noproxy_url' => 'Excluded URLs (one per line)',

There are several others, though...

Best,
Matthias
  
Tom Rymes April 23, 2019, 12:06 a.m. UTC | #2
> On Apr 22, 2019, at 4:02 AM, Matthias Fischer <matthias.fischer@ipfire.org> wrote:

<snip>

> Could you please remove the apostrophs!? Its one of the most common
> failures in spelling -

[snip]

For more detail: http://apostropheabuse.com

[snip]

> and otherwise my oldest daughter will come after
> you. She is married (no chance!) and knows some terrible torture
> methods...  ;-))

Are you implying that marriage is an effective torture method?

<grin>

Tom
  
Matthias Fischer April 23, 2019, 1:10 a.m. UTC | #3
On 22.04.2019 16:06, Tom Rymes wrote:

>>...
>> and otherwise my oldest daughter will come after
>> you. She is married (no chance!) and knows some terrible torture
>> methods...  ;-))

> Are you implying that marriage is an effective torture method?
> 
> <grin>

Hmmm. Can't say at the moment. I'll ask her husband when he's out of the
hospital... :-))

Best,
Matthias
  
Michael Tremer April 23, 2019, 4:46 a.m. UTC | #4
Hi,

> On 22 Apr 2019, at 16:10, Matthias Fischer <matthias.fischer@ipfire.org> wrote:
> 
> On 22.04.2019 16:06, Tom Rymes wrote:
> 
>>> ...
>>> and otherwise my oldest daughter will come after
>>> you. She is married (no chance!) and knows some terrible torture
>>> methods...  ;-))
> 
>> Are you implying that marriage is an effective torture method?
>> 
>> <grin>
> 
> Hmmm. Can't say at the moment. I'll ask her husband when he's out of the
> hospital... :-))

LOL I like this :)

I merged the patches and made the proposed changes so that nobody has to get hurt!

Thanks for the suggestion. I think I would have missed in. In the future you can send patches straight away for things like this.

-Michael

> 
> Best,
> Matthias
  
Matthias Fischer April 24, 2019, 2:29 a.m. UTC | #5
Hi,

On 22.04.2019 20:46, Michael Tremer wrote:
> In the future you can send patches straight away for things like this.

It's on my list... ;-)

Best,
Matthias
  

Patch

diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi
index 369a5cb..55fdc1c 100644
--- a/html/cgi-bin/proxy.cgi
+++ b/html/cgi-bin/proxy.cgi
@@ -559,6 +559,8 @@  ERROR:
 		delete $proxysettings{'SRC_UNRESTRICTED_MAC'};
 		delete $proxysettings{'DST_NOCACHE'};
 		delete $proxysettings{'DST_NOAUTH'};
+		delete $proxysettings{'DST_NOPROXY_IP'};
+		delete $proxysettings{'DST_NOPROXY_URL'};
 		delete $proxysettings{'PORTS_SAFE'};
 		delete $proxysettings{'PORTS_SSL'};
 		delete $proxysettings{'MIME_TYPES'};
@@ -1318,6 +1320,58 @@  END
 ;
 }
 
+# ===================================================================
+#  WPAD settings
+# ===================================================================
+
+print <<END
+<table width='100%'>
+<tr>
+	<td colspan='4'><b>$Lang::tr{'advproxy wpad title'}</b></td>
+</tr>
+<tr>
+	<td width='25%'></td> <td width='20%'> </td><td width='25%'> </td><td width='30%'></td>
+</tr>
+<tr>
+	<td colspan='2' class='base'>$Lang::tr{'advproxy wpad label dst_noproxy_ip'}:</td>
+	<td colspan='2' class='base'>$Lang::tr{'advproxy wpad label dst_noproxy_url'}:</td>
+</tr>
+<tr>
+	<td colspan='2'><textarea name='DST_NOPROXY_IP' cols='32' rows='3' wrap='off'>
+END
+;
+
+	print $proxysettings{'DST_NOPROXY_IP'};
+
+print <<END
+</textarea></td>
+
+	<td colspan='2'><textarea name='DST_NOPROXY_URL' cols='32' rows='3' wrap='off'>
+END
+;
+
+	print $proxysettings{'DST_NOPROXY_URL'};
+
+print <<END
+</textarea></td>
+</tr>
+<tr>
+	<td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_ip'}</td>
+	<td colspan='2' class='base'>$Lang::tr{'advproxy wpad example dst_noproxy_url'}</td>
+</tr>
+<tr>
+	<td colspan="4">&nbsp;</td>
+</tr>
+<tr>
+	<td colspan="4">$Lang::tr{'advproxy wpad view pac'}: <a href="http://$ENV{SERVER_ADDR}:81/wpad.dat" target="_blank">http://$ENV{SERVER_ADDR}:81/wpad.dat</a></td>
+</tr>
+</table>
+
+<hr size='1'>
+
+END
+;
+
 # -------------------------------------------------------------------
 
 print <<END
@@ -2261,6 +2315,18 @@  sub read_acls
 		while (<FILE>) { $proxysettings{'DST_NOAUTH'} .= $_ };
 		close(FILE);
 	}
+	if (-e "$acl_dst_noproxy_ip") {
+		open(FILE,"$acl_dst_noproxy_ip");
+		delete $proxysettings{'DST_NOPROXY_IP'};
+		while (<FILE>) { $proxysettings{'DST_NOPROXY_IP'} .= $_ };
+		close(FILE);
+	}
+	if (-e "$acl_dst_noproxy_url") {
+		open(FILE,"$acl_dst_noproxy_url");
+		delete $proxysettings{'DST_NOPROXY_URL'};
+		while (<FILE>) { $proxysettings{'DST_NOPROXY_URL'} .= $_ };
+		close(FILE);
+	}
 	if (-e "$acl_ports_safe") {
 		open(FILE,"$acl_ports_safe");
 		delete $proxysettings{'PORTS_SAFE'};
@@ -2446,6 +2512,31 @@  sub check_acls
 		}
 	}
 
+	@temp = split(/\n/,$proxysettings{'DST_NOPROXY_IP'});
+	undef $proxysettings{'DST_NOPROXY_IP'};
+	foreach (@temp)
+	{
+			s/^\s+//g; s/\s+$//g;
+			if ($_)
+			{
+					unless (&General::validipormask($_)) { $errormessage = $Lang::tr{'advproxy errmsg wpad invalid ip or mask'}; }
+					$proxysettings{'DST_NOPROXY_IP'} .= $_."\n";
+			}
+	}
+
+	@temp = split(/\n/,$proxysettings{'DST_NOPROXY_URL'});
+	undef $proxysettings{'DST_NOPROXY_URL'};
+	foreach (@temp)
+	{
+			s/^\s+//g;
+			unless (/^#/) { s/\s+//g; }
+			if ($_)
+			{
+					if (/^\./) { $_ = '*'.$_; }
+					$proxysettings{'DST_NOPROXY_URL'} .= $_."\n";
+			}
+	}
+
 	if (($proxysettings{'NTLM_ENABLE_ACL'} eq 'on') && ($proxysettings{'NTLM_USER_ACL'} eq 'positive'))
 	{
 		@temp = split(/\n/,$proxysettings{'NTLM_ALLOW_USERS'});
@@ -2584,6 +2675,16 @@  sub write_acls
 	print FILE $proxysettings{'DST_NOAUTH'};
 	close(FILE);
 
+	open(FILE, ">$acl_dst_noproxy_ip");
+	flock(FILE, 2);
+	print FILE $proxysettings{'DST_NOPROXY_IP'};
+	close(FILE);
+
+	open(FILE, ">$acl_dst_noproxy_url");
+	flock(FILE, 2);
+	print FILE $proxysettings{'DST_NOPROXY_URL'};
+	close(FILE);
+
 	open(FILE, ">$acl_dst_noauth_net");
 	close(FILE);
 	open(FILE, ">$acl_dst_noauth_dom");
@@ -2769,7 +2870,7 @@  END
 	# Additional exceptions for URLs
 	# The file has to be created by the user and should contain one entry per line
 	# Line-Format: <URL incl. wildcards>
-	# e.g. *ipfire.org*
+	# e.g. *.ipfire.org*
 	if (-s "$acl_dst_noproxy_url") {
 		undef @templist;
 
@@ -2786,8 +2887,8 @@  END
 
 	# Additional exceptions for Subnets
 	# The file has to be created by the user and should contain one entry per line
-	# Line-Format: "<IP>", "<SUBNET MASK>"
-	# e.g. "192.168.0.0", "255.255.255.0"
+	# Line-Format: <IP>/<SUBNET MASK>
+	# e.g. 192.168.0.0/255.255.255.0
 	if (-s "$acl_dst_noproxy_ip") {
 		undef @templist;
 
@@ -2798,7 +2899,8 @@  END
 
 		foreach (@templist)
 		{
-			print FILE "     (isInNet(host, $_)) ||\n";
+			@temp = split(/\//);
+			print FILE "     (isInNet(host, \"$temp[0]\", \"$temp[1]\")) ||\n";
 		}
 	}
 
diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl
index 90b1ada..8f84042 100644
--- a/langs/de/cgi-bin/de.pl
+++ b/langs/de/cgi-bin/de.pl
@@ -396,6 +396,13 @@ 
 'advproxy visible hostname' => 'Sichtbarer Hostname',
 'advproxy web browser' => 'Web-Browser',
 'advproxy wednesday' => 'Mi',
+'advproxy wpad title' => 'Web Proxy Auto-Discovery Protocol (WPAD) / Proxy Auto-Config (PAC)',
+'advproxy wpad label dst_noproxy_url' => 'Ausgenommene URL\'s (eine pro Zeile)',
+'advproxy wpad label dst_noproxy_ip' => 'Ausgenommene IP-Subnetze (eins pro Zeile)',
+'advproxy wpad example dst_noproxy_url' => 'z.B. *.ipfire.org*',
+'advproxy wpad example dst_noproxy_ip' => 'z.B. 192.168.2.0/255.255.255.0',
+'advproxy errmsg wpad invalid ip or mask' => 'WPAD: Ung&uuml;ltige IP oder Subnetz f&uuml;r ausgenommenes IP-Subnetz',
+'advproxy wpad view pac' => 'PAC-Datei aufrufen',
 'again' => 'Wiederholung:',
 'age second' => 'Sekunde',
 'age seconds' => 'Sekunden',
diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl
index 98e99f1..9a3e8b0 100644
--- a/langs/en/cgi-bin/en.pl
+++ b/langs/en/cgi-bin/en.pl
@@ -397,6 +397,13 @@ 
 'advproxy visible hostname' => 'Visible hostname',
 'advproxy web browser' => 'Web browser',
 'advproxy wednesday' => 'Wed',
+'advproxy wpad title' => 'Web Proxy Auto-Discovery Protocol (WPAD) / Proxy Auto-Config (PAC)',
+'advproxy wpad label dst_noproxy_url' => 'Excluded URL\'s (one per line)',
+'advproxy wpad label dst_noproxy_ip' => 'Excluded IP-Subnets (one per line)',
+'advproxy wpad example dst_noproxy_url' => 'e.g. *.ipfire.org*',
+'advproxy wpad example dst_noproxy_ip' => 'e.g. 192.168.2.0/255.255.255.0',
+'advproxy errmsg wpad invalid ip or mask' => 'WPAD: Invalid IP or subnet for excluded IP-subnet',
+'advproxy wpad view pac' => 'Open PAC-File',
 'again' => 'Again:',
 'age second' => 'second',
 'age seconds' => 'seconds',