aboutsummaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-01-31 20:36:47 +0100
committerGitHub <noreply@github.com>2021-01-31 20:36:47 +0100
commit112a6adb10d3a5a2e55012a36580607d12ce9758 (patch)
tree344696315dbb8e261477e15d2e13421173fca8ba /src/network
parent6e0e0324a48130376ab3c9fef03b84ee25608242 (diff)
downloadminetest-112a6adb10d3a5a2e55012a36580607d12ce9758.tar.gz
minetest-112a6adb10d3a5a2e55012a36580607d12ce9758.tar.bz2
minetest-112a6adb10d3a5a2e55012a36580607d12ce9758.zip
Cache client IP in RemoteClient so it can always be retrieved (#10887)
specifically: after the peer has already disappeared
Diffstat (limited to 'src/network')
-rw-r--r--src/network/serverpackethandler.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index c636d01e1..882cf71c1 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -56,12 +56,12 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
session_t peer_id = pkt->getPeerId();
RemoteClient *client = getClient(peer_id, CS_Created);
+ Address addr;
std::string addr_s;
try {
- Address address = getPeerAddress(peer_id);
- addr_s = address.serializeString();
- }
- catch (con::PeerNotFoundException &e) {
+ addr = m_con->GetPeerAddress(peer_id);
+ addr_s = addr.serializeString();
+ } catch (con::PeerNotFoundException &e) {
/*
* no peer for this packet found
* most common reason is peer timeout, e.g. peer didn't
@@ -73,13 +73,14 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
return;
}
- // If net_proto_version is set, this client has already been handled
if (client->getState() > CS_Created) {
verbosestream << "Server: Ignoring multiple TOSERVER_INITs from " <<
addr_s << " (peer_id=" << peer_id << ")" << std::endl;
return;
}
+ client->setCachedAddress(addr);
+
verbosestream << "Server: Got TOSERVER_INIT from " << addr_s <<
" (peer_id=" << peer_id << ")" << std::endl;