+ if(Cmd_Argv(0)[0] == 's' || rcon_secure.integer > 1)
+ {
+ if(cls.rcon_commands[cls.rcon_ringpos][0])
+ {
+ char s[128];
+ LHNETADDRESS_ToString(&cls.rcon_addresses[cls.rcon_ringpos], s, sizeof(s), true);
+ Con_Printf("rcon to %s (for command %s) failed: too many buffered commands (possibly increase MAX_RCONS)\n", s, cls.rcon_commands[cls.rcon_ringpos]);
+ cls.rcon_commands[cls.rcon_ringpos][0] = 0;
+ --cls.rcon_trying;
+ }
+ for (i = 0;i < MAX_RCONS;i++)
+ if(cls.rcon_commands[i][0])
+ if (!LHNETADDRESS_Compare(&to, &cls.rcon_addresses[i]))
+ break;
+ ++cls.rcon_trying;
+ if(i >= MAX_RCONS)
+ NetConn_WriteString(mysocket, "\377\377\377\377getchallenge", &to); // otherwise we'll request the challenge later
+ strlcpy(cls.rcon_commands[cls.rcon_ringpos], Cmd_Args(), sizeof(cls.rcon_commands[cls.rcon_ringpos]));
+ cls.rcon_addresses[cls.rcon_ringpos] = to;
+ cls.rcon_timeout[cls.rcon_ringpos] = realtime + rcon_secure_challengetimeout.value;
+ cls.rcon_ringpos = (cls.rcon_ringpos + 1) % MAX_RCONS;
+ }
+ else if(rcon_secure.integer > 0)
+ {
+ char buf[1500];
+ char argbuf[1500];
+ dpsnprintf(argbuf, sizeof(argbuf), "%ld.%06d %s", (long) time(NULL), (int) (rand() % 1000000), Cmd_Args());
+ memcpy(buf, "\377\377\377\377srcon HMAC-MD4 TIME ", 24);
+ if(HMAC_MDFOUR_16BYTES((unsigned char *) (buf + 24), (unsigned char *) argbuf, strlen(argbuf), (unsigned char *) rcon_password.string, n))
+ {
+ buf[40] = ' ';
+ strlcpy(buf + 41, argbuf, sizeof(buf) - 41);
+ NetConn_Write(mysocket, buf, 41 + strlen(buf + 41), &to);
+ }
+ }
+ else
+ {
+ NetConn_WriteString(mysocket, va(vabuf, sizeof(vabuf), "\377\377\377\377rcon %.*s %s", n, rcon_password.string, Cmd_Args()), &to);
+ }