Torque3D Documentation / _generateds / telnetConsole.h

telnetConsole.h

Engine/source/console/telnetConsole.h

More...

Classes:

class

Telnet admin console.

class

Represents a connection to the telnet console.

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _TELNETCONSOLE_H_
 25#define _TELNETCONSOLE_H_
 26
 27#ifndef _CONSOLE_H_
 28#include "console/console.h"
 29#endif
 30#include "platform/platformNet.h"
 31
 32/// Telnet admin console.
 33///
 34/// Torque supports remote access to its console. This is most useful when
 35/// running a dedicated server, as you can remotely administer the game
 36/// (for instance, kicking people). In the context of a MMORPG, this sort of
 37/// functionality would be useful for managing a server.
 38///
 39/// There are a number of products for Tribes2 which allow remote administration
 40/// via a nice GUI.
 41///
 42/// @section telnetconsole_use Using the Telnet Console
 43///
 44/// The TelnetConsole is designed to be used globally, so you don't instantiate
 45/// it like a normal class.
 46///
 47class TelnetConsole
 48{
 49   NetSocket mAcceptSocket;
 50   S32 mAcceptPort;
 51
 52   enum {
 53      PasswordMaxLength = 32  ///< Maximum length of the telnet and listen passwords.
 54   };
 55
 56   bool mRemoteEchoEnabled;
 57   char mTelnetPassword[PasswordMaxLength+1];
 58   char mListenPassword[PasswordMaxLength+1];
 59
 60   /// State of a TelnetClient.
 61   enum State
 62   {
 63      PasswordTryOne,      ///< Allow three password attempts.
 64      PasswordTryTwo,
 65      PasswordTryThree,
 66      DisconnectThisDude,  ///< If they've failed all three, disconnect them.
 67      FullAccessConnected, ///< They presented the telnetPassword, they get full access.
 68      ReadOnlyConnected    ///< They presented the listenPassword, they get read only access.
 69   };
 70
 71   /// Represents a connection to the telnet console.
 72   ///
 73   /// This is also a linked list.
 74   struct TelnetClient
 75   {
 76      NetSocket socket;
 77      char curLine[Con::MaxLineLength];
 78      S32 curPos;
 79      S32 state;                       ///< State of the client.
 80                                       ///  @see TelnetConsole::State
 81      TelnetClient *nextClient;
 82      TelnetClient() { dStrncpy(curLine, "", Con::MaxLineLength); curPos = 0; state = 0; nextClient = NULL; }
 83   };
 84   TelnetClient *mClientList;
 85   TelnetConsole();
 86   ~<a href="/coding/class/classtelnetconsole/">TelnetConsole</a>();
 87
 88public:
 89   static void create();    ///< Initialize the telnet console.
 90   static void destroy();   ///< Shut down the telnet console.
 91   void process();          ///< Called by the main loop to let the console process commands
 92                            ///  and connections.
 93
 94   /// Configure the parameter for the telnet console.
 95   ///
 96   /// @param    port           Port on which to listen for connections.
 97   /// @param    telnetPassword Password for full access to the console.
 98   /// @param    listenPassword Password for read-only access to the console.
 99   /// @param    remoteEcho     Enable/disable echoing input back to the client
100   void setTelnetParameters(S32 port, const char *telnetPassword, const char *listenPassword, bool remoteEcho = false);
101
102   /// Callback to handle a line from the console.
103   ///
104   /// @note This is used internally by the class; you
105   ///       shouldn't need to call it.
106   ///
107   /// @see Con::addConsumer()
108   void processConsoleLine(const char *line);
109};
110
111#endif
112
113