Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client-to-client hole punching #429

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/game/CNetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ void CNetManager::DisconnectSome(short mask) {
}

void CNetManager::HandleDisconnect(short slotId, short why) {
DBG_Log("login+", "HandleDisconnect called for slot #%d, why=%d", slotId, why);
itsCommManager->DisconnectSlot(slotId);

if (slotId == itsCommManager->myId) {
Expand Down
3 changes: 2 additions & 1 deletion src/net/CUDPComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ Boolean CUDPComm::PacketHandler(PacketInfo *thePacket) {
case kpPacketProtocolTOC:
if (!isServing && thePacket->p3 == seed) {
ReadFromTOC(thePacket);
DBG_Log("login", "sending kpPacketProtocolTOC to kdEveryone\n");
DBG_Log("login+", "sending kpPacketProtocolControl to kdEveryone with cramData = %d\n", cramData);
SendPacket(kdEveryone, kpPacketProtocolControl, udpCramInfo, cramData, 0, 0, NULL);
}
break;
Expand All @@ -647,6 +647,7 @@ Boolean CUDPComm::PacketHandler(PacketInfo *thePacket) {
}
break;
case kpPacketProtocolControl:
DBG_Log("login+", "received kpPacketProtocolControl from %d with cramData = %d\n", thePacket->sender, thePacket->p2);
connections->ReceiveControlPacket(thePacket);
break;
case kpKickClient:
Expand Down
9 changes: 5 additions & 4 deletions src/net/CUDPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ void CUDPConnection::MarkOpenConnections(CompleteAddress *table) {
table++;
}

DBG_Log("login", "%s no longer in connection table, marking as GONE", FormatHostPort(ipAddr, port).c_str());
port = 0;
ipAddr = 0;
myId = -1;
Expand Down Expand Up @@ -849,10 +850,10 @@ void CUDPConnection::FreshClient(ip_addr remoteHost, port_num remotePort, uint16
ipAddr = ipAddrExt = remoteHost;
port = remotePort;

// Normal client-client Avara packets will do the hole-punching for us, so this is unnecessary.
// But maybe this could speed things up?
// IPaddress addr = { remoteHost, remotePort };
// Punch(addr);
// Normal client-client Avara packets will do the hole-punching for us, so this is unnecessary?
// Sometimes the hole needs to be punched between clients such as when they are both behind double-NAT.
IPaddress addr = { remoteHost, remotePort };
RequestPunch(addr);
}

Boolean CUDPConnection::AreYouDone() {
Expand Down