Penguin
Diff: SquidCachingYouTube
EditPageHistoryDiffInfoLikePages

Differences between current version and predecessor to the previous major change of SquidCachingYouTube.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 2 Last edited on Sunday, June 1, 2008 10:23:26 pm by AristotlePagaltzis
Older page: version 1 Last edited on Sunday, June 1, 2008 4:33:16 pm by CraigWhitmore Revert
@@ -1,7 +1,9 @@
-Using Squid 2.7 
+( Using Squid 2.7)  
  
-<pre
+!! Configuration  
+  
+ <verbatim
 acl all src all 
 acl manager proto cache_object 
 acl localhost src 127.0.0.1/32 
 acl to_localhost dst 127.0.0.0/8 
@@ -51,42 +53,36 @@
 storeurl_access allow store_rewrite_list 
 storeurl_access deny all 
 storeurl_rewrite_program /archives/youtube 
 quick_abort_min -1 KB 
+</verbatim>  
  
------------------------------  
- /archives/youtube 
+!! The <tt> /archives/youtube</tt> program  
  
+<verbatim>  
 #!/usr/bin/perl 
+use IO::File;  
+  
+STDOUT->autoflush(1);  
  
- use IO::File;  
- use IO::Socket::INET;  
- use IO::Pipe
+my $logfile = '/tmp/debug.log'
  
- $| = 1
+open my $logfh, '>>', $logfile  
+ or die "Couldn't open $logfile for appending: $!\n"
  
- $fh = new IO::File("/tmp/debug.log", "a");  
- $fh ->flush (); 
+$logfh ->autoflush (1 ); 
  
- while (<>) {  
- chomp;  
- print LOG "Orig URL: " . $_ . "\n";  
- $fh->print("Orig URL: " . $_ . "\n");  
- if ( m/ kh(.*?)\.google\.com(.*?)\ /(.*?) /) {  
- print "http://keyhole-srv.google.com" . $2 . " .SQUIDINTERNAL/" . $3 . "\n";  
- # print STDERR "KEYHOLE\n";  
- } elsif ( m/ mt(.*?)\.google\.com(.*?)\ /(.*?) /) {  
- print "http://map-srv.google.com" . $2 . " .SQUIDINTERNAL/" . $3 . "\n";  
- # print STDERR "MAPSRV\n";  
- } elsif ( m/ ^http:\ /\ /([A-Za-z]*?)-(.*?)\.(.*)\.youtube\.com\ /get_video\?video_id=([^&]+).* /) {  
- print "http://video-srv.youtube.com.SQUIDINTERNAL/get_video?video_id=" . $4 . "\n";  
- $fh->print("http ://video-srv.youtube.com.SQUIDINTERNAL/get_video?video_id=" . $4 . "\n");  
- $fh->flush();  
- } elsif ( m/ ^http:\ /\ /([A-Za-z]*?)-(.*?)\.(.*)\.youtube\.com\ /get_video\?video_id=(.*) /) {  
- # http://lax-v290.lax.youtube.com/get_video ?video_id=jqx1ZmzX0k0  
- print "http://video-srv.youtube.com.SQUIDINTERNAL/get_video?video_id=" . $4 . "\n";  
- } else {  
- print $_ . "\n" ;  
- }  
- }  
+while (<>) {  
+ chomp;  
+ my $out =  
+ m{ kh(.*?)\.google\.com(.*?)/(.*?) } ? "http://keyhole-srv.google.com$2.SQUIDINTERNAL/$3" :  
+ m{ mt(.*?)\.google\.com(.*?)/(.*?) } ? "http://map-srv.google.com$2.SQUIDINTERNAL/$3" :  
+ m{ ^http://([A-Za-z]*?)-(.*?)\.(.*)\.youtube\.com/get_video\?video_id=([^&]+).* }  
+ ? "http://video-srv.youtube.com.SQUIDINTERNAL/get_video?video_id=$4" :  
+ m{ ^http://([A-Za-z]*?)-(.*?)\.(.*)\.youtube\.com/get_video\?video_id=(.*) }  
+ ? "http://video-srv.youtube.com.SQUIDINTERNAL/get_video?video_id=$4" :  
+ $_; 
  
-</pre
+ print $logfh "Original: $_\n", "Translation: $out\n\n";  
+ print "$out\n";  
+}  
+ </verbatim