Add ipv6 server configuration
This commit is contained in:
parent
3f0db672d6
commit
5cacd486da
@ -78,6 +78,9 @@ The current server configuration xml looks like this:
|
||||
<!-- Disable it to turn off all stun related code in server, it allows saving server resource if your server is not behind a firewall. -->
|
||||
<firewalled-server value="true" />
|
||||
|
||||
<!-- Enable to allow ipv6 connection if you have a public ipv6 address. STK currently use dual-stack mode which requires server to have both ipv4 and ipv6 and listen to same port, firewalled-server will be disabled so you need to make sure this server has port forward configured properly if needed. -->
|
||||
<ipv6-server value="false" />
|
||||
|
||||
<!-- No server owner in lobby which can control the starting of game or kick any players. -->
|
||||
<owner-less value="false" />
|
||||
|
||||
|
@ -340,6 +340,15 @@ void loadServerLobbyFromConfig()
|
||||
m_server_max_players > 10)
|
||||
m_server_max_players = 10;
|
||||
|
||||
if (m_ipv6_server)
|
||||
{
|
||||
#ifdef ENABLE_IPV6
|
||||
m_firewalled_server = false;
|
||||
#else
|
||||
Log::warn("ServerConfig", "IPV6 support not compiled.");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_ranked)
|
||||
{
|
||||
m_validating_player = true;
|
||||
|
@ -176,6 +176,14 @@ namespace ServerConfig
|
||||
"it allows saving server resource if your server is not "
|
||||
"behind a firewall."));
|
||||
|
||||
SERVER_CFG_PREFIX BoolServerConfigParam m_ipv6_server
|
||||
SERVER_CFG_DEFAULT(BoolServerConfigParam(false, "ipv6-server",
|
||||
"Enable to allow ipv6 connection if you have a public ipv6 address. "
|
||||
"STK currently use dual-stack mode which requires server to have both "
|
||||
"ipv4 and ipv6 and listen to same port, firewalled-server will be "
|
||||
"disabled so you need to make sure this server has port forward "
|
||||
"configured properly if needed."));
|
||||
|
||||
SERVER_CFG_PREFIX BoolServerConfigParam m_owner_less
|
||||
SERVER_CFG_DEFAULT(BoolServerConfigParam(false, "owner-less",
|
||||
"No server owner in lobby which can control the starting of game or "
|
||||
|
@ -261,6 +261,7 @@ STKHost::STKHost(bool server)
|
||||
|
||||
if (server)
|
||||
{
|
||||
setIPV6(ServerConfig::m_ipv6_server ? 1 : 0);
|
||||
addr.port = ServerConfig::m_server_port;
|
||||
if (addr.port == 0 && !UserConfigParams::m_random_server_port)
|
||||
addr.port = stk_config->m_server_port;
|
||||
@ -856,12 +857,18 @@ void STKHost::mainLoop()
|
||||
|
||||
// A separate network connection (socket) to handle LAN requests.
|
||||
Network* direct_socket = NULL;
|
||||
if (!isIPV6() && ((NetworkConfig::get()->isLAN() && is_server) ||
|
||||
NetworkConfig::get()->isPublicServer()))
|
||||
if ((NetworkConfig::get()->isLAN() && is_server) ||
|
||||
NetworkConfig::get()->isPublicServer())
|
||||
{
|
||||
TransportAddress address(0, stk_config->m_server_discovery_port);
|
||||
ENetAddress eaddr = address.toEnetAddress();
|
||||
bool socket_ipv6 = isIPV6() == 1 ? true : false;
|
||||
if (socket_ipv6)
|
||||
setIPV6(0);
|
||||
// direct_socket use IPV4 only atm
|
||||
direct_socket = new Network(1, 1, 0, 0, &eaddr);
|
||||
if (socket_ipv6)
|
||||
setIPV6(1);
|
||||
if (direct_socket->getENetHost() == NULL)
|
||||
{
|
||||
Log::warn("STKHost", "No direct socket available, this "
|
||||
|
@ -141,6 +141,11 @@ int isIPV6()
|
||||
return 0;
|
||||
} // isIPV6
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void setIPV6(int val)
|
||||
{
|
||||
} // setIPV6
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string getIPV6ReadableFromMappedAddress(const ENetAddress* ea)
|
||||
{
|
||||
@ -180,7 +185,7 @@ void unixInitialize()
|
||||
{
|
||||
// Clear previous setting, in case user changed wifi or mobile data
|
||||
g_mapped_ipv6_used = 0;
|
||||
g_ipv6 = 1;
|
||||
g_ipv6 = 0;
|
||||
g_mapped_ips.clear();
|
||||
} // unixInitialize
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user