589c304d7e76e316228ef5bc6dfa34d76d100aea
jcasper
  Wed May 7 09:50:30 2025 -0700
Added option to better penalize webcrawlers sharing hgsids, refs #35584

diff --git src/hg/lib/botDelay.c src/hg/lib/botDelay.c
index d99031e7197..33ae0e54437 100644
--- src/hg/lib/botDelay.c
+++ src/hg/lib/botDelay.c
@@ -95,34 +95,51 @@
 {
 char *user = NULL;
 char *centralCookie = hUserCookie();
 
 if (centralCookie)
     user = findCookieData(centralCookie);
 
 return user;
 }
 
 char *getBotCheckString(char *ip, double fraction)
 /* compose "user.ip fraction" string for bot check */
 {
 char *user = getCookieUser();
 char *botCheckString = needMem(256);
+boolean useNew = cfgOptionBooleanDefault("newBotDelay", false);
+if (useNew)
+    {
+        char *hgsid = cgiOptionalString("hgsid");
+        if (user)
+            safef(botCheckString, 256, "uid%s %f", user, fraction);
+        else
+            {
+            if (hgsid)
+                safef(botCheckString, 256, "sid%s %f", hgsid, fraction);
+            else
+                safef(botCheckString, 256, "%s %f", ip, fraction);
+            }
+    }
+else
+    {
     if (user)
       safef(botCheckString, 256, "%s.%s %f", user, ip, fraction);
     else
       safef(botCheckString, 256, "%s %f", ip, fraction);
+    }
 return botCheckString;
 }
 
 boolean botException()
 /* check if the remote ip address is on the exceptions list */
 {
 char *exceptIps = cfgOption("bottleneck.except");
 if (exceptIps)
     {
     char *remoteAddr = getenv("REMOTE_ADDR");
     if (remoteAddr)
 	{
 	char *s = exceptIps;
 	boolean found = FALSE;
 	while (s && !found)