always read counter.numb (for secret threaded servers)

This commit is contained in:
jake 2024-03-16 00:15:52 -04:00
parent d24d8bff7f
commit cea9c0ce5b
2 changed files with 7 additions and 1 deletions

View file

@ -1 +0,0 @@
0

View file

@ -19,6 +19,7 @@ app->hook(before_server_start => sub ($server, $app) {
});
get '/' => sub ($c) {
update_counter(); # hypnotoad or w/e may run on threads or something. awkward.
make_image(to_number_length($counter++));
$c->res->headers->header('Content-Security-Policy' => 'img-src * artemis.venus.place');
$c->res->headers->header('Server' => 'nginx/1.22.1'); # lie :)
@ -28,6 +29,12 @@ get '/' => sub ($c) {
close $fh;
};
sub update_counter () {
open my $fh, '<', $counter_file;
sysread $fh, $counter, 20;
close $fh;
}
sub to_number_length ($counter) {
while (length $counter lt 6) {
$counter = "0$counter";