mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Servers: Fix some code style issues in world and authserver
This commit is contained in:
@@ -61,24 +61,21 @@ void RARunnable::run()
|
||||
|
||||
ACE_Acceptor<RASocket, ACE_SOCK_ACCEPTOR> acceptor;
|
||||
|
||||
uint16 raport = uint16(sConfigMgr->GetIntDefault("Ra.Port", 3443));
|
||||
std::string stringip = sConfigMgr->GetStringDefault("Ra.IP", "0.0.0.0");
|
||||
ACE_INET_Addr listen_addr(raport, stringip.c_str());
|
||||
uint16 raPort = uint16(sConfigMgr->GetIntDefault("Ra.Port", 3443));
|
||||
std::string stringIp = sConfigMgr->GetStringDefault("Ra.IP", "0.0.0.0");
|
||||
ACE_INET_Addr listenAddress(raPort, stringIp.c_str());
|
||||
|
||||
if (acceptor.open(listen_addr, m_Reactor) == -1)
|
||||
if (acceptor.open(listenAddress, m_Reactor) == -1)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Trinity RA can not bind to port %d on %s", raport, stringip.c_str());
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Trinity RA can not bind to port %d on %s", raPort, stringIp.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
TC_LOG_INFO(LOG_FILTER_WORLDSERVER, "Starting Trinity RA on port %d on %s", raport, stringip.c_str());
|
||||
TC_LOG_INFO(LOG_FILTER_WORLDSERVER, "Starting Trinity RA on port %d on %s", raPort, stringIp.c_str());
|
||||
|
||||
while (!World::IsStopped())
|
||||
{
|
||||
// don't be too smart to move this outside the loop
|
||||
// the run_reactor_event_loop will modify interval
|
||||
ACE_Time_Value interval(0, 100000);
|
||||
if (m_Reactor->run_reactor_event_loop(interval) == -1)
|
||||
if (m_Reactor->run_reactor_event_loop(ACE_Time_Value(0, 100000)) == -1)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class RARunnable : public ACE_Based::Runnable
|
||||
public:
|
||||
RARunnable();
|
||||
virtual ~RARunnable();
|
||||
void run();
|
||||
void run() OVERRIDE;
|
||||
|
||||
private:
|
||||
ACE_Reactor* m_Reactor;
|
||||
@@ -39,4 +39,5 @@ private:
|
||||
};
|
||||
|
||||
#endif /* _TRINITY_RARUNNABLE_H_ */
|
||||
|
||||
/// @}
|
||||
|
||||
@@ -36,26 +36,22 @@ RASocket::RASocket()
|
||||
_commandExecuting = false;
|
||||
}
|
||||
|
||||
RASocket::~RASocket()
|
||||
{
|
||||
}
|
||||
|
||||
int RASocket::open(void *)
|
||||
{
|
||||
ACE_INET_Addr remote_addr;
|
||||
ACE_INET_Addr remoteAddress;
|
||||
|
||||
if (peer().get_remote_addr(remote_addr) == -1)
|
||||
if (peer().get_remote_addr(remoteAddress) == -1)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "RASocket::open: peer().get_remote_addr error is %s", ACE_OS::strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
TC_LOG_INFO(LOG_FILTER_REMOTECOMMAND, "Incoming connection from %s", remote_addr.get_host_addr());
|
||||
TC_LOG_INFO(LOG_FILTER_REMOTECOMMAND, "Incoming connection from %s", remoteAddress.get_host_addr());
|
||||
|
||||
return activate();
|
||||
}
|
||||
|
||||
int RASocket::handle_close(ACE_HANDLE, ACE_Reactor_Mask)
|
||||
int RASocket::handle_close(ACE_HANDLE /*handle*/, ACE_Reactor_Mask /*mask*/)
|
||||
{
|
||||
TC_LOG_INFO(LOG_FILTER_REMOTECOMMAND, "Closing connection");
|
||||
peer().close_reader();
|
||||
@@ -89,9 +85,7 @@ int RASocket::recv_line(ACE_Message_Block& buffer)
|
||||
ssize_t n = peer().recv(&byte, sizeof(byte));
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
@@ -110,8 +104,8 @@ int RASocket::recv_line(ACE_Message_Block& buffer)
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char null_term = '\0';
|
||||
if (buffer.copy(&null_term, sizeof(null_term)) == -1)
|
||||
const char nullTerm = '\0';
|
||||
if (buffer.copy(&nullTerm, sizeof(nullTerm)) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -31,33 +31,34 @@
|
||||
#include <ace/SOCK_Acceptor.h>
|
||||
|
||||
/// Remote Administration socket
|
||||
class RASocket: public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>
|
||||
class RASocket : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>
|
||||
{
|
||||
public:
|
||||
RASocket();
|
||||
virtual ~RASocket();
|
||||
virtual ~RASocket() { }
|
||||
|
||||
virtual int svc(void);
|
||||
virtual int open(void * = 0);
|
||||
virtual int handle_close(ACE_HANDLE = ACE_INVALID_HANDLE, ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
|
||||
virtual int svc() OVERRIDE;
|
||||
virtual int open(void* = 0) OVERRIDE;
|
||||
virtual int handle_close(ACE_HANDLE = ACE_INVALID_HANDLE, ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK) OVERRIDE;
|
||||
|
||||
private:
|
||||
int recv_line(std::string& out_line);
|
||||
int recv_line(std::string& outLine);
|
||||
int recv_line(ACE_Message_Block& buffer);
|
||||
int process_command(const std::string& command);
|
||||
int authenticate();
|
||||
int subnegotiate(); //! Used by telnet protocol RFC 854 / 855
|
||||
int subnegotiate(); ///< Used by telnet protocol RFC 854 / 855
|
||||
int check_access_level(const std::string& user);
|
||||
int check_password(const std::string& user, const std::string& pass);
|
||||
int send(const std::string& line);
|
||||
|
||||
static void zprint(void* callbackArg, const char * szText );
|
||||
static void zprint(void* callbackArg, const char* szText);
|
||||
static void commandFinished(void* callbackArg, bool success);
|
||||
|
||||
private:
|
||||
/// Minimum security level required to connect
|
||||
uint8 _minLevel;
|
||||
uint8 _minLevel; ///< Minimum security level required to connect
|
||||
ACE_Atomic_Op<ACE_Thread_Mutex, bool> _commandExecuting;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/// @}
|
||||
|
||||
Reference in New Issue
Block a user