-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: urcd
action: commit
revision:
path_from:
revision_from: 60fe2cd579c4203b2c1d52384d127f772bc5a2be:
path_to:
revision_to:

git.thebackupbox.net

urcd

git://git.thebackupbox.net/urcd

commit 60fe2cd579c4203b2c1d52384d127f772bc5a2be
Author: root <root@d3v11.ano>
Date:   Sun Apr 14 21:40:44 2013 +0000

    [urccache.c] timing algorithm

diff --git a/src/urccache.c b/src/urccache.c

index 0db90e87a486a9c0401577211f01306cf374b3ba..

index ..3eeae462b31c2198ea5d898466c4086836aba412 100644

--- a/src/urccache.c
+++ b/src/urccache.c
@@ -4,6 +4,7 @@
 #include <nacl/randombytes.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#include <strings.h>
 #include <stdlib.h>
 #include <string.h>
 #include <taia.h>
@@ -44,12 +45,16 @@ main(int argc, char **argv)
   struct passwd *urcd = getpwnam("urcd");
   if ((!urcd) || ((chroot(argv[1])) || (setgid(urcd->pw_gid)) || (setuid(urcd->pw_uid)))) exit(64);

+  unsigned long timecached = time((long *) 0);
   unsigned char cache[256][32768]={0};
   unsigned char buffer[16+8+65536+32];
   unsigned char taia0[16];
   unsigned char taia1[16];
   unsigned char hash[32];
+  float cached[256];
+  bzero(cached,256);
   int i, n, l;
+  float f;

   while (1)
   {
@@ -105,7 +110,15 @@ main(int argc, char **argv)
     memcpy(cache[hash[0]]+32768-32,hash,32);

     if (write(1,"\0",1)<1) exit(6);
-    usleep(250000);
+
+    if (cached[hash[0]] == 1024.0) cached[hash[0]] = 0.0;
+    if (time((long *) 0) - timecached >= 128)
+    {
+      timecached = time((long *) 0);
+      bzero(cached,256);
+    } ++cached[hash[0]];
+
+    usleep((int) (cached[hash[0]] / 1024.0 * 250000.0));

   }

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 18:06:51 2024