Use more real address in server
This commit is contained in:
parent
02f8f6fadd
commit
7becfb311d
@ -91,7 +91,8 @@ void mainLoop(STKHost* host)
|
||||
peer->kick();
|
||||
// ATM use permanently ban
|
||||
auto sl = LobbyProtocol::get<ServerLobby>();
|
||||
if (sl)
|
||||
// We don't support banning ipv6 address atm
|
||||
if (sl && peer->getIPV6Address().empty())
|
||||
sl->saveIPBanTable(peer->getAddress());
|
||||
}
|
||||
else
|
||||
@ -105,7 +106,7 @@ void mainLoop(STKHost* host)
|
||||
for (unsigned int i = 0; i < peers.size(); i++)
|
||||
{
|
||||
std::cout << peers[i]->getHostId() << ": " <<
|
||||
peers[i]->getAddress().toString() << " " <<
|
||||
peers[i]->getRealAddress() << " " <<
|
||||
peers[i]->getUserVersion() << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ void ProtocolManager::update(int ticks)
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
const std::string& name = (*i)->getPeer()->getAddress().toString();
|
||||
const std::string& name = (*i)->getPeer()->getRealAddress();
|
||||
Log::error("ProtocolManager",
|
||||
"Synchronous event error from %s: %s", name.c_str(), e.what());
|
||||
Log::error("ProtocolManager", (*i)->data().getLogMessage().c_str());
|
||||
@ -441,7 +441,7 @@ void ProtocolManager::asynchronousUpdate()
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
const std::string& name = (*i)->getPeer()->getAddress().toString();
|
||||
const std::string& name = (*i)->getPeer()->getRealAddress();
|
||||
Log::error("ProtocolManager", "Asynchronous event "
|
||||
"error from %s: %s", name.c_str(), e.what());
|
||||
Log::error("ProtocolManager",
|
||||
|
@ -108,7 +108,7 @@ bool GameEventsProtocol::notifyEvent(Event* event)
|
||||
if (!event->getPeer()->availableKartID(kart_id))
|
||||
{
|
||||
Log::warn("GameProtocol", "Wrong kart id %d from %s.",
|
||||
kart_id, event->getPeer()->getAddress().toString().c_str());
|
||||
kart_id, event->getPeer()->getRealAddress().c_str());
|
||||
return true;
|
||||
}
|
||||
float f = LobbyProtocol::get<ServerLobby>()
|
||||
|
@ -205,7 +205,7 @@ void GameProtocol::handleControllerAction(Event *event)
|
||||
!peer->availableKartID(kart_id))
|
||||
{
|
||||
Log::warn("GameProtocol", "Wrong kart id %d from %s.",
|
||||
kart_id, peer->getAddress().toString().c_str());
|
||||
kart_id, peer->getRealAddress().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1387,14 +1387,14 @@ void ServerLobby::liveJoinRequest(Event* event)
|
||||
for (int id : used_id)
|
||||
{
|
||||
Log::info("ServerLobby", "%s live joining with reserved kart id %d.",
|
||||
peer->getAddress().toString().c_str(), id);
|
||||
peer->getRealAddress().c_str(), id);
|
||||
peer->addAvailableKartID(id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::info("ServerLobby", "%s spectating now.",
|
||||
peer->getAddress().toString().c_str());
|
||||
peer->getRealAddress().c_str());
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<NetworkPlayerProfile> > players =
|
||||
@ -1532,7 +1532,7 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
|
||||
if (!live_joined_in_time)
|
||||
{
|
||||
Log::warn("ServerLobby", "%s can't live-join in time.",
|
||||
peer->getAddress().toString().c_str());
|
||||
peer->getRealAddress().c_str());
|
||||
rejectLiveJoin(peer.get(), BLR_NO_GAME_FOR_LIVE_JOIN);
|
||||
return;
|
||||
}
|
||||
@ -1553,12 +1553,12 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
|
||||
const RemoteKartInfo& rki = race_manager->getKartInfo(id);
|
||||
addLiveJoiningKart(id, rki, m_last_live_join_util_ticks);
|
||||
Log::info("ServerLobby", "%s succeeded live-joining with kart id %d.",
|
||||
peer->getAddress().toString().c_str(), id);
|
||||
peer->getRealAddress().c_str(), id);
|
||||
}
|
||||
if (peer->getAvailableKartIDs().empty())
|
||||
{
|
||||
Log::info("ServerLobby", "%s spectating succeeded.",
|
||||
peer->getAddress().toString().c_str());
|
||||
peer->getRealAddress().c_str());
|
||||
spectator = true;
|
||||
}
|
||||
|
||||
@ -1631,7 +1631,7 @@ void ServerLobby::update(int ticks)
|
||||
// Remove loading world too long (60 seconds) live join peer
|
||||
Log::info("ServerLobby", "%s hasn't live-joined within"
|
||||
" 60 seconds, remove it.",
|
||||
peer->getAddress().toString().c_str());
|
||||
peer->getRealAddress().c_str());
|
||||
rki.makeReserved();
|
||||
continue;
|
||||
}
|
||||
@ -1642,7 +1642,7 @@ void ServerLobby::update(int ticks)
|
||||
continue;
|
||||
Log::info("ServerLobby", "%s %s has been idle for more than"
|
||||
" %d seconds, kick.",
|
||||
peer->getAddress().toString().c_str(),
|
||||
peer->getRealAddress().c_str(),
|
||||
StringUtils::wideToUtf8(rki.getPlayerName()).c_str(), sec);
|
||||
peer->kick();
|
||||
}
|
||||
@ -3010,7 +3010,7 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
|
||||
Log::info("ServerLobby",
|
||||
"New player %s with online id %u from %s with %s.",
|
||||
StringUtils::wideToUtf8(npp->getName()).c_str(),
|
||||
npp->getOnlineId(), peer->getAddress().toString().c_str(),
|
||||
npp->getOnlineId(), peer->getRealAddress().c_str(),
|
||||
peer->getUserVersion().c_str());
|
||||
}
|
||||
}
|
||||
@ -3727,7 +3727,7 @@ void ServerLobby::configPeersStartTime()
|
||||
{
|
||||
Log::warn("ServerLobby",
|
||||
"Peer %s cannot catch up with max ping %d.",
|
||||
peer->getAddress().toString().c_str(), max_ping);
|
||||
peer->getRealAddress().c_str(), max_ping);
|
||||
continue;
|
||||
}
|
||||
max_ping = std::max(peer->getAveragePing(), max_ping);
|
||||
@ -3802,7 +3802,7 @@ void ServerLobby::addWaitingPlayersToGame()
|
||||
"New player %s with online id %u from %s with %s.",
|
||||
StringUtils::wideToUtf8(profile->getName()).c_str(),
|
||||
profile->getOnlineId(),
|
||||
peer->getAddress().toString().c_str(),
|
||||
peer->getRealAddress().c_str(),
|
||||
peer->getUserVersion().c_str());
|
||||
}
|
||||
}
|
||||
@ -3868,7 +3868,7 @@ void ServerLobby::testBannedForIP(STKPeer* peer) const
|
||||
const char* desc = (char*)sqlite3_column_text(stmt, 4);
|
||||
Log::info("ServerLobby", "%s banned by IP: %s "
|
||||
"(rowid: %d, description: %s).",
|
||||
peer->getAddress().toString().c_str(), reason, row_id, desc);
|
||||
peer->getRealAddress().c_str(), reason, row_id, desc);
|
||||
kickPlayerWithReason(peer, reason);
|
||||
}
|
||||
ret = sqlite3_finalize(stmt);
|
||||
@ -3927,7 +3927,7 @@ void ServerLobby::testBannedForOnlineId(STKPeer* peer,
|
||||
const char* desc = (char*)sqlite3_column_text(stmt, 2);
|
||||
Log::info("ServerLobby", "%s banned by online id: %s "
|
||||
"(online id: %u rowid: %d, description: %s).",
|
||||
peer->getAddress().toString().c_str(), reason, online_id,
|
||||
peer->getRealAddress().c_str(), reason, online_id,
|
||||
row_id, desc);
|
||||
kickPlayerWithReason(peer, reason);
|
||||
}
|
||||
@ -4329,7 +4329,7 @@ void ServerLobby::clientInGameWantsToBackLobby(Event* event)
|
||||
if (!w || !worldIsActive() || peer->isWaitingForGame())
|
||||
{
|
||||
Log::warn("ServerLobby", "%s try to leave the game at wrong time.",
|
||||
peer->getAddress().toString().c_str());
|
||||
peer->getRealAddress().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4339,14 +4339,14 @@ void ServerLobby::clientInGameWantsToBackLobby(Event* event)
|
||||
if (rki.getHostId() == peer->getHostId())
|
||||
{
|
||||
Log::info("ServerLobby", "%s left the game with kart id %d.",
|
||||
peer->getAddress().toString().c_str(), id);
|
||||
peer->getRealAddress().c_str(), id);
|
||||
rki.setNetworkPlayerProfile(
|
||||
std::shared_ptr<NetworkPlayerProfile>());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("ServerLobby", "%s doesn't exist anymore in server.",
|
||||
peer->getAddress().toString().c_str());
|
||||
peer->getRealAddress().c_str());
|
||||
}
|
||||
}
|
||||
NetworkItemManager* nim =
|
||||
@ -4382,7 +4382,7 @@ void ServerLobby::clientSelectingAssetsWantsToBackLobby(Event* event)
|
||||
{
|
||||
Log::warn("ServerLobby",
|
||||
"%s try to leave selecting assets at wrong time.",
|
||||
peer->getAddress().toString().c_str());
|
||||
peer->getRealAddress().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@
|
||||
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
|
||||
if (m_peer_address.getIP() < 16777216)
|
||||
m_ipv6_address = getIPV6ReadableFromMappedAddress(&enet_peer->address);
|
||||
m_enet_peer = enet_peer;
|
||||
m_host_id = host_id;
|
||||
|
Loading…
Reference in New Issue
Block a user