* implemented (experimental!) remote controlling interface as requested by Coma. you can send any text to a specific port (via PHP or anything else), which will be interpreted & parsed DefScript-like.

* please report any bugs with this!
This commit is contained in:
False.Genesis 2007-06-13 11:27:43 +00:00
parent 7ffc21bec5
commit 2b40be9e01
9 changed files with 61 additions and 15 deletions

View File

@ -102,3 +102,9 @@ defaultlang=0
// the GUI is enabled and activated. (if its in background - way less CPU load.) // the GUI is enabled and activated. (if its in background - way less CPU load.)
enablegui=0 enablegui=0
// options for remote control:
// port beeing listened on. set to 0 do disable.
rmcontrolport=8101
// IP or hostname that is allowed to connect. leave blank to allow connections from everywhere (dangerous!)
rmcontrolhost=localhost

View File

@ -812,3 +812,5 @@ void DefScriptPackage::My_Run(std::string line, std::string username)
Interpret(curSet); Interpret(curSet);
} }

View File

@ -12,7 +12,7 @@
#include "WorldSession.h" #include "WorldSession.h"
#include "CacheHandler.h" #include "CacheHandler.h"
#include "GUI/PseuGUI.h" #include "GUI/PseuGUI.h"
#include "RemoteController.h"
#include "Cli.h" #include "Cli.h"
@ -53,6 +53,7 @@ PseuInstance::PseuInstance(PseuInstanceRunnable *run)
_scp=NULL; _scp=NULL;
_conf=NULL; _conf=NULL;
_cli=NULL; _cli=NULL;
_rmcontrol=NULL;
_stop=false; _stop=false;
_fastquit=false; _fastquit=false;
_startrealm=true; _startrealm=true;
@ -70,6 +71,8 @@ PseuInstance::~PseuInstance()
_cli->stop(); _cli->stop();
} }
if(_rmcontrol)
delete _rmcontrol;
if(_rsession) if(_rsession)
delete _rsession; delete _rsession;
if(_wsession) if(_wsession)
@ -166,6 +169,11 @@ bool PseuInstance::Init(void) {
logerror("GUI: incorrect settings!"); logerror("GUI: incorrect settings!");
} }
if(GetConf()->rmcontrolport)
{
_rmcontrol = new RemoteController(this,GetConf()->rmcontrolport);
}
if(GetConf()->enablecli) if(GetConf()->enablecli)
{ {
log("Starting CLI..."); log("Starting CLI...");
@ -286,6 +294,16 @@ void PseuInstance::Update()
} }
if(_rmcontrol)
{
_rmcontrol->Update();
if(_rmcontrol->MustDie())
{
delete _rmcontrol;
_rmcontrol = NULL;
}
}
GetScripts()->GetEventMgr()->Update(); GetScripts()->GetEventMgr()->Update();
this->Sleep(GetConf()->networksleeptime); this->Sleep(GetConf()->networksleeptime);
@ -338,6 +356,8 @@ void PseuInstanceConf::ApplyFromVarSet(VarSet &v)
showmyopcodes=(bool)atoi(v.Get("SHOWMYOPCODES").c_str()); showmyopcodes=(bool)atoi(v.Get("SHOWMYOPCODES").c_str());
disablespellcheck=(bool)atoi(v.Get("DISABLESPELLCHECK").c_str()); disablespellcheck=(bool)atoi(v.Get("DISABLESPELLCHECK").c_str());
enablegui=(bool)atoi(v.Get("ENABLEGUI").c_str()); enablegui=(bool)atoi(v.Get("ENABLEGUI").c_str());
rmcontrolport=atoi(v.Get("RMCONTROLPORT").c_str());
rmcontrolhost=v.Get("RMCONTROLHOST");
// clientversion is a bit more complicated to add // clientversion is a bit more complicated to add
{ {

View File

@ -15,6 +15,7 @@ class WorldSession;
class Sockethandler; class Sockethandler;
class PseuInstanceRunnable; class PseuInstanceRunnable;
class CliRunnable; class CliRunnable;
class RemoteController;
class PseuInstanceConf class PseuInstanceConf
{ {
@ -49,6 +50,8 @@ class PseuInstanceConf
bool notifyping; bool notifyping;
bool showmyopcodes; bool showmyopcodes;
bool disablespellcheck; bool disablespellcheck;
uint32 rmcontrolport;
std::string rmcontrolhost;
// gui related // gui related
bool enablegui; bool enablegui;
@ -109,6 +112,7 @@ class PseuInstance
SocketHandler _sh; SocketHandler _sh;
CliRunnable *_cli; CliRunnable *_cli;
ZThread::Thread _clithread; ZThread::Thread _clithread;
RemoteController *_rmcontrol;
}; };

View File

@ -243,6 +243,11 @@ void RealmSession::_HandleRealmList(ByteBuffer& pkt)
void RealmSession::SendLogonChallenge(void) void RealmSession::SendLogonChallenge(void)
{ {
if(!_socket)
{
logerror("Can't send logon challenge, socket doesn't exist");
return;
}
if( GetInstance()->GetConf()->accname.empty() || GetInstance()->GetConf()->clientversion_string.empty() if( GetInstance()->GetConf()->accname.empty() || GetInstance()->GetConf()->clientversion_string.empty()
|| GetInstance()->GetConf()->clientbuild==0 || GetInstance()->GetConf()->clientlang.empty() ) || GetInstance()->GetConf()->clientbuild==0 || GetInstance()->GetConf()->clientlang.empty() )
{ {
@ -264,7 +269,7 @@ void RealmSession::SendLogonChallenge(void)
for(uint8 i=0;i<4;i++) for(uint8 i=0;i<4;i++)
packet << (uint8)(GetInstance()->GetConf()->clientlang[3-i]); // "enUS" -> "SUne" : reversed and NOT zero terminated packet << (uint8)(GetInstance()->GetConf()->clientlang[3-i]); // "enUS" -> "SUne" : reversed and NOT zero terminated
packet << (uint32)0x3c; // timezone packet << (uint32)0x3c; // timezone
packet << (uint32)_socket->GetClientRemoteAddr(); // my IP address packet << (uint32)_socket->GetMyIP(); // my IP address
packet << (uint8)acc.length(); // length of acc name without \0 packet << (uint8)acc.length(); // length of acc name without \0
packet.append(acc.c_str(),acc.length()); // append accname, skip \0 packet.append(acc.c_str(),acc.length()); // append accname, skip \0

View File

@ -3,6 +3,7 @@
#include "ByteBuffer.h" #include "ByteBuffer.h"
#include "RealmSession.h" #include "RealmSession.h"
#include "RealmSocket.h" #include "RealmSocket.h"
#include "Network/Utility.h"
@ -10,7 +11,7 @@
RealmSocket::RealmSocket(SocketHandler& h) : TcpSocket(h) RealmSocket::RealmSocket(SocketHandler& h) : TcpSocket(h)
{ {
_session = NULL; _session = NULL;
_ok = false; _ok = false;
} }
RealmSocket::~RealmSocket() RealmSocket::~RealmSocket()
@ -88,4 +89,8 @@ void RealmSocket::OnDelete(void)
_session->SetMustDie(); _session->SetMustDie();
} }
uint32 RealmSocket::GetMyIP(void)
{
return GetRemoteIP4();
}

View File

@ -14,6 +14,7 @@ public:
RealmSession *GetSession(void); RealmSession *GetSession(void);
bool IsOk(void); bool IsOk(void);
void SetSession(RealmSession*); void SetSession(RealmSession*);
uint32 GetMyIP(void);
void Update(void); void Update(void);
void SendLogonChallenge(void); void SendLogonChallenge(void);
@ -27,6 +28,7 @@ public:
int Close(void); int Close(void);
private: private:
bool _ok; bool _ok;
RealmSession *_session; RealmSession *_session;

View File

@ -162,6 +162,12 @@
<File <File
RelativePath=".\Client\Cli.h"> RelativePath=".\Client\Cli.h">
</File> </File>
<File
RelativePath=".\Client\ControlSocket.cpp">
</File>
<File
RelativePath=".\Client\ControlSocket.h">
</File>
<File <File
RelativePath=".\Client\DefScriptInterface.cpp"> RelativePath=".\Client\DefScriptInterface.cpp">
</File> </File>
@ -189,6 +195,12 @@
<File <File
RelativePath=".\Client\PseuWoW.h"> RelativePath=".\Client\PseuWoW.h">
</File> </File>
<File
RelativePath=".\Client\RemoteController.cpp">
</File>
<File
RelativePath=".\Client\RemoteController.h">
</File>
<File <File
RelativePath=".\Client\SCPDatabase.cpp"> RelativePath=".\Client\SCPDatabase.cpp">
</File> </File>

View File

@ -28,6 +28,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
RuntimeTypeInfo="FALSE"
PrecompiledHeaderFile=".\Debug/PseuWoW_Controller.pch" PrecompiledHeaderFile=".\Debug/PseuWoW_Controller.pch"
AssemblerListingLocation="$(SolutionDir)temp/$(ProjectName)/$(ConfigurationName)/" AssemblerListingLocation="$(SolutionDir)temp/$(ProjectName)/$(ConfigurationName)/"
ObjectFile="$(SolutionDir)temp/$(ProjectName)/$(ConfigurationName)/" ObjectFile="$(SolutionDir)temp/$(ProjectName)/$(ConfigurationName)/"
@ -84,6 +85,7 @@
BufferSecurityCheck="FALSE" BufferSecurityCheck="FALSE"
EnableFunctionLevelLinking="FALSE" EnableFunctionLevelLinking="FALSE"
EnableEnhancedInstructionSet="0" EnableEnhancedInstructionSet="0"
RuntimeTypeInfo="FALSE"
PrecompiledHeaderFile=".\Release/PseuWoW_Controller.pch" PrecompiledHeaderFile=".\Release/PseuWoW_Controller.pch"
AssemblerListingLocation="$(SolutionDir)temp/$(ProjectName)/$(ConfigurationName)/" AssemblerListingLocation="$(SolutionDir)temp/$(ProjectName)/$(ConfigurationName)/"
ObjectFile="$(SolutionDir)temp/$(ProjectName)/$(ConfigurationName)/" ObjectFile="$(SolutionDir)temp/$(ProjectName)/$(ConfigurationName)/"
@ -160,18 +162,6 @@
</File> </File>
<File <File
RelativePath=".\shared\Network\CircularBuffer.cpp"> RelativePath=".\shared\Network\CircularBuffer.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath=".\shared\Network\CircularBuffer.h"> RelativePath=".\shared\Network\CircularBuffer.h">