Merge pull request #4056 from risostk/clean_IPV4_typo

Clean IPV4/ipv4 to IPv4, IPV6/ipv6 to IPv6
This commit is contained in:
Deve 2019-09-03 21:43:45 +02:00 committed by GitHub
commit 137e9dd99e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 50 additions and 50 deletions

View File

@ -22,7 +22,7 @@ option(SERVER_ONLY "Create a server only (i.e. no graphics or sound)" OFF)
option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF)
option(USE_SYSTEM_ENET "Use system ENet instead of the built-in version, when available." ON)
option(USE_IPV6 "Allow create or connect to game server with ipv6 address, system enet will not be used." ON)
option(USE_IPV6 "Allow create or connect to game server with IPv6 address, system enet will not be used." ON)
option(USE_SYSTEM_GLEW "Use system GLEW instead of the built-in version, when available." ON)
option(USE_SYSTEM_WIIUSE "Use system WiiUse instead of the built-in version, when available." OFF)
option(USE_SQLITE3 "Use sqlite to manage server stats and ban list." ON)

View File

@ -78,7 +78,7 @@ 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. -->
<!-- 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. -->
@ -224,9 +224,9 @@ You have the best gaming experience when choosing server having all players less
Currently STK uses sqlite (if building with sqlite3 on) for server management with the following functions at the moment:
1. Server statistics
2. IPV4 / online ID ban list
2. IPv4 / online ID ban list
3. Player reports
4. IPV4 geolocation
4. IPv4 geolocation
You need to create a database in sqlite first, run `sqlite3 stkservers.db` in the folder where (all) your server_config.xml(s) located.
@ -236,7 +236,7 @@ CREATE TABLE IF NOT EXISTS (table name above)
(
host_id INTEGER UNSIGNED NOT NULL PRIMARY KEY, -- Unique host id in STKHost of each connection session for a STKPeer
ip INTEGER UNSIGNED NOT NULL, -- IP decimal of host
ipv6 TEXT NOT NULL DEFAULT '', -- IPV6 (if exists) in string of host (only created if ipv6 server)
ipv6 TEXT NOT NULL DEFAULT '', -- IPv6 (if exists) in string of host (only created if IPv6 server)
port INTEGER UNSIGNED NOT NULL, -- Port of host
online_id INTEGER UNSIGNED NOT NULL, -- Online if of the host (0 for offline account)
username TEXT NOT NULL, -- First player name in the host (if the host has splitscreen player)
@ -273,7 +273,7 @@ CREATE TABLE IF NOT EXISTS (table name above)
If you want to see flags and readable names of countries in the above views, you need to initialize `v(server database version)_countries` table, check [this script](tools/generate-countries-table.py).
For IPV4 and online ID ban list, player reports or IP mapping, you need to create one yourself:
For IPv4 and online ID ban list, player reports or IP mapping, you need to create one yourself:
```sql
CREATE TABLE ip_ban
(
@ -302,13 +302,13 @@ CREATE TABLE player_reports
(
server_uid TEXT NOT NULL, -- Report from which server unique id (config filename)
reporter_ip INTEGER UNSIGNED NOT NULL, -- IP decimal of player who reports
reporter_ipv6 TEXT NOT NULL DEFAULT '', -- IPV6 (if exists) in string of player who reports (only needed for ipv6 server)
reporter_ipv6 TEXT NOT NULL DEFAULT '', -- IPv6 (if exists) in string of player who reports (only needed for IPv6 server)
reporter_online_id INTEGER UNSIGNED NOT NULL, -- Online id of player who reports, 0 for offline player
reporter_username TEXT NOT NULL, -- Player name who reports
reported_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time of reporting
info TEXT NOT NULL, -- Report info by reporter
reporting_ip INTEGER UNSIGNED NOT NULL, -- IP decimal of player being reported
reporting_ipv6 TEXT NOT NULL DEFAULT '', -- IPV6 (if exists) in string of player who reports (only needed for ipv6 server)
reporting_ipv6 TEXT NOT NULL DEFAULT '', -- IPv6 (if exists) in string of player who reports (only needed for IPv6 server)
reporting_online_id INTEGER UNSIGNED NOT NULL, -- Online id of player being reported, 0 for offline player
reporting_username TEXT NOT NULL -- Player name being reported
);

View File

@ -22,7 +22,7 @@
<checkbox width="fit" id="ipv6" text_align="left"/>
<spacer width="10"/>
<label proportion="1" height="100%" text_align="left"
I18N="In the server selection screen" text="Use IPV6 connection if server supports"/>
I18N="In the server selection screen" text="Use IPv6 connection if server supports"/>
</div>
</div>
</div>

View File

@ -271,7 +271,7 @@ enet_socket_create (ENetSocketType type)
if (isIPV6() && socket_fd != -1)
{
int no = 0;
// Allow ipv6 socket listen to ipv4 connection (as long as the host has ipv4 address)
// Allow IPv6 socket listen to IPv4 connection (as long as the host has IPv4 address)
int ret = setsockopt(socket_fd, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&no, sizeof(no));
if (ret != 0)
{

View File

@ -204,7 +204,7 @@ enet_socket_create (ENetSocketType type)
if (isIPV6() && socket_fd != INVALID_SOCKET)
{
int no = 0;
// Allow ipv6 socket listen to ipv4 connection (as long as the host has ipv4 address)
// Allow IPv6 socket listen to IPv4 connection (as long as the host has IPv4 address)
int ret = setsockopt(socket_fd, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&no, sizeof(no));
if (ret != 0)
{

View File

@ -612,7 +612,7 @@ void cmdLineHelp()
" --connect-now=ip Connect to a server with IP known now\n"
" (in format x.x.x.x:xxx(port)), the port should be its\n"
" public port.\n"
" --connect-now6=ip Connect to a server with IPV6 known now\n"
" --connect-now6=ip Connect to a server with IPv6 known now\n"
" (in format [x:x:x:x:x:x:x:x]:xxx(port)), the port should be its\n"
" public port.\n"
" --server-id=n Server id in stk addons for --connect-now.\n"

View File

@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Minimum code to allow iOS device to connect to ipv4 non-firewalled game server
// Minimum code to allow iOS device to connect to IPv4 non-firewalled game server
#ifdef IOS_STK
@ -266,9 +266,9 @@ namespace Mars
}
// ============================================================================
/** Return 1 if this iOS device has only IPV6 address, in this case we always
/** Return 1 if this iOS device has only IPv6 address, in this case we always
* create inet6 socket in enet and try to use the NAT64 (provided by iOS)
* to connect to ipv4 server. */
* to connect to IPv4 server. */
int isIPV6Only()
{
using namespace Mars;

View File

@ -91,7 +91,7 @@ void mainLoop(STKHost* host)
peer->kick();
// ATM use permanently ban
auto sl = LobbyProtocol::get<ServerLobby>();
// We don't support banning ipv6 address atm
// We don't support banning IPv6 address atm
if (sl && peer->getIPV6Address().empty())
sl->saveIPBanTable(peer->getAddress());
}

View File

@ -226,7 +226,7 @@ void ConnectToServer::asynchronousUpdate()
}
if (m_server->useIPV6Connection())
{
// Disable STUN if using ipv6 (check in setPublicAddress)
// Disable STUN if using IPv6 (check in setPublicAddress)
setIPV6(1);
}
if (m_server->supportsEncryption())
@ -265,10 +265,10 @@ void ConnectToServer::asynchronousUpdate()
// direct connection to server first, if failed than use the one
// that has stun mapped, the first 8 seconds allow the server to
// start the connect to peer protocol first before the port is
// remapped. IPV6 has no stun so try once with any port
// remapped. IPv6 has no stun so try once with any port
if (isIPV6())
{
if (!tryConnect(2000, 15, true/*another_port*/, true/*ipv6*/))
if (!tryConnect(2000, 15, true/*another_port*/, true/*IPv6*/))
m_state = DONE;
}
else
@ -396,7 +396,7 @@ bool ConnectToServer::tryConnect(int timeout, int retry, bool another_port,
// in iOS 9.2
if (!m_server->useIPV6Connection())
{
// From IPV4
// From IPv4
addr_string = m_server->getAddress().toString(false/*show_port*/);
}
#endif

View File

@ -227,7 +227,7 @@ void ServerLobby::initServerStatsTable()
" host_id INTEGER UNSIGNED NOT NULL PRIMARY KEY, -- Unique host id in STKHost of each connection session for a STKPeer\n"
" ip INTEGER UNSIGNED NOT NULL, -- IP decimal of host\n";
if (ServerConfig::m_ipv6_server)
oss << " ipv6 TEXT NOT NULL DEFAULT '', -- IPV6 (if exists) in string of host\n";
oss << " ipv6 TEXT NOT NULL DEFAULT '', -- IPv6 (if exists) in string of host\n";
oss << " port INTEGER UNSIGNED NOT NULL, -- Port of host\n"
" online_id INTEGER UNSIGNED NOT NULL, -- Online if of the host (0 for offline account)\n"
" username TEXT NOT NULL, -- First player name in the host (if the host has splitscreen player)\n"
@ -936,7 +936,7 @@ void ServerLobby::writePlayerReport(Event* event)
std::string query;
if (ServerConfig::m_ipv6_server)
{
// We don't save the internally mapped ipv4 (0.x.x.x)
// We don't save the internally mapped IPv4 (0.x.x.x)
query = StringUtils::insertValues(
"INSERT INTO %s "
"(server_uid, reporter_ip, reporter_ipv6, reporter_online_id, reporter_username, "
@ -1899,7 +1899,7 @@ bool ServerLobby::registerServer(bool now)
{
request->addParameter("address_ipv6",
STKHost::get()->getPublicIPV6Address());
Log::info("ServerLobby", "Public IPV6 server address %s",
Log::info("ServerLobby", "Public IPv6 server address %s",
STKHost::get()->getPublicIPV6Address().c_str());
}
if (now)
@ -3057,7 +3057,7 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
std::string query;
if (ServerConfig::m_ipv6_server && !peer->getIPV6Address().empty())
{
// We don't save the internally mapped ipv4 (0.x.x.x)
// We don't save the internally mapped IPv4 (0.x.x.x)
query = StringUtils::insertValues(
"INSERT INTO %s "
"(host_id, ip, ipv6 ,port, online_id, username, player_num, "
@ -3885,7 +3885,7 @@ void ServerLobby::testBannedForIP(STKPeer* peer) const
if (!m_db || !m_ip_ban_table_exists)
return;
// We only test for ipv4 atm
// We only test for IPv4 atm
if (!peer->getIPV6Address().empty())
return;

View File

@ -345,7 +345,7 @@ void loadServerLobbyFromConfig()
#ifdef ENABLE_IPV6
m_firewalled_server = false;
#else
Log::warn("ServerConfig", "IPV6 support not compiled.");
Log::warn("ServerConfig", "IPv6 support not compiled.");
#endif
}

View File

@ -178,9 +178,9 @@ namespace ServerConfig
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. "
"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 "
"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."));

View File

@ -370,7 +370,7 @@ void ServersManager::addAllBroadcastAddresses(const TransportAddress &a, int len
// ----------------------------------------------------------------------------
/** Updates a list of all possible broadcast addresses on this machine.
* It queries all adapters for active IPV4 interfaces, determines their
* It queries all adapters for active IPv4 interfaces, determines their
* netmask to create the broadcast addresses. It will also add 'smaller'
* broadcast addesses, e.g. in a /16 network, it will add *.*.255.255 and
* *.*.*.255, since it was sometimes observed that routers would not let

View File

@ -394,7 +394,7 @@ std::string STKHost::getIPFromStun(int socket, const std::string& stun_address,
return "";
}
// We specify ai_family, so only ipv4 or ipv6 is found
// We specify ai_family, so only IPv4 or IPv6 is found
if (res == NULL)
return "";
@ -406,7 +406,7 @@ std::string STKHost::getIPFromStun(int socket, const std::string& stun_address,
struct sockaddr_in* ipv4_addr = (struct sockaddr_in*)(res->ai_addr);
m_stun_address.setIP(ntohl(ipv4_addr->sin_addr.s_addr));
m_stun_address.setPort(ntohs(ipv4_addr->sin_port));
// Change address to ::ffff:ipv4 format for ipv6 socket
// Change address to ::ffff:IPv4 format for IPv6 socket
std::string ipv4_mapped = "::ffff:";
ipv4_mapped += m_stun_address.toString(false/*show_port*/);
freeaddrinfo(res);
@ -640,7 +640,7 @@ std::string STKHost::getIPFromStun(int socket, const std::string& stun_address,
}
if (port != m_public_address.getPort())
{
Log::error("STKHost", "IPV6 has different port than IPV4.");
Log::error("STKHost", "IPv6 has different port than IPv4.");
return "";
}
}
@ -694,9 +694,9 @@ void STKHost::setPublicAddress()
{
if (isIPV6() && NetworkConfig::get()->isClient())
{
// IPV6 client doesn't support connection to firewalled server,
// IPv6 client doesn't support connection to firewalled server,
// so no need to test STUN
Log::info("STKHost", "IPV6 only environment detected.");
Log::info("STKHost", "IPv6 only environment detected.");
m_public_address = TransportAddress("169.254.0.0:65535");
return;
}
@ -726,7 +726,7 @@ void STKHost::setPublicAddress()
Log::debug("STKHost", "Using STUN server %s", server_name.c_str());
uint64_t ping = StkTime::getMonoTimeMs();
std::string ipv4_string = getIPFromStun(
(int)m_network->getENetHost()->socket, server_name, true/*ipv4*/);
(int)m_network->getENetHost()->socket, server_name, true/*IPv4*/);
TransportAddress addr(ipv4_string);
if (!addr.isUnset())
{
@ -738,10 +738,10 @@ void STKHost::setPublicAddress()
{
m_public_ipv6_address = getIPFromStun(
(int)m_network->getENetHost()->socket, server_name,
false/*ipv4*/);
false/*IPv4*/);
if (m_public_ipv6_address.empty())
{
Log::warn("STKHost", "Failed to get public ipv6 address "
Log::warn("STKHost", "Failed to get public IPv6 address "
"for this host.");
}
}
@ -881,7 +881,7 @@ void STKHost::mainLoop()
bool socket_ipv6 = isIPV6() == 1 ? true : false;
if (socket_ipv6)
setIPV6(0);
// direct_socket use IPV4 only atm
// direct_socket use IPv4 only atm
direct_socket = new Network(1, 1, 0, 0, &eaddr);
if (socket_ipv6)
setIPV6(1);

View File

@ -134,7 +134,7 @@ private:
/** The public address found by stun (if WAN is used). */
TransportAddress m_public_address;
/** The public ipv6 address found by stun (if WAN is used). */
/** The public IPv6 address found by stun (if WAN is used). */
std::string m_public_ipv6_address;
/** The public address stun server used. */

View File

@ -227,7 +227,7 @@ std::string getIPV6ReadableFromMappedAddress(const ENetAddress* ea)
} // getIPV6ReadableFromMappedAddress
// ----------------------------------------------------------------------------
/** Add a (fake or synthesized by ios / osx) ipv4 address and map it to an ipv6
/** Add a (fake or synthesized by ios / osx) IPv4 address and map it to an IPv6
* one, used in client to set the game server address or server to initialize
* host.
*/
@ -237,8 +237,8 @@ void addMappedAddress(const ENetAddress* ea, const struct sockaddr_in6* in6)
} // addMappedAddress
// ----------------------------------------------------------------------------
/* This is called when enet needs to sent to an mapped ipv4 address, we look up
* the map here and get the real ipv6 address, so you need to call
/* This is called when enet needs to sent to an mapped IPv4 address, we look up
* the map here and get the real IPv6 address, so you need to call
* addMappedAddress above first (for client mostly).
*/
void getIPV6FromMappedAddress(const ENetAddress* ea, struct sockaddr_in6* in6)
@ -260,7 +260,7 @@ void getIPV6FromMappedAddress(const ENetAddress* ea, struct sockaddr_in6* in6)
// ----------------------------------------------------------------------------
/* This is called when enet recieved a packet from its socket, we create an
* real ipv4 address out of it or a fake one if it's from ipv6 connection.
* real IPv4 address out of it or a fake one if it's from IPv6 connection.
*/
void getMappedFromIPV6(const struct sockaddr_in6* in6, ENetAddress* ea)
{
@ -299,12 +299,12 @@ void getMappedFromIPV6(const struct sockaddr_in6* in6, ENetAddress* ea)
}
else
{
// Create a fake ipv4 address of 0.x.x.x if it's a real ipv6 connection
// Create a fake IPv4 address of 0.x.x.x if it's a real IPv6 connection
if (g_mapped_ipv6_used >= 16777215)
g_mapped_ipv6_used = 0;
TransportAddress addr(++g_mapped_ipv6_used, ntohs(in6->sin6_port));
*ea = addr.toEnetAddress();
Log::debug("IPV6", "Fake IPV4 address %s mapped to %s",
Log::debug("IPv6", "Fake IPv4 address %s mapped to %s",
addr.toString().c_str(), getIPV6ReadableFromIn6(in6).c_str());
addMappedAddress(ea, in6);
}
@ -312,7 +312,7 @@ void getMappedFromIPV6(const struct sockaddr_in6* in6, ENetAddress* ea)
// ----------------------------------------------------------------------------
/* Called when a peer is expired (no activity for 20 seconds) and we remove its
* reference to the ipv6.
* reference to the IPv6.
*/
void removeDisconnectedMappedAddress()
{
@ -321,11 +321,11 @@ void removeDisconnectedMappedAddress()
if (it->m_last_activity + 20000 < StkTime::getMonoTimeMs())
{
TransportAddress addr(it->m_addr);
Log::debug("IPV6", "Removing expired %s, ipv4 address %s.",
Log::debug("IPv6", "Removing expired %s, IPv4 address %s.",
getIPV6ReadableFromIn6(&it->m_in6).c_str(),
addr.toString().c_str());
it = g_mapped_ips.erase(it);
Log::debug("IPV6", "Mapped address size now: %d.",
Log::debug("IPv6", "Mapped address size now: %d.",
g_mapped_ips.size());
}
else

View File

@ -37,7 +37,7 @@
STKPeer::STKPeer(ENetPeer *enet_peer, STKHost* host, uint32_t host_id)
: m_peer_address(enet_peer->address), m_host(host)
{
// We use 0.x.x.x ip to map to ipv6 address internally
// We use 0.x.x.x ip to map to IPv6 address internally
if (m_peer_address.getIP() < 16777216)
m_ipv6_address = getIPV6ReadableFromMappedAddress(&enet_peer->address);
m_enet_peer = enet_peer;
@ -205,7 +205,7 @@ void STKPeer::setCrypto(std::unique_ptr<Crypto>&& c)
} // setCrypto
//-----------------------------------------------------------------------------
/* Return an IPV6 or IPV4 address, used for debug printing.
/* Return an IPv6 or IPv4 address, used for debug printing.
*/
std::string STKPeer::getRealAddress() const
{