allocate session just once
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 23 Oct 2010 16:46:55 +0000 (18:46 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 23 Oct 2010 16:46:55 +0000 (18:46 +0200)
this will prevent our denial of service against Aleph if we get
too many requests (and since it's random number, I might as well used
42 for it)

Aleph.pm

index c8e529a..6a3cf3c 100644 (file)
--- a/Aleph.pm
+++ b/Aleph.pm
@@ -59,13 +59,16 @@ sub usemap {{
 #      1016    => '',
 }};
 
+our $session_id;
 
 sub search {
        my ( $self, $query ) = @_;
 
        die "need query" unless defined $query;
 
-       my $url = 'http://161.53.240.197:8991/F?RN=' . int rand(1000000000);
+       $session_id ||= int rand(1000000000);
+       # FIXME allocate session just once
+       my $url = 'http://161.53.240.197:8991/F?RN=' . $session_id;
        # fake JavaScript code on page which creates random session
 
 diag "get $url";