If you want to host a Ran server behind a router or VPN and don't want to use an IP interceptor, here's what you need to edit in the source. This feature works best for VPN services with Port Forwarding features.
Requirements:
- Knowledge with C++
- knowledge on Port Forwarding
Files that need to be edited:
s_CCfg.h
Find the line:
Replace with:
Add this:
s_CCfg.cpp
add on method SetDefault(void)
Add this on Process(TCHAR * szLine)
Add at the end of s_CCfg.cpp:
s_CAgentServerMsg.cpp
s_LoginServerSession.cpp
s_CFieldServerSession.cpp
s_CAgentServerSession.cpp
How to implement on your server:
1. Forward all your LoginServer, FieldServer, AgentServer ports (assuming you have your session server set to localhost)
2. Set your LAN IP as your "server_ip" in the CFGs for Login, Field, and Agent (The same as what you would do if you were to use an IP interceptor).
3. Add this to your LoginServer.cfg, FieldServer.cfg, AgentServer.cfg:
Disclaimer: I have only tested this in a hurry. Use at your own risk
Requirements:
- Knowledge with C++
- knowledge on Port Forwarding
Files that need to be edited:
s_CCfg.h
Find the line:
Code:
TCHAR* GetSessionServerIP(void);
int GetSessionServerPort(void);
Replace with:
Code:
TCHAR* GetSessionServerIP(void);
int GetSessionServerPort(void);
const TCHAR* GetProxyIp(const TCHAR* szDefaultVal);
Add this:
Code:
private:
bool m_bUseProxyIp;
TCHAR m_szProxyIp[MAX_IP_LENGTH+1];
s_CCfg.cpp
add on method SetDefault(void)
Code:
m_bUseProxyIp = false;
Add this on Process(TCHAR * szLine)
Code:
else if (_tcscmp(token, "use_ip_proxy") == 0)
{
token = ::_tcstok(NULL, seps);
if (token)
{
if (::_tstoi(token)) m_bUseProxyIp = true;
else m_bUseProxyIp = false;
}
else
return 0;
}
else if (_tcscmp(token, "ip_proxy") == 0)
{
// ip_proxy [ip here]
token = ::_tcstok(NULL, seps);
if (token)
::StringCchCopy(m_szProxyIp, MAX_IP_LENGTH + 1, token);
else
return 0;
}
Add at the end of s_CCfg.cpp:
Code:
const TCHAR* CCfg::GetProxyIp(const TCHAR* szDefaultValue)
{
if (m_bUseProxyIp)
return m_szProxyIp;
else
return szDefaultValue;
}
s_CAgentServerMsg.cpp
Code:
int CAgentServer::MsgLobbyCharJoinField(MSG_LIST* pMsg)
{
if (pMsg == NULL) return NET_ERROR;
DWORD dwClient = pMsg->dwClient - (DWORD) m_nMaxClient;
NET_GAME_JOIN_FIELDSVR_FB* pMsgJoinFB = (NET_GAME_JOIN_FIELDSVR_FB*) pMsg->Buffer;
if (pMsgJoinFB == NULL) return NET_ERROR;
int nChannel = m_pClientManager->GetChannel(dwClient);
F_SERVER_INFO* pField = CCfg::GetInstance()->GetFieldServer ( (int) pMsgJoinFB->dwFieldSVR, nChannel );
// Check GaeaID
if ( pMsgJoinFB->dwGaeaID != m_pClientManager->GetGaeaID(dwClient) ) return NET_ERROR;
m_pClientManager->SetSlotFieldAgent ( dwClient, pMsgJoinFB->dwSlotFieldAgent );
NET_CONNECT_CLIENT_TO_FIELD MsgConnect;
MsgConnect.dwGaeaID = m_pClientManager->GetGaeaID(dwClient);
MsgConnect.dwSlotFieldAgent = m_pClientManager->GetSlotFieldAgent(dwClient);
MsgConnect.emType = pMsgJoinFB->emType;
[COLOR=#ff0000]::StringCchCopy( MsgConnect.szServerIP, MAX_IP_LENGTH+1, CCfg::GetInstance()->GetProxyIp(pField->szServerIP) );[/COLOR]
MsgConnect.nServicePort = pField->nServicePort;
// m_pClientManager->GetChaNum(dwClient);
return SendClient ( dwClient, &MsgConnect );
}
s_LoginServerSession.cpp
Code:
void CLoginServer::SessionSndSvrInfo(void)
{
NET_SERVER_INFO nsi;
int nSize;
nSize = sizeof(NET_SERVER_INFO);
::memset(&nsi, 0, nSize);
nsi.nmg.dwSize = nSize;
nsi.nmg.nType = NET_MSG_SND_FULL_SVR_INFO;
nsi.gsi.nServerCurrentClient = m_pClientManager->GetCurrentClientNumber();
nsi.gsi.nServerGroup = m_nServerGroup;
nsi.gsi.nServerChannel = m_nServerChannel;
nsi.gsi.nServerMaxClient = m_pClientManager->GetMaxClient();
nsi.gsi.nServicePort = m_nPort;
nsi.gsi.nServerType = SERVER_LOGIN;
[COLOR=#ff0000]::StringCchCopy(nsi.gsi.szServerIP, MAX_IP_LENGTH+1, CCfg::GetInstance()->GetProxyIp(m_szAddress));[/COLOR]
SendSession(&nsi);
}
s_CFieldServerSession.cpp
Code:
int CFieldServer::SessionSndSvrInfo()
{
int nSize;
NET_SERVER_INFO nsi;
nSize = sizeof(NET_SERVER_INFO);
::memset(&nsi, 0, nSize);
nsi.nmg.dwSize = nSize;
nsi.nmg.nType = NET_MSG_SND_FULL_SVR_INFO;
nsi.gsi.nControlPort = CCfg::GetInstance()->GetControlPort();
nsi.gsi.nServerCurrentClient = m_pClientManager->GetCurrentClientNumber();
nsi.gsi.nServerGroup = CCfg::GetInstance()->GetServerGroup();
nsi.gsi.nServerMaxClient = CCfg::GetInstance()->GetServerMaxClient();
nsi.gsi.nServerNumber = CCfg::GetInstance()->GetServerNumber();
nsi.gsi.nServerType = CCfg::GetInstance()->GetServerType();
nsi.gsi.nServerChannel = CCfg::GetInstance()->GetServerChannel();
nsi.gsi.nServicePort = CCfg::GetInstance()->GetServicePort();
// ::memcpy(nsi.gsi.szServerIP, m_szAddress, MAX_IP_LENGTH);
[COLOR=#ff0000]StringCchCopy(nsi.gsi.szServerIP, MAX_IP_LENGTH+1, CCfg::GetInstance()->GetProxyIp(m_szAddress));[/COLOR]
if (SendSession(&nsi) == NET_ERROR)
{
CConsoleMessage::GetInstance()->Write(LOG_CONSOLE, _T("ERROR:SessionSndSvrInfo NET_ERROR"));
return NET_ERROR;
}
else
{
CConsoleMessage::GetInstance()->Write(LOG_CONSOLE, _T("INFO:SessionSndSvrInfo %s"), m_szAddress);
return NET_OK;
}
}
s_CAgentServerSession.cpp
Code:
int CAgentServer::SessionSndSvrInfo(void)
{
NET_SERVER_INFO nsi;
nsi.nmg.nType = NET_MSG_SND_FULL_SVR_INFO;
nsi.gsi.nControlPort = CCfg::GetInstance()->GetControlPort();
nsi.gsi.nServerCurrentClient = m_pClientManager->GetCurrentClientNumber();
nsi.gsi.nServerGroup = CCfg::GetInstance()->GetServerGroup();
nsi.gsi.nServerMaxClient = CCfg::GetInstance()->GetServerMaxClient();
nsi.gsi.nServerNumber = CCfg::GetInstance()->GetServerNumber();
nsi.gsi.nServerType = CCfg::GetInstance()->GetServerType();
nsi.gsi.nServicePort = CCfg::GetInstance()->GetServicePort();
nsi.gsi.nServerChannel = CCfg::GetInstance()->GetServerChannel();
nsi.gsi.nServerChannelNumber = CCfg::GetInstance()->GetServerChannelNumber();
nsi.gsi.nServerChannellMaxClient= CCfg::GetInstance()->GetServerChannelMaxClient();
// proxy address
[COLOR=#ff0000]StringCchCopy( nsi.gsi.szServerIP, MAX_IP_LENGTH+1, CCfg::GetInstance()->GetProxyIp(m_szAddress) );[/COLOR]
CConsoleMessage::GetInstance()->Write(
_T("SessionSndSvrInfo %s CH:%d"),
m_szAddress,
nsi.gsi.nServerChannelNumber );
if (SendSession(&nsi) == NET_ERROR)
{
return NET_ERROR;
}
else
{
for (int i=0; i<CCfg::GetInstance()->GetServerChannelNumber(); ++i)
{
SessionSndChannelState(i);
}
return NET_OK;
}
}
How to implement on your server:
1. Forward all your LoginServer, FieldServer, AgentServer ports (assuming you have your session server set to localhost)
2. Set your LAN IP as your "server_ip" in the CFGs for Login, Field, and Agent (The same as what you would do if you were to use an IP interceptor).
3. Add this to your LoginServer.cfg, FieldServer.cfg, AgentServer.cfg:
Code:
use_ip_proxy 1
ip_proxy [dynamic ip]
Disclaimer: I have only tested this in a hurry. Use at your own risk
Last edited: