scripts
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace System.Net
|
||||
{
|
||||
// Token: 0x02000218 RID: 536
|
||||
internal sealed class EndPointManager
|
||||
{
|
||||
// Token: 0x06001239 RID: 4665 RVA: 0x00036E70 File Offset: 0x00035070
|
||||
private EndPointManager()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600123B RID: 4667 RVA: 0x00036E84 File Offset: 0x00035084
|
||||
public static void AddListener(HttpListener listener)
|
||||
{
|
||||
ArrayList arrayList = new ArrayList();
|
||||
try
|
||||
{
|
||||
Hashtable hashtable = EndPointManager.ip_to_endpoints;
|
||||
lock (hashtable)
|
||||
{
|
||||
foreach (string text in listener.Prefixes)
|
||||
{
|
||||
EndPointManager.AddPrefixInternal(text, listener);
|
||||
arrayList.Add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
foreach (object obj in arrayList)
|
||||
{
|
||||
string text2 = (string)obj;
|
||||
EndPointManager.RemovePrefix(text2, listener);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600123C RID: 4668 RVA: 0x00036FAC File Offset: 0x000351AC
|
||||
public static void AddPrefix(string prefix, HttpListener listener)
|
||||
{
|
||||
Hashtable hashtable = EndPointManager.ip_to_endpoints;
|
||||
lock (hashtable)
|
||||
{
|
||||
EndPointManager.AddPrefixInternal(prefix, listener);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600123D RID: 4669 RVA: 0x00036FF4 File Offset: 0x000351F4
|
||||
private static void AddPrefixInternal(string p, HttpListener listener)
|
||||
{
|
||||
ListenerPrefix listenerPrefix = new ListenerPrefix(p);
|
||||
if (listenerPrefix.Path.IndexOf('%') != -1)
|
||||
{
|
||||
throw new HttpListenerException(400, "Invalid path.");
|
||||
}
|
||||
if (listenerPrefix.Path.IndexOf("//") != -1)
|
||||
{
|
||||
throw new HttpListenerException(400, "Invalid path.");
|
||||
}
|
||||
EndPointListener eplistener = EndPointManager.GetEPListener(IPAddress.Any, listenerPrefix.Port, listener, listenerPrefix.Secure);
|
||||
eplistener.AddPrefix(listenerPrefix, listener);
|
||||
}
|
||||
|
||||
// Token: 0x0600123E RID: 4670 RVA: 0x00037074 File Offset: 0x00035274
|
||||
private static EndPointListener GetEPListener(IPAddress addr, int port, HttpListener listener, bool secure)
|
||||
{
|
||||
Hashtable hashtable;
|
||||
if (EndPointManager.ip_to_endpoints.ContainsKey(addr))
|
||||
{
|
||||
hashtable = (Hashtable)EndPointManager.ip_to_endpoints[addr];
|
||||
}
|
||||
else
|
||||
{
|
||||
hashtable = new Hashtable();
|
||||
EndPointManager.ip_to_endpoints[addr] = hashtable;
|
||||
}
|
||||
EndPointListener endPointListener;
|
||||
if (hashtable.ContainsKey(port))
|
||||
{
|
||||
endPointListener = (EndPointListener)hashtable[port];
|
||||
}
|
||||
else
|
||||
{
|
||||
endPointListener = new EndPointListener(addr, port, secure);
|
||||
hashtable[port] = endPointListener;
|
||||
}
|
||||
return endPointListener;
|
||||
}
|
||||
|
||||
// Token: 0x0600123F RID: 4671 RVA: 0x000370FC File Offset: 0x000352FC
|
||||
public static void RemoveEndPoint(EndPointListener epl, IPEndPoint ep)
|
||||
{
|
||||
Hashtable hashtable = EndPointManager.ip_to_endpoints;
|
||||
lock (hashtable)
|
||||
{
|
||||
Hashtable hashtable2 = (Hashtable)EndPointManager.ip_to_endpoints[ep.Address];
|
||||
hashtable2.Remove(ep.Port);
|
||||
if (hashtable2.Count == 0)
|
||||
{
|
||||
EndPointManager.ip_to_endpoints.Remove(ep.Address);
|
||||
}
|
||||
epl.Close();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06001240 RID: 4672 RVA: 0x00037188 File Offset: 0x00035388
|
||||
public static void RemoveListener(HttpListener listener)
|
||||
{
|
||||
Hashtable hashtable = EndPointManager.ip_to_endpoints;
|
||||
lock (hashtable)
|
||||
{
|
||||
foreach (string text in listener.Prefixes)
|
||||
{
|
||||
EndPointManager.RemovePrefixInternal(text, listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06001241 RID: 4673 RVA: 0x0003721C File Offset: 0x0003541C
|
||||
public static void RemovePrefix(string prefix, HttpListener listener)
|
||||
{
|
||||
Hashtable hashtable = EndPointManager.ip_to_endpoints;
|
||||
lock (hashtable)
|
||||
{
|
||||
EndPointManager.RemovePrefixInternal(prefix, listener);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06001242 RID: 4674 RVA: 0x00037264 File Offset: 0x00035464
|
||||
private static void RemovePrefixInternal(string prefix, HttpListener listener)
|
||||
{
|
||||
ListenerPrefix listenerPrefix = new ListenerPrefix(prefix);
|
||||
if (listenerPrefix.Path.IndexOf('%') != -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (listenerPrefix.Path.IndexOf("//") != -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EndPointListener eplistener = EndPointManager.GetEPListener(IPAddress.Any, listenerPrefix.Port, listener, listenerPrefix.Secure);
|
||||
eplistener.RemovePrefix(listenerPrefix, listener);
|
||||
}
|
||||
|
||||
// Token: 0x04000FBC RID: 4028
|
||||
private static Hashtable ip_to_endpoints = new Hashtable();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user