Advertisement
ujiajah1

rewritespeed.pl by greg vision credit by syaifudin.jw-cespun

Apr 9th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.42 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # @ http://www2.fh-lausitz.de/…/comp/misc/squid/projekt_youtube/
  3. # ketika mamam itu menimbulkan sebuah kenikmatan
  4. # disitu lapar di tiadakan
  5. # jangan lupa mamam biar ga salatri.
  6. #### var
  7. use IO::File;
  8. $|=1;
  9. STDOUT->autoflush(1);
  10. $debug=0; ## recommended:0
  11. $bypassallrules=0; ## recommended:0
  12. $sucks=""; ## unused
  13. $sucks="sucks" if ($debug>=1);
  14. $timenow="";
  15. $printtimenow=1; ## print timenow: 0|1
  16. my $logfile = '/tmp/rewrite.log';
  17.  
  18. open my $logfh, '>>', $logfile
  19. or die "Couldn't open $logfile for appending: $!\n" if $debug;
  20. $logfh->autoflush(1) if $debug;
  21.  
  22. while (<>) {
  23. $timenow=time()." " if ($printtimenow);
  24. #print $logfh "$timenow"."in : $_" if ($debug>=1);
  25. #print $logfh "in : $_" if ($debug>=1);
  26. chop; ## strip eol
  27. my $urlku = $_;
  28. #@X = split;
  29. @X = split(" ",$urlku);
  30. $a = $X[0]; ## chanel
  31. $b = $X[1]; ## url
  32. $c = $X[2]; ## ip
  33. $u = $b; ## url
  34.  
  35. print $logfh "in : $_\n" if ($debug>=1);
  36.  
  37. if ($bypassallrules){
  38. $out="$u"; ## map 1:1
  39.  
  40. } elsif ($u=~ m/^http:\/\/.*\/(speedtest\/.*)/) {
  41. $out="OK rewrite-url=http://172.16.0.2:80/$1";
  42.  
  43. } elsif ($u=~ m/^http:\/\/.*speedtest\.net\/id\/(.*)/) {
  44. $out="OK rewrite-url=http://172.16.0.2:80/speedtest/$1";
  45.  
  46. } elsif ($u=~ m/^http:\/\/.*api\.ookla\.com\/(.*)/) {
  47. $out="OK rewrite-url=http://172.16.0.2:80/speedtest/$1";
  48.  
  49. } else {
  50. $out="ERR";
  51. }
  52. print $logfh "out: $a $out\n" if ($debug>=1);
  53. print "$a $out\n";
  54. }
  55. close $logfh if ($debug);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement