add a dirty hack to disable ipv6 dns resolution. Fixes texture pack downloads taking 40-60 seconds on some machines.

This commit is contained in:
UnknownShadow200 2018-04-09 19:12:28 +10:00
parent 769e4223e9
commit 533e431fd7

View File

@ -28,6 +28,7 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Net.Sockets;
namespace OpenTK {
@ -102,6 +103,13 @@ namespace OpenTK {
// So we hack around and prevent them ever being initalised.
// TODO: only seems to work before .NET 4.0, not sure if still needed by then
HACK_PerfCounters();
// Another issue with ipv6 DNS resolution delaying downloads for 30-40 seconds too
HACK_IPv6();
}
static void HACK_PerfCounters() {
try {
Assembly assem = typeof(System.Net.IPAddress).Assembly;
Type perfType = assem.GetType("System.Net.NetworkingPerfCounters");
@ -114,5 +122,18 @@ namespace OpenTK {
} catch {
}
}
static void HACK_IPv6() {
try {
// Force socket state to get initalised
bool ignored = System.Net.Sockets.Socket.OSSupportsIPv6;
FieldInfo field = typeof(Socket).GetField("s_OSSupportsIPv6", BindingFlags.NonPublic | BindingFlags.Static);
if (field == null) return;
field.SetValue(null, false);
} catch {
}
}
}
}