Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =================================================================================================== #
- # ################################ addon script to squid.conf #########################################
- # =================================================================================================== #
- acl rewriteyoutube url_regex ^https?\:\/\/.*youtube\.com\/watch\?.*
- url_rewrite_access allow rewriteyoutube
- url_rewrite_program /etc/squid/youtubeplay.pl
- url_rewrite_children 32 startup=0 idle=1 concurrency=100
- redirector_bypass on
- acl youtubeplay url_regex ^https?\:\/\/.*youtube\.com\/watch\?.*
- cache deny youtubeplay
- store_id_access deny youtubeplay
- # =================================================================================================== #
- ########################## INPUT SCRIPT touch youtube.pl at squid directory /etc/squid/ ###############
- # =================================================================================================== #
- # copy script
- #!/usr/bin/perl
- #### var
- use IO::File;
- $|=1;
- STDOUT->autoflush(1);
- $debug=1; ## recommended:0
- $bypassallrules=0; ## recommended:0
- $sucks=""; ## unused
- $sucks="sucks" if ($debug>=1);
- $timenow="";
- $printtimenow=1; ## print timenow: 0|1
- my $logfile = '/tmp/urlrewrite.log';
- open my $logfh, '>>', $logfile
- or die "Couldn't open $logfile for appending: $!\n" if $debug;
- $logfh->autoflush(1) if $debug;
- while () {
- $timenow=time()." " if ($printtimenow);
- #print $logfh "$timenow"."in : $_" if ($debug>=1);
- #print $logfh "in : $_" if ($debug>=1);
- chop; ## strip eol
- my $urlku = $_;
- #@X = split;
- @X = split(" ",$urlku);
- $a = $X[0]; ## chanel
- $b = $X[1]; ## url
- $c = $X[2]; ## ip
- $u = $b; ## url
- print $logfh "in : $_\n" if ($debug>=1);
- if ($bypassallrules){
- $out="$u"; ## map 1:1
- #utmgif
- } elsif ($u=~ m/^https?\:\/\/.*youtube\.com\/watch\?.*/) {
- $out="OK rewrite-url=$u&html5=1";
- } else {
- $out="ERR";
- }
- print $logfh "out: $a $out\n" if ($debug>=1);
- print "$a $out\n";
- }
- close $logfh if ($debug);
- # =================================================================================================== #
Add Comment
Please, Sign In to add comment