Work around not being able to reach the shard from a local connection

In certain circumstances, like when running a private server through
Hamachi, the shard IP will be set to an address the local machine can't
reach itself from, preventing only the local player from getting past
character selection. This workaround detects local connections and
sends a loopback address for the shard instead of the configured one.
This makes those use cases feasible.
This commit is contained in:
2021-03-05 18:21:40 +01:00
parent da8dde9818
commit d5fe1cc513
3 changed files with 20 additions and 10 deletions

View File

@@ -63,7 +63,7 @@ CNPacketData::CNPacketData(void* b, uint32_t t, int l): buf(b), size(l), type(t)
// ========================================================[[ CNSocket ]]========================================================
CNSocket::CNSocket(SOCKET s, PacketHandler ph): sock(s), pHandler(ph) {
CNSocket::CNSocket(SOCKET s, struct sockaddr_in &addr, PacketHandler ph): sock(s), sockaddr(addr), pHandler(ph) {
EKey = (uint64_t)(*(uint64_t*)&CNSocketEncryption::defaultKey[0]);
}
@@ -390,7 +390,7 @@ void CNServer::start() {
addPollFD(newConnectionSocket);
// add connection to list!
CNSocket* tmp = new CNSocket(newConnectionSocket, pHandler);
CNSocket* tmp = new CNSocket(newConnectionSocket, address, pHandler);
connections[newConnectionSocket] = tmp;
newConnection(tmp);