]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
patch from RocketGuy for pqrcon command, to administrate proquake
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 11 Jun 2009 02:08:32 +0000 (02:08 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 11 Jun 2009 02:08:32 +0000 (02:08 +0000)
servers

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9015 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c
netconn.c
netconn.h

index 1d474610ce6e3c5d0c3f5fe5ab0a1380ee9c8286..cdda57cc6f43b1f2464cee6cb203f537cda91e88 100644 (file)
@@ -2347,6 +2347,63 @@ static void MaxPlayers_f(void)
                Cvar_Set ("deathmatch", "1");
 }
 
+/*
+=====================
+Host_PQRcon_f
+
+ProQuake rcon support
+=====================
+*/
+void Host_PQRcon_f (void)
+{
+       int i;
+       lhnetaddress_t to;
+       lhnetsocket_t *mysocket;
+       char peer_address[64];
+
+       if (!rcon_password.string || !rcon_password.string[0])
+       {
+               Con_Printf ("You must set rcon_password before issuing an rcon command.\n");
+               return;
+       }
+
+       for (i = 0;rcon_password.string[i];i++)
+       {
+               if (ISWHITESPACE(rcon_password.string[i]))
+               {
+                       Con_Printf("rcon_password is not allowed to have any whitespace.\n");
+                       return;
+               }
+       }
+
+       if (cls.netcon)
+       {
+               InfoString_GetValue(cls.userinfo, "*ip", peer_address, sizeof(peer_address));
+       }
+       else
+       {
+               if (!rcon_address.string[0])
+               {
+                       Con_Printf ("You must either be connected, or set the rcon_address cvar to issue rcon commands\n");
+                       return;
+               }
+               strlcpy(peer_address, rcon_address.string, strlen(rcon_address.string)+1);
+       }
+       LHNETADDRESS_FromString(&to, peer_address, sv_netport.integer);
+       mysocket = NetConn_ChooseClientSocketForAddress(&to);
+       if (mysocket)
+       {
+               SZ_Clear(&net_message);
+               MSG_WriteLong (&net_message, 0);
+               MSG_WriteByte (&net_message, CCREQ_RCON);
+               MSG_WriteString (&net_message, rcon_password.string);
+               MSG_WriteString (&net_message, Cmd_Args());
+               *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
+               NetConn_Write(mysocket, net_message.data, net_message.cursize, &to);
+               SZ_Clear (&net_message);
+       }
+}
+
 //=============================================================================
 
 // QuakeWorld commands
@@ -2792,6 +2849,7 @@ void Host_InitCommands (void)
        Cvar_RegisterVariable (&rcon_secure);
        Cmd_AddCommand ("rcon", Host_Rcon_f, "sends a command to the server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's); note: if rcon_secure is set, client and server clocks must be synced e.g. via NTP");
        Cmd_AddCommand ("srcon", Host_Rcon_f, "sends a command to the server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's); this always works as if rcon_secure is set; note: client and server clocks must be synced e.g. via NTP");
+       Cmd_AddCommand ("pqrcon", Host_PQRcon_f, "sends a command to a proquake server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's)");
        Cmd_AddCommand ("user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
        Cmd_AddCommand ("users", Host_Users_f, "prints additional information about all players on the scoreboard");
        Cmd_AddCommand ("fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string");
index 2bc262fa8060390ab9cfd37f12247c5510e8d5a2..fc2b34c320f6b368047fe5f4fb584bc312cdd69b 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -1851,6 +1851,12 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
 
                        NetConn_ClientParsePacket_ServerList_UpdateCache(n);
 
+                       break;
+               case CCREP_RCON: // RocketGuy: ProQuake rcon support
+                       if (developer.integer >= 10)
+                               Con_Printf("Datagram_ParseConnectionless: received CCREP_RCON from %s.\n", addressstring2);
+
+                       Con_Printf("%s\n", MSG_ReadString());
                        break;
                case CCREP_PLAYER_INFO:
                        // we got a CCREP_PLAYER_INFO??
index aacbcd7ec59a8042d7663f4c8755be881892e629..29670ccb6cc4a43c5f962a55b4b0bd69d5e1a0eb 100755 (executable)
--- a/netconn.h
+++ b/netconn.h
@@ -62,6 +62,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // CCREQ_RULE_INFO
 //             string  rule
 //
+// CCREQ_RCON
+//             string  password
+//             string  command
+//
 //
 //
 // CCREP_ACCEPT
@@ -89,6 +93,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // CCREP_RULE_INFO
 //             string  rule
 //             string  value
+//
+// CCREP_RCON
+//             string  reply
 
 //     note:
 //             There are two address forms used above.  The short form is just a
@@ -104,12 +111,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define CCREQ_SERVER_INFO      0x02
 #define CCREQ_PLAYER_INFO      0x03
 #define CCREQ_RULE_INFO                0x04
+#define CCREQ_RCON             0x05 // RocketGuy: ProQuake rcon support
 
 #define CCREP_ACCEPT           0x81
 #define CCREP_REJECT           0x82
 #define CCREP_SERVER_INFO      0x83
 #define CCREP_PLAYER_INFO      0x84
 #define CCREP_RULE_INFO                0x85
+#define CCREP_RCON             0x86 // RocketGuy: ProQuake rcon support
 
 typedef struct netconn_s
 {