Reduce impact of bruteforce attack on solutions

This commit is contained in:
Némunaire 2015-01-18 06:45:29 +01:00 committed by Nemunaire
commit 8601678b13
3 changed files with 29 additions and 8 deletions

View file

@ -175,12 +175,12 @@ sub manage
say "Generate team: $1";
genTeam($1, $m);
}
elsif (/^TEAM([0-9]+),([0-9]+)$/)
elsif (/^T(?:E(?:A(?:M)?)?)?([0-9]+),([0-9]+)$/)
{
say "Generate team theme: $1/$2";
genTeamTheme($1, $2, $m);
}
elsif (/^(reset)*r(e(s(e(t)?)?)?)?/)
elsif (/^(C)?(reset)*r(e(s(e(t)?)?)?)?/)
{
say "Performing RESET ...";
remove_tree($main::tmpdir);
@ -325,6 +325,14 @@ sub parse($$;$)
for my $cmd ($cmds =~ /([^:]+)/g)
{
if ($cmd =~ "^Creset")
{
if ($queue->pending() > 5) {
say $chan_output "Skip item $cmd, due to huge queue length: ".$queue->pending();
next;
}
}
my $i;
if ($cmd =~ "^(un)?freeze")
{
@ -357,12 +365,22 @@ sub parse($$;$)
# Search the right position
for ($i = 0; $i < $queue->pending(); $i++)
{
last if ($len > length($queue->peek($i)));
my $itm = $queue->peek($i);
last if ($cmd eq $itm);
last if ($len > length($itm));
}
}
say $chan_output "Inserting $cmd at position $i/".$queue->pending();
$queue->insert($i, $cmd);
$change_current = 1 if $i == 0 && $queue->pending() != 1;
if ($i < $queue->pending() && $queue->peek($i) eq $cmd)
{
say $chan_output "Skip item $cmd, already at position $i/".$queue->pending();
}
else
{
say $chan_output "Inserting $cmd at position $i/".$queue->pending();
$queue->insert($i, $cmd);
$change_current = 1 if $i == 0 && $queue->pending() != 1;
}
}
if ($change_current)
@ -948,6 +966,10 @@ Generate pages for the C<11> theme for the team C<00>.
Clean the temporary directory.
=item B<Creset>
Clean the temporary directory, only if the queue has less than 5 items.
=item B<DSYNC>
Made a full synchronization of the output directory (remove existing output dir