diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index a751289c..4bdae119 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -26,7 +26,10 @@ using Fika.Core.UI; using Fika.Core.UI.Models; using Fika.Core.UI.Patches; +using System; using System.Collections.Generic; +using System.Net.Sockets; +using System.Net; using System.Text; using UnityEngine; @@ -156,6 +159,7 @@ public class FikaPlugin : BaseUnityPlugin public static ConfigEntry NativeSockets { get; set; } public static ConfigEntry ForceIP { get; set; } public static ConfigEntry ForceBindIP { get; set; } + public static ConfigEntry ForceBindIP2 { get; set; } public static ConfigEntry AutoRefreshRate { get; set; } public static ConfigEntry UDPPort { get; set; } public static ConfigEntry UseUPnP { get; set; } @@ -353,7 +357,7 @@ private void SetupConfig() ForceIP = Config.Bind("Network", "Force IP", "", new ConfigDescription("Forces the server when hosting to use this IP when broadcasting to the backend instead of automatically trying to fetch it. Leave empty to disable.", tags: new ConfigurationManagerAttributes() { Order = 6 })); - ForceBindIP = Config.Bind("Network", "Force Bind IP", "", new ConfigDescription("Forces the server when hosting to use this local IP when starting the server. Useful if you are hosting on a VPN. Leave empty to disable.", tags: new ConfigurationManagerAttributes() { Order = 5 })); + ForceBindIP = Config.Bind("Network", "Force Bind IP", "",new ConfigDescription("Forces the server when hosting to use this local IP when starting the server. Useful if you are hosting on a VPN. Leave empty to disable.",new AcceptableValueList(GetLocalIPAddress()), new ConfigurationManagerAttributes() { Order = 5 })); AutoRefreshRate = Config.Bind("Network", "Auto Server Refresh Rate", 10f, new ConfigDescription("Every X seconds the client will ask the server for the list of matches while at the lobby screen.", new AcceptableValueRange(3f, 60f), new ConfigurationManagerAttributes() { Order = 4 })); @@ -370,6 +374,21 @@ private void SetupConfig() ArmpitDamageMultiplier = Config.Bind("Gameplay", "Armpit Damage Multiplier", 1f, new ConfigDescription("X multiplier to damage taken on the armpits collider. 0.2 = 20%", new AcceptableValueRange(0.2f, 1f), new ConfigurationManagerAttributes() { Order = 1 })); } + private string[] GetLocalIPAddress() + { + IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); + List ips = []; + ips.Add("Disabled"); + foreach (IPAddress ip in host.AddressList) + { + if (ip.AddressFamily == AddressFamily.InterNetwork) + { + ips.Add(ip.ToString()); + } + } + return [.. ips]; + } + private void DisableSPTPatches() { // Disable these as they interfere with Fika diff --git a/Fika.Core/UI/Custom/MatchMakerUIScript.cs b/Fika.Core/UI/Custom/MatchMakerUIScript.cs index e074a807..871829f0 100644 --- a/Fika.Core/UI/Custom/MatchMakerUIScript.cs +++ b/Fika.Core/UI/Custom/MatchMakerUIScript.cs @@ -132,7 +132,7 @@ private void CreateMatchMakerUI() return; } } - if (FikaPlugin.ForceBindIP.Value != "") + if (FikaPlugin.ForceBindIP.Value != "Disabled") { if (!IPAddress.TryParse(FikaPlugin.ForceBindIP.Value, out _)) {