From 105aa766cb466a854c232e75d029f3b1a1009643 Mon Sep 17 00:00:00 2001 From: trippyone <137233897+trippyone@users.noreply.github.com> Date: Sat, 8 Jun 2024 10:55:21 -0400 Subject: [PATCH] Added server nat punch logic --- Fika.Core/Networking/FikaClient.cs | 3 ++- Fika.Core/Networking/FikaServer.cs | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs index 72a5ac7c..396b6da2 100644 --- a/Fika.Core/Networking/FikaClient.cs +++ b/Fika.Core/Networking/FikaClient.cs @@ -105,7 +105,8 @@ public void Init() EnableStatistics = true }; - _netClient.Start(); + // netClient needs to bind on the same port as the STUN query + _netClient.Start(FikaPlugin.UDPPort.Value); /*GetHostRequest body = new(MatchmakerAcceptPatches.GetGroupId()); GetHostResponse result = FikaRequestHandler.GetHost(body); diff --git a/Fika.Core/Networking/FikaServer.cs b/Fika.Core/Networking/FikaServer.cs index 391f45ca..eb9ddf00 100644 --- a/Fika.Core/Networking/FikaServer.cs +++ b/Fika.Core/Networking/FikaServer.cs @@ -16,6 +16,7 @@ using Fika.Core.Modding.Events; using Fika.Core.Networking.Http; using Fika.Core.Networking.Http.Models; +using Fika.Core.Networking.NatPunch; using Fika.Core.Networking.Packets.Communication; using Fika.Core.Networking.Packets.GameWorld; using Fika.Core.Networking.Packets.Player; @@ -108,6 +109,9 @@ public async Task Init() EnableStatistics = true }; + var natPunchServer = new FikaNatPunchServer(_netServer); + natPunchServer.Listen(); + if (FikaPlugin.UseUPnP.Value) { bool upnpFailed = false;