Compare commits
4 Commits
0.3.1
...
armhf-test
Author | SHA1 | Date | |
---|---|---|---|
41f0df9572 | |||
7b39087fa7 | |||
db4542dd7a | |||
0f259307df |
6
.idea/encodings.xml
generated
Normal file
6
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="PROJECT" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
12
Dockerfile
12
Dockerfile
@ -8,14 +8,18 @@ RUN echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https:
|
|||||||
|
|
||||||
# Update the system and install various dependencies
|
# Update the system and install various dependencies
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y git cmake ninja-build build-essential tar curl zip unzip pkg-config autoconf python3 \
|
apt-get install -y git cmake ninja-build clang tar curl zip unzip pkg-config autoconf python3 \
|
||||||
libdevil-dev libncurses5-dev libbsd-dev
|
libdevil-dev libncurses5-dev libbsd-dev
|
||||||
|
|
||||||
# Arm specific
|
# Arm specific
|
||||||
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
|
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
|
||||||
|
|
||||||
|
# Set clang as default compiler
|
||||||
|
RUN update-alternatives --set cc /usr/bin/clang
|
||||||
|
RUN update-alternatives --set c++ /usr/bin/clang++
|
||||||
|
|
||||||
# Install vcpkg and the required libraries
|
# Install vcpkg and the required libraries
|
||||||
RUN git clone https://github.com/Microsoft/vcpkg.git
|
RUN git clone --depth 1 https://github.com/Microsoft/vcpkg.git
|
||||||
RUN bash ./vcpkg/bootstrap-vcpkg.sh
|
RUN bash ./vcpkg/bootstrap-vcpkg.sh
|
||||||
RUN ./vcpkg/vcpkg install cryptopp effolkronium-random libmariadb libevent lzo fmt spdlog argon2
|
RUN ./vcpkg/vcpkg install cryptopp effolkronium-random libmariadb libevent lzo fmt spdlog argon2
|
||||||
|
|
||||||
@ -23,13 +27,13 @@ COPY . .
|
|||||||
|
|
||||||
# Build the binaries
|
# Build the binaries
|
||||||
RUN mkdir build/
|
RUN mkdir build/
|
||||||
RUN cd build && cmake -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake ..
|
RUN cd build && cmake -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
RUN cd build && make -j $(nproc)
|
RUN cd build && make -j $(nproc)
|
||||||
|
|
||||||
FROM ubuntu:22.04 AS app
|
FROM ubuntu:22.04 AS app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y gettext python2 libdevil-dev libbsd-dev && apt-get clean
|
RUN apt-get update && apt-get install -y gettext python2 libdevil1c2 libbsd0 && apt-get clean
|
||||||
|
|
||||||
# Copy the binaries from the build stage
|
# Copy the binaries from the build stage
|
||||||
COPY --from=build /app/build/src/db/db /bin/db
|
COPY --from=build /app/build/src/db/db /bin/db
|
||||||
|
@ -735,10 +735,11 @@ typedef struct SEmpireSelectPacket
|
|||||||
|
|
||||||
typedef struct SPacketGDSetup
|
typedef struct SPacketGDSetup
|
||||||
{
|
{
|
||||||
char szPublicIP[16]; // Public IP which listen to users
|
BYTE bChannel;
|
||||||
BYTE bChannel; // 채널
|
char szPublicIP[16]; // Public IP which clients connect to
|
||||||
WORD wListenPort; // 클라이언트가 접속하는 포트 번호
|
WORD wListenPort; // Port number which clients connect to
|
||||||
WORD wP2PPort; // 서버끼리 연결 시키는 P2P 포트 번호
|
char szInternalIP[16]; // Internal IP which other servers connect to
|
||||||
|
WORD wP2PPort; // Port number which other servers connect to
|
||||||
LONG alMaps[MAP_ALLOW_MAX_LEN];
|
LONG alMaps[MAP_ALLOW_MAX_LEN];
|
||||||
DWORD dwLoginCount;
|
DWORD dwLoginCount;
|
||||||
BYTE bAuthServer;
|
BYTE bAuthServer;
|
||||||
|
@ -1145,9 +1145,10 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peer->SetChannel(p->bChannel);
|
||||||
peer->SetPublicIP(p->szPublicIP);
|
peer->SetPublicIP(p->szPublicIP);
|
||||||
peer->SetChannel(p->bChannel);
|
|
||||||
peer->SetListenPort(p->wListenPort);
|
peer->SetListenPort(p->wListenPort);
|
||||||
|
peer->SetInternalIP(p->szInternalIP);
|
||||||
peer->SetP2PPort(p->wP2PPort);
|
peer->SetP2PPort(p->wP2PPort);
|
||||||
peer->SetMaps(p->alMaps);
|
peer->SetMaps(p->alMaps);
|
||||||
|
|
||||||
@ -1264,9 +1265,9 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
|
|||||||
SPDLOG_DEBUG("SETUP: channel {} listen {} p2p {} count {}", peer->GetChannel(), p->wListenPort, p->wP2PPort, bMapCount);
|
SPDLOG_DEBUG("SETUP: channel {} listen {} p2p {} count {}", peer->GetChannel(), p->wListenPort, p->wP2PPort, bMapCount);
|
||||||
|
|
||||||
TPacketDGP2P p2pSetupPacket;
|
TPacketDGP2P p2pSetupPacket;
|
||||||
p2pSetupPacket.wPort = peer->GetP2PPort();
|
|
||||||
p2pSetupPacket.bChannel = peer->GetChannel();
|
p2pSetupPacket.bChannel = peer->GetChannel();
|
||||||
strlcpy(p2pSetupPacket.szHost, peer->GetPublicIP(), sizeof(p2pSetupPacket.szHost));
|
strlcpy(p2pSetupPacket.szHost, peer->GetInternalIP(), sizeof(p2pSetupPacket.szHost));
|
||||||
|
p2pSetupPacket.wPort = peer->GetP2PPort();
|
||||||
|
|
||||||
for (itertype(m_peerList) i = m_peerList.begin(); i != m_peerList.end();++i)
|
for (itertype(m_peerList) i = m_peerList.begin(); i != m_peerList.end();++i)
|
||||||
{
|
{
|
||||||
|
@ -38,15 +38,18 @@ class CPeer : public CPeerBase
|
|||||||
DWORD GetUserCount();
|
DWORD GetUserCount();
|
||||||
void SetUserCount(DWORD dwCount);
|
void SetUserCount(DWORD dwCount);
|
||||||
|
|
||||||
void SetPublicIP(const char * ip) { m_stPublicIP = ip; }
|
|
||||||
const char * GetPublicIP() { return m_stPublicIP.c_str(); }
|
|
||||||
|
|
||||||
void SetChannel(BYTE bChannel) { m_bChannel = bChannel; }
|
void SetChannel(BYTE bChannel) { m_bChannel = bChannel; }
|
||||||
BYTE GetChannel() { return m_bChannel; }
|
BYTE GetChannel() { return m_bChannel; }
|
||||||
|
|
||||||
|
void SetPublicIP(const char * ip) { m_stPublicIP = ip; }
|
||||||
|
const char * GetPublicIP() { return m_stPublicIP.c_str(); }
|
||||||
|
|
||||||
void SetListenPort(WORD wPort) { m_wListenPort = wPort; }
|
void SetListenPort(WORD wPort) { m_wListenPort = wPort; }
|
||||||
WORD GetListenPort() { return m_wListenPort; }
|
WORD GetListenPort() { return m_wListenPort; }
|
||||||
|
|
||||||
|
void SetInternalIP(const char * ip) { m_stInternalIP = ip; }
|
||||||
|
const char * GetInternalIP() { return m_stInternalIP.c_str(); }
|
||||||
|
|
||||||
void SetP2PPort(WORD wPort);
|
void SetP2PPort(WORD wPort);
|
||||||
WORD GetP2PPort() { return m_wP2PPort; }
|
WORD GetP2PPort() { return m_wP2PPort; }
|
||||||
|
|
||||||
@ -72,6 +75,7 @@ class CPeer : public CPeerBase
|
|||||||
TItemIDRangeTable m_itemSpareRange;
|
TItemIDRangeTable m_itemSpareRange;
|
||||||
|
|
||||||
std::string m_stPublicIP;
|
std::string m_stPublicIP;
|
||||||
|
std::string m_stInternalIP;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,12 +21,12 @@
|
|||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
// Networking
|
// Networking
|
||||||
char g_szPublicBindIP[16] = "0.0.0.0";
|
string g_szPublicBindIP = "0.0.0.0";
|
||||||
char g_szPublicIP[16] = "0";
|
string g_szPublicIP;
|
||||||
WORD mother_port = 50080;
|
WORD mother_port = 50080;
|
||||||
|
|
||||||
char g_szInternalBindIP[16] = "0.0.0.0";
|
string g_szInternalBindIP = "0.0.0.0";
|
||||||
char g_szInternalIP[16] = "0";
|
string g_szInternalIP;
|
||||||
WORD p2p_port = 50900;
|
WORD p2p_port = 50900;
|
||||||
|
|
||||||
char db_addr[ADDRESS_MAX_LEN + 1];
|
char db_addr[ADDRESS_MAX_LEN + 1];
|
||||||
@ -263,16 +263,16 @@ bool GetIPInfo()
|
|||||||
sai->sin_addr.s_addr == 16777343) // ignore if address is 127.0.0.1
|
sai->sin_addr.s_addr == 16777343) // ignore if address is 127.0.0.1
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (IsPrivateIP(sai->sin_addr) && g_szInternalIP[0] == '0')
|
if (IsPrivateIP(sai->sin_addr) && g_szInternalIP.empty())
|
||||||
{
|
{
|
||||||
char * ip = inet_ntoa(sai->sin_addr);
|
char * ip = inet_ntoa(sai->sin_addr);
|
||||||
strlcpy(g_szInternalIP, ip, sizeof(g_szInternalIP));
|
g_szInternalIP = string(ip);
|
||||||
SPDLOG_WARN("Internal IP automatically configured: {} interface {}", ip, ifap->ifa_name);
|
SPDLOG_WARN("Internal IP automatically configured: {} interface {}", ip, ifap->ifa_name);
|
||||||
}
|
}
|
||||||
else if (g_szPublicIP[0] == '0')
|
else if (g_szPublicIP.empty())
|
||||||
{
|
{
|
||||||
char * ip = inet_ntoa(sai->sin_addr);
|
char * ip = inet_ntoa(sai->sin_addr);
|
||||||
strlcpy(g_szPublicIP, ip, sizeof(g_szPublicIP));
|
g_szPublicIP = string(ip);
|
||||||
SPDLOG_WARN("Public IP automatically configured: {} interface {}", ip, ifap->ifa_name);
|
SPDLOG_WARN("Public IP automatically configured: {} interface {}", ip, ifap->ifa_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,6 +355,10 @@ void config_init(const string& st_localeServiceName)
|
|||||||
{
|
{
|
||||||
parse_token(buf, token_string, value_string);
|
parse_token(buf, token_string, value_string);
|
||||||
|
|
||||||
|
// If the configuration string is empty, ignore this line
|
||||||
|
if (strcmp(value_string, "") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
TOKEN("BLOCK_LOGIN")
|
TOKEN("BLOCK_LOGIN")
|
||||||
{
|
{
|
||||||
g_stBlockDate = value_string;
|
g_stBlockDate = value_string;
|
||||||
@ -662,6 +666,10 @@ void config_init(const string& st_localeServiceName)
|
|||||||
{
|
{
|
||||||
parse_token(buf, token_string, value_string);
|
parse_token(buf, token_string, value_string);
|
||||||
|
|
||||||
|
// If the configuration string is empty, ignore this line
|
||||||
|
if (strcmp(value_string, "") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
TOKEN("empire_whisper")
|
TOKEN("empire_whisper")
|
||||||
{
|
{
|
||||||
bool b_value = 0;
|
bool b_value = 0;
|
||||||
@ -699,13 +707,14 @@ void config_init(const string& st_localeServiceName)
|
|||||||
|
|
||||||
TOKEN("public_ip")
|
TOKEN("public_ip")
|
||||||
{
|
{
|
||||||
strlcpy(g_szPublicIP, value_string, sizeof(g_szPublicIP));
|
g_szPublicIP = string(value_string);
|
||||||
|
SPDLOG_INFO("Setting public IP address to '{}'...", g_szPublicIP);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TOKEN("public_bind_ip")
|
TOKEN("public_bind_ip")
|
||||||
{
|
{
|
||||||
strlcpy(g_szPublicBindIP, value_string, sizeof(g_szPublicBindIP));
|
g_szPublicBindIP = string(value_string);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -717,13 +726,14 @@ void config_init(const string& st_localeServiceName)
|
|||||||
|
|
||||||
TOKEN("internal_ip")
|
TOKEN("internal_ip")
|
||||||
{
|
{
|
||||||
strlcpy(g_szInternalIP, value_string, sizeof(g_szInternalIP));
|
g_szInternalIP = string(value_string);
|
||||||
|
SPDLOG_INFO("Setting internal IP address to '{}'...", g_szInternalIP);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TOKEN("internal_bind_ip")
|
TOKEN("internal_bind_ip")
|
||||||
{
|
{
|
||||||
strlcpy(g_szInternalBindIP, value_string, sizeof(g_szInternalBindIP));
|
g_szInternalBindIP = string(value_string);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ enum
|
|||||||
|
|
||||||
void config_init(const std::string& st_localeServiceName); // default "" is CONFIG
|
void config_init(const std::string& st_localeServiceName); // default "" is CONFIG
|
||||||
|
|
||||||
extern char g_szPublicBindIP[16];
|
extern std::string g_szPublicBindIP;
|
||||||
extern char g_szPublicIP[16];
|
extern std::string g_szPublicIP;
|
||||||
extern WORD mother_port;
|
extern WORD mother_port;
|
||||||
|
|
||||||
extern char g_szInternalBindIP[16];
|
extern std::string g_szInternalBindIP;
|
||||||
extern char g_szInternalIP[16];
|
extern std::string g_szInternalIP;
|
||||||
extern WORD p2p_port;
|
extern WORD p2p_port;
|
||||||
|
|
||||||
extern char db_addr[ADDRESS_MAX_LEN + 1];
|
extern char db_addr[ADDRESS_MAX_LEN + 1];
|
||||||
|
@ -158,7 +158,7 @@ void CLIENT_DESC::SetPhase(int iPhase)
|
|||||||
TPacketGDBoot p;
|
TPacketGDBoot p;
|
||||||
p.dwItemIDRange[0] = 0;
|
p.dwItemIDRange[0] = 0;
|
||||||
p.dwItemIDRange[1] = 0;
|
p.dwItemIDRange[1] = 0;
|
||||||
memcpy(p.szIP, g_szPublicIP, 16);
|
memcpy(p.szIP, g_szPublicIP.c_str(), 16);
|
||||||
DBPacket(HEADER_GD_BOOT, 0, &p, sizeof(p));
|
DBPacket(HEADER_GD_BOOT, 0, &p, sizeof(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,7 +168,8 @@ void CLIENT_DESC::SetPhase(int iPhase)
|
|||||||
TPacketGDSetup p;
|
TPacketGDSetup p;
|
||||||
|
|
||||||
memset(&p, 0, sizeof(p));
|
memset(&p, 0, sizeof(p));
|
||||||
strlcpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP));
|
strlcpy(p.szPublicIP, g_szPublicIP.c_str(), sizeof(p.szPublicIP));
|
||||||
|
strlcpy(p.szInternalIP, g_szInternalIP.c_str(), sizeof(p.szInternalIP));
|
||||||
|
|
||||||
if (!g_bAuthServer)
|
if (!g_bAuthServer)
|
||||||
{
|
{
|
||||||
|
@ -1304,13 +1304,13 @@ void CInputDB::P2P(const char * c_pData)
|
|||||||
extern event_base* ev_base;
|
extern event_base* ev_base;
|
||||||
extern evdns_base* dns_base;
|
extern evdns_base* dns_base;
|
||||||
|
|
||||||
TPacketDGP2P * p = (TPacketDGP2P *) c_pData;
|
auto * p = (TPacketDGP2P *) c_pData;
|
||||||
|
|
||||||
P2P_MANAGER& mgr = P2P_MANAGER::instance();
|
P2P_MANAGER& mgr = P2P_MANAGER::instance();
|
||||||
|
|
||||||
if (false == DESC_MANAGER::instance().IsP2PDescExist(p->szHost, p->wPort))
|
if (!DESC_MANAGER::instance().IsP2PDescExist(p->szHost, p->wPort))
|
||||||
{
|
{
|
||||||
LPCLIENT_DESC pkDesc = NULL;
|
LPCLIENT_DESC pkDesc = nullptr;
|
||||||
SPDLOG_DEBUG("InputDB:P2P {}:{}", p->szHost, p->wPort);
|
SPDLOG_DEBUG("InputDB:P2P {}:{}", p->szHost, p->wPort);
|
||||||
pkDesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, p->szHost, p->wPort, PHASE_P2P, false);
|
pkDesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, p->szHost, p->wPort, PHASE_P2P, false);
|
||||||
mgr.RegisterConnector(pkDesc);
|
mgr.RegisterConnector(pkDesc);
|
||||||
|
@ -513,9 +513,9 @@ int start(int argc, char **argv)
|
|||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case 'I': // IP
|
case 'I': // IP
|
||||||
strlcpy(g_szPublicIP, optarg, sizeof(g_szPublicIP));
|
g_szPublicIP = std::string(optarg);
|
||||||
|
|
||||||
printf("IP %s\n", g_szPublicIP);
|
printf("IP %s\n", g_szPublicIP.c_str());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -596,11 +596,11 @@ int start(int argc, char **argv)
|
|||||||
// Initialize the network stack
|
// Initialize the network stack
|
||||||
|
|
||||||
// Check if the public and internal IP addresses were configured
|
// Check if the public and internal IP addresses were configured
|
||||||
if (g_szInternalIP[0] == '0') {
|
if (g_szInternalIP.empty()) {
|
||||||
SPDLOG_CRITICAL("Public IP address could not be automatically detected. Manually set the IP and try again.");
|
SPDLOG_CRITICAL("Internal IP address could not be automatically detected. Manually set the IP and try again.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (g_szPublicIP[0] == '0') {
|
if (g_szPublicIP.empty()) {
|
||||||
SPDLOG_CRITICAL("Public IP address could not be automatically detected. Manually set the IP and try again.");
|
SPDLOG_CRITICAL("Public IP address could not be automatically detected. Manually set the IP and try again.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -622,7 +622,7 @@ int start(int argc, char **argv)
|
|||||||
|
|
||||||
// Main TCP listener
|
// Main TCP listener
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_addr.s_addr = inet_addr(g_szPublicBindIP);
|
sin.sin_addr.s_addr = inet_addr(g_szPublicBindIP.c_str());
|
||||||
sin.sin_port = htons(mother_port);
|
sin.sin_port = htons(mother_port);
|
||||||
|
|
||||||
tcp_listener = evconnlistener_new_bind(
|
tcp_listener = evconnlistener_new_bind(
|
||||||
@ -640,7 +640,7 @@ int start(int argc, char **argv)
|
|||||||
|
|
||||||
// Game P2P listener
|
// Game P2P listener
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_addr.s_addr = inet_addr(g_szInternalBindIP);
|
sin.sin_addr.s_addr = inet_addr(g_szInternalBindIP.c_str());
|
||||||
sin.sin_port = htons(p2p_port);
|
sin.sin_port = htons(p2p_port);
|
||||||
|
|
||||||
p2p_listener = evconnlistener_new_bind(
|
p2p_listener = evconnlistener_new_bind(
|
||||||
|
@ -32,7 +32,7 @@ class CStmt
|
|||||||
|
|
||||||
std::vector<MYSQL_BIND> m_vec_param;
|
std::vector<MYSQL_BIND> m_vec_param;
|
||||||
unsigned int m_uiParamCount;
|
unsigned int m_uiParamCount;
|
||||||
uint64_t * m_puiParamLen;
|
unsigned long * m_puiParamLen;
|
||||||
|
|
||||||
std::vector<MYSQL_BIND> m_vec_result;
|
std::vector<MYSQL_BIND> m_vec_result;
|
||||||
unsigned int m_uiResultCount;
|
unsigned int m_uiResultCount;
|
||||||
|
@ -59,7 +59,7 @@ bool CStmt::Prepare(CAsyncSQL * sql, const char * c_pszQuery)
|
|||||||
m_vec_param.resize(iParamCount);
|
m_vec_param.resize(iParamCount);
|
||||||
memset(&m_vec_param[0], 0, sizeof(MYSQL_BIND) * iParamCount);
|
memset(&m_vec_param[0], 0, sizeof(MYSQL_BIND) * iParamCount);
|
||||||
|
|
||||||
m_puiParamLen = (uint64_t *) calloc(iParamCount, sizeof(uint64_t));
|
m_puiParamLen = (unsigned long *) calloc(iParamCount, sizeof(unsigned long));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vec_result.resize(48);
|
m_vec_result.resize(48);
|
||||||
|
Reference in New Issue
Block a user