Guest User

Untitled

a guest
Nov 5th, 2017
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.76 KB | None | 0 0
  1. --- module/vara.pl.orig 2013-11-05 15:18:21.000000000 +0900
  2. +++ module/vara.pl  2017-11-05 18:58:52.000000000 +0900
  3. @@ -7,6 +7,7 @@
  4.  
  5.  use strict;
  6.  #use warnings;
  7. +use LWP::UserAgent;
  8.  
  9.  #------------------------------------------------------------------------------------------------------------
  10.  #
  11. @@ -341,6 +342,57 @@
  12.                 $Form->Set('FROM', "</b>[´+ω+`] $host <b>$from");
  13.             }
  14.         }
  15. +      
  16. +       # VPNGate
  17. +       {
  18. +           my $interval = 600;
  19. +           my $timeout  = 10;
  20. +           my $retry    = 120;
  21. +          
  22. +           my $path = $Sys->Get('BBSPATH') . '/' . $Sys->Get('BBS') . '/info/vpngate.cgi';
  23. +           my $now = time;
  24. +           my @blacklist_vpn = ();
  25. +          
  26. +           if (open(my $fh, '<', $path)) {
  27. +               while (<$fh>) {
  28. +                   chomp($_);
  29. +                   push(@blacklist_vpn, $_);
  30. +               }
  31. +               close($fh);
  32. +           }
  33. +          
  34. +           if (!(-f $path) || (($now - (stat $path)[9]) > $interval)) {
  35. +               utime $now, $now, ($path);
  36. +               my $ua = LWP::UserAgent->new;
  37. +               my $url = 'http://www.vpngate.net/api/iphone/';
  38. +               $ua->timeout($timeout);
  39. +               my $resp = $ua->get($url);
  40. +               if ($resp->is_success) {
  41. +                   my $data = $resp->content;
  42. +                   my @blacklist_vpn_new = ();
  43. +                   while ($data =~ /,(([0-9]{1,3}\.){3}[0-9]{1,3}),/g) {
  44. +                       if (!grep {$_ eq $1} @blacklist_vpn) {
  45. +                           push(@blacklist_vpn_new, $1);
  46. +                       }
  47. +                   }
  48. +                   if (@blacklist_vpn_new && open(my $fh, '>>', $path)) {
  49. +                       flock($fh, 2);
  50. +                       seek($fh, 0, 2);
  51. +                       binmode($fh);
  52. +                       print $fh join("\n", @blacklist_vpn_new) . "\n";
  53. +                       close($fh);
  54. +                   }
  55. +                   push(@blacklist_vpn, @blacklist_vpn_new);
  56. +               }
  57. +               else {
  58. +                   utime $now, $now-$retry, ($path);
  59. +               }
  60. +           }
  61. +          
  62. +           if (grep {$_ eq $addr} @blacklist_vpn) {
  63. +               return $ZP::E_REG_NGUSER;
  64. +           }
  65. +       }
  66.     }
  67.    
  68.     # pluginに渡す値を設定
Advertisement
Add Comment
Please, Sign In to add comment