Lidgren-Network updated. Only TLS 1.3 and TLS 1.2 are supported. Small changes

This commit is contained in:
EntenKoeniq
2021-12-17 19:50:47 +01:00
parent 7df796340f
commit 6e72cf9d27
5 changed files with 33 additions and 8 deletions

View File

@ -88,6 +88,11 @@ namespace CoopClient
}
private ulong LastDataSend;
#if DEBUG
private ulong LastDebugData;
private int DebugBytesSend;
private int DebugBytesReceived;
#endif
private void OnTick(object sender, EventArgs e)
{
if (Game.IsLoading)
@ -122,9 +127,20 @@ namespace CoopClient
#if DEBUG
if (MainNetworking.ShowNetworkInfo)
{
ulong time = Util.GetTickCount64();
if (time - LastDebugData > 1000)
{
LastDebugData = time;
DebugBytesReceived = MainNetworking.BytesReceived;
MainNetworking.BytesReceived = 0;
DebugBytesSend = MainNetworking.BytesSend;
MainNetworking.BytesSend = 0;
}
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 0), $"L: {MainNetworking.Latency * 1000:N0}ms", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 30), $"R: {MainNetworking.BytesReceived * 0.000001} mb", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 60), $"S: {MainNetworking.BytesSend * 0.000001} mb", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 30), $"R: {Lidgren.Network.NetUtility.ToHumanReadable(DebugBytesReceived)}/s", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 60), $"S: {Lidgren.Network.NetUtility.ToHumanReadable(DebugBytesSend)}/s", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
}
#endif

View File

@ -67,9 +67,9 @@ namespace CoopClient.Menus.Sub
List<ServerListClass> serverList = null;
try
{
// SSL/TLS
// TLS only
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
WebClient client = new WebClient();

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<AssemblyVersion>1.10.0.0001</AssemblyVersion>
<AssemblyVersion>1.10.1.0001</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
</PropertyGroup>

View File

@ -1,4 +1,6 @@
using System;
using System.Text;
using System.Net;
using System.Linq;
using System.Collections.Generic;
using System.Threading;
@ -9,7 +11,6 @@ using System.Net.Http;
using Newtonsoft.Json;
using Lidgren.Network;
using System.Text;
namespace CoopServer
{
@ -67,7 +68,7 @@ namespace CoopServer
}
else
{
Logging.Error("Port forwarding failed!");
Logging.Error("Port forwarding failed! Your router may not support UPnP.");
Logging.Warning("If you and your friends can join this server, please ignore this error or set UPnP in CoopSettings.xml to false!");
}
}
@ -75,13 +76,17 @@ namespace CoopServer
if (MainSettings.AnnounceSelf)
{
Logging.Info("Announcing to master server...");
Logging.Warning("Please make sure that port forwarding is active, otherwise nobody can join!");
#region -- MASTERSERVER --
new Thread(async () =>
{
try
{
// TLS only
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
HttpClient httpClient = new();
IpInfo info;
@ -154,6 +159,10 @@ namespace CoopServer
Thread.Sleep(12500);
}
}
catch (HttpRequestException ex)
{
Logging.Error($"MasterServer: {ex.InnerException.Message}");
}
catch (Exception ex)
{
Logging.Error($"MasterServer: {ex.Message}");