Re: [squid-users] adding a parameter to a URL / Problem in the url_redirect program

From: Shaine <gsm_linux_at_yahoo.co.uk>
Date: Mon, 7 Jul 2008 01:48:32 -0700 (PDT)

Thank you Henrik. yes that script is very simple and now and its working. But
i have another requirement to capture Client IP which comes via the URL .
Its bit confuse at this time coz i had different idea .So now can u direct
me to how to capture client ip by that perl script which you have posted.

Thank you
Shaine.

Henrik Nordstrom-5 wrote:
>
> On sön, 2008-07-06 at 22:05 -0700, Shaine wrote:
>
>> Following is my script.
>>
>> #!/usr/bin/perl
>> # no buffered output, auto flush
>> use strict;
>> use warnings;
>>
>> my ($temp, $array, @array, $param_1, $param_2, $param_3, $new_uri);
>>
>> $|=1;
>> $temp = "";
>>
>>
>> while (<STDIN>){
>> #@array = split(/ /);
>> ($param_1, $param_2, $param_3) = split(/ /);
>> #if (!($array[1] =~ m#VALUE-X#)) {
>> if (!($param_2 =~ m#VALUE-X#)) {
>> $temp = $param_2;
>> if ($param_2 =~ m#\?#) {
>> $temp .= "&VALUE-X=652224848";
>> }else {
>> $temp .= "?VALUE-X=652224848";
>> }
>> $new_uri = ($param_1 . " " . $temp . " " . $param_3);
>> s#$param_2#$temp#;
>> #print $new_uri;
>> print;
>> }else {
>> print;
>> }
>> }
>
>
> If I understand the above correct you modify the second parameter sent
> to the script which is the requesting client ip...
>
> The URL is the first, and the only one used by Squid in responses.
>
> Here is a simplified version of that script which should work better I
> think (completely untested)
>
> ### BEGIN ###
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> # no buffered output, auto flush
> $|=1;
> while (<STDIN>) {
> chomp;
> my ($url) = split(/ /);
> if (!($url =~ m#VALUE-X#)) {
> if ($url =~ m#\?#) {
> $url .= "&VALUE-X=652224848";
> } else {
> $url .= "?VALUE-X=652224848";
> }
> print $url."\n";
> } else {
> print "\n";
> }
> }
> ### END ###
>
> The chomp isn't stricly needed, but makes testing from command line
> easier as it's sufficient to then enter just the URL for proper results
> and not a complete url rewriter request.
>
> Regards
> Henrik
>
>
>

-- 
View this message in context: http://www.nabble.com/adding-a-parameter-to-a-URL-tp17776816p18312476.html
Sent from the Squid - Users mailing list archive at Nabble.com.
Received on Mon Jul 07 2008 - 08:48:37 MDT

This archive was generated by hypermail 2.2.0 : Mon Jul 07 2008 - 12:00:04 MDT