Server
Mt2/server/common/service.h
Adauga:
#define ENABLE_PORT_SECURITY
Server
db/src/Peerbase.cpp
Cauta
bool CPeerBase::Accept(socket_t fd_accept)
{
struct sockaddr_in peer;
if ((m_fd = socket_accept(fd_accept, &peer)) == INVALID_SOCKET)
{
Destroy();
return false;
}
Adauga:
#ifdef ENABLE_PORT_SECURITY
if (strcmp(inet_ntoa(peer.sin_addr), "127.0.0.1")) // refuse if remote host != localhost (only the same machine must be able to connect in here)
{
sys_log(0, "BLOCK CONNECTION FROM %s", inet_ntoa(peer.sin_addr));
Destroy();
return false;
}
#endif
Server
game/src/desc_p2p.cpp
Cauta:
#include "desc_p2p.h"
Adauga:
#ifdef ENABLE_PORT_SECURITY
#include "config.h"
#endif
Cauta
m_iMinInputBufferLen = 1024 * 1024;
Adauga:
#ifdef ENABLE_PORT_SECURITY
if (strcmp(host, g_szPublicIP)) // refuse if remote host != public ip (only the same machine must be able to connect in here)
{
sys_log(0, "SYSTEM: new p2p connection from [%s] to [%s] fd: %d BLOCKED", host, g_szPublicIP, m_sock);
SetPhase(PHASE_CLOSE);
return true;
}
#endif
Server
Mt2/server/input.cpp
Cauta
int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
{
if (bHeader == 10) // ??? ??
return 0;
if (bHeader == HEADER_CG_TEXT)
{
Adauga
#ifdef ENABLE_PORT_SECURITY
if (IsEmptyAdminPage() || !IsAdminPage(inet_ntoa(d->GetAddr().sin_addr))) // block if adminpage is not set or if not admin
{
sys_log(0, "SOCKET_CMD: BLOCK FROM(%s)", d->GetHostName());
return -1;
}
#endif
Done
Mt2/server/common/service.h
Adauga:
#define ENABLE_PORT_SECURITY
Server
db/src/Peerbase.cpp
Cauta
bool CPeerBase::Accept(socket_t fd_accept)
{
struct sockaddr_in peer;
if ((m_fd = socket_accept(fd_accept, &peer)) == INVALID_SOCKET)
{
Destroy();
return false;
}
Adauga:
#ifdef ENABLE_PORT_SECURITY
if (strcmp(inet_ntoa(peer.sin_addr), "127.0.0.1")) // refuse if remote host != localhost (only the same machine must be able to connect in here)
{
sys_log(0, "BLOCK CONNECTION FROM %s", inet_ntoa(peer.sin_addr));
Destroy();
return false;
}
#endif
Server
game/src/desc_p2p.cpp
Cauta:
#include "desc_p2p.h"
Adauga:
#ifdef ENABLE_PORT_SECURITY
#include "config.h"
#endif
Cauta
m_iMinInputBufferLen = 1024 * 1024;
Adauga:
#ifdef ENABLE_PORT_SECURITY
if (strcmp(host, g_szPublicIP)) // refuse if remote host != public ip (only the same machine must be able to connect in here)
{
sys_log(0, "SYSTEM: new p2p connection from [%s] to [%s] fd: %d BLOCKED", host, g_szPublicIP, m_sock);
SetPhase(PHASE_CLOSE);
return true;
}
#endif
Server
Mt2/server/input.cpp
Cauta
int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
{
if (bHeader == 10) // ??? ??
return 0;
if (bHeader == HEADER_CG_TEXT)
{
Adauga
#ifdef ENABLE_PORT_SECURITY
if (IsEmptyAdminPage() || !IsAdminPage(inet_ntoa(d->GetAddr().sin_addr))) // block if adminpage is not set or if not admin
{
sys_log(0, "SOCKET_CMD: BLOCK FROM(%s)", d->GetHostName());
return -1;
}
#endif
Done