summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2013-03-09 10:07:45 +0100
committerYorhel <git@yorhel.nl>2013-03-09 10:07:45 +0100
commitf8b85e6d0aa29e6d670df9f19af07d4f4a6e29b2 (patch)
tree5204b264c5643b49e225b102b52d67f156c75b6e /lib/VNDB/Handler
parenta0772bdb64e779071f301315ca44857c73cdd8bb (diff)
Allow only one account registration per /48 IPv6 block per day
I think this is the only thing necessary to add full IPv6 support to VNDB. It's not actually necessary, but without this modification it will become way too easy to flood the site with new accounts.
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r--lib/VNDB/Handler/Users.pm6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index e8f9cb38..7397f43a 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -282,7 +282,11 @@ sub register {
push @{$frm->{_err}}, 'notanswer' if !$frm->{_err} && ($frm->{answer} > $num || $frm->{answer} < $num*0.995);
push @{$frm->{_err}}, 'usrexists' if $frm->{usrname} eq 'anonymous' || !$frm->{_err} && $self->dbUserGet(username => $frm->{usrname})->[0]{id};
push @{$frm->{_err}}, 'mailexists' if !$frm->{_err} && $self->dbUserGet(mail => $frm->{mail})->[0]{id};
- push @{$frm->{_err}}, 'oneaday' if !$frm->{_err} && $self->dbUserGet(ip => $self->reqIP, registered => time-24*3600)->[0]{id};
+
+ # Use /32 match for IPv4 and /48 for IPv6. The /48 is fairly broad, so some
+ # users may have to wait a bit before they can register...
+ my $ip = $self->reqIP;
+ push @{$frm->{_err}}, 'oneaday' if !$frm->{_err} && $self->dbUserGet(ip => $ip =~ /:/ ? "$ip/48" : $ip, registered => time-24*3600)->[0]{id};
if(!$frm->{_err}) {
my($token, $pass, $salt) = $self->authPrepareReset();