Advertisement
suprianto

patch store-idby squidlover

Oct 1st, 2014
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1.  
  2.  
  3. --- /etc/squid/store-id.pl 2014-10-01 14:22:25.215981237 +0700
  4. +++ /etc/squid/store-id-edit.pl 2014-10-01 15:19:17.000000000 +0700
  5. @@ -9,34 +9,26 @@
  6. $|=1;
  7. while (<>) {
  8. @X = split;
  9. -
  10. -if ( $X[0] =~ m/^http\:\/\/.*/) {
  11. -$x = $X[0];
  12. -$_ = $X[0];
  13. -$u = $X[0];
  14. -} else {
  15. $x = $X[1];
  16. -$_ = $X[1];
  17. -$u = $X[1];
  18. -}
  19. -
  20. +$y = $X[0] . " ";
  21. if ($x =~ m/^http(|s)\:\/\/.*youtube.*(ptracking|stream_204|player_204|gen_204).*(video_id|docid|v)\=([^\&\s]*).*/){
  22. $vid = $4 ;
  23. @cpn = m/[&?]cpn\=([^\&\s]*)/;
  24. - $fn = "/var/log/squid/@cpn";
  25. + $fn = "/tmp/@cpn";
  26. unless (-e $fn) {
  27. open FH,">".$fn ;
  28. print FH "$vid\n";
  29. close FH;
  30. }
  31. - $out = $x . "\n";
  32. + $out="ERR";
  33. +
  34.  
  35. } elsif ($x =~ m/^https?:\/\/.*(youtube|google).*videoplayback.*/){
  36. @itag = m/[&?](itag=[0-9]*)/;
  37. @ids = m/[&?]id\=([^\&\s]*)/;
  38. @mime = m/[&?](mime\=[^\&\s]*)/;
  39. @cpn = m/[&?]cpn\=([^\&\s]*)/;
  40. - $fn = "/var/log/squid/@cpn";
  41. + $fn = "/tmp/@cpn";
  42. if (-e $fn) {
  43. open FH,"<".$fn ;
  44. $id = <FH>;
  45. @@ -141,12 +133,12 @@
  46. $out="http://" . $y[0] . ".yimg.com/" . $y[1] ;
  47.  
  48. } else {
  49. - $out=$x;
  50. + $out="ERR";
  51.  
  52. }
  53. -if ( $X[0] =~ m/^http\:\/\/.*/) {
  54. - print "OK store-id=$out\n" ;
  55. +if ( $out =~ m/^https?\:\/\/.*/) {
  56. + print $y . "OK store-id=$out\n" ;
  57. } else {
  58. - print $X[0] . " OK store-id=$out\n" ;
  59. + print $y . "ERR\n" ;
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement