mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
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:
parent
769e4223e9
commit
533e431fd7
@ -28,6 +28,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
|
||||||
namespace OpenTK {
|
namespace OpenTK {
|
||||||
|
|
||||||
@ -102,6 +103,13 @@ namespace OpenTK {
|
|||||||
|
|
||||||
// So we hack around and prevent them ever being initalised.
|
// 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
|
// 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 {
|
try {
|
||||||
Assembly assem = typeof(System.Net.IPAddress).Assembly;
|
Assembly assem = typeof(System.Net.IPAddress).Assembly;
|
||||||
Type perfType = assem.GetType("System.Net.NetworkingPerfCounters");
|
Type perfType = assem.GetType("System.Net.NetworkingPerfCounters");
|
||||||
@ -111,7 +119,20 @@ namespace OpenTK {
|
|||||||
if (field == null) return;
|
if (field == null) return;
|
||||||
|
|
||||||
field.SetValue(null, true);
|
field.SetValue(null, true);
|
||||||
} catch {
|
} 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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user