Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- module/vara.pl.orig 2013-11-05 15:18:21.000000000 +0900
- +++ module/vara.pl 2017-11-05 18:58:52.000000000 +0900
- @@ -7,6 +7,7 @@
- use strict;
- #use warnings;
- +use LWP::UserAgent;
- #------------------------------------------------------------------------------------------------------------
- #
- @@ -341,6 +342,57 @@
- $Form->Set('FROM', "</b>[´+ω+`] $host <b>$from");
- }
- }
- +
- + # VPNGate
- + {
- + my $interval = 600;
- + my $timeout = 10;
- + my $retry = 120;
- +
- + my $path = $Sys->Get('BBSPATH') . '/' . $Sys->Get('BBS') . '/info/vpngate.cgi';
- + my $now = time;
- + my @blacklist_vpn = ();
- +
- + if (open(my $fh, '<', $path)) {
- + while (<$fh>) {
- + chomp($_);
- + push(@blacklist_vpn, $_);
- + }
- + close($fh);
- + }
- +
- + if (!(-f $path) || (($now - (stat $path)[9]) > $interval)) {
- + utime $now, $now, ($path);
- + my $ua = LWP::UserAgent->new;
- + my $url = 'http://www.vpngate.net/api/iphone/';
- + $ua->timeout($timeout);
- + my $resp = $ua->get($url);
- + if ($resp->is_success) {
- + my $data = $resp->content;
- + my @blacklist_vpn_new = ();
- + while ($data =~ /,(([0-9]{1,3}\.){3}[0-9]{1,3}),/g) {
- + if (!grep {$_ eq $1} @blacklist_vpn) {
- + push(@blacklist_vpn_new, $1);
- + }
- + }
- + if (@blacklist_vpn_new && open(my $fh, '>>', $path)) {
- + flock($fh, 2);
- + seek($fh, 0, 2);
- + binmode($fh);
- + print $fh join("\n", @blacklist_vpn_new) . "\n";
- + close($fh);
- + }
- + push(@blacklist_vpn, @blacklist_vpn_new);
- + }
- + else {
- + utime $now, $now-$retry, ($path);
- + }
- + }
- +
- + if (grep {$_ eq $addr} @blacklist_vpn) {
- + return $ZP::E_REG_NGUSER;
- + }
- + }
- }
- # pluginに渡す値を設定
Advertisement
Add Comment
Please, Sign In to add comment