wasSharpNET
/Network/HTTP/HTTPServer.cs |
@@ -22,6 +22,9 @@ |
|
private int processedRequests; |
|
private AutoResetEvent StopServerEvent = new AutoResetEvent(false); |
private AutoResetEvent ServerStoppedEvent = new AutoResetEvent(false); |
|
public AuthenticationSchemes AuthenticationSchemes |
{ |
get |
@@ -43,7 +46,6 @@ |
return false; |
|
// Add all prefixes. |
HTTPListener.Prefixes.Clear(); |
foreach (var prefix in prefixes) |
{ |
HTTPListener.Prefixes.Add(prefix); |
@@ -58,7 +60,9 @@ |
|
public bool Stop() |
{ |
HTTPListener.Stop(); |
StopServerEvent.Set(); |
ServerStoppedEvent.WaitOne(); |
HTTPListener.Prefixes.Clear(); |
return true; |
} |
|
@@ -69,8 +73,16 @@ |
while (callbackState.Listener.IsListening) |
{ |
callbackState.Listener.BeginGetContext(ContextCallback, callbackState); |
callbackState.ContextRetrieved.WaitOne(); |
var n = WaitHandle.WaitAny(new WaitHandle[] { callbackState.ContextRetrieved, StopServerEvent }); |
|
if (n.Equals(1)) |
{ |
callbackState.Listener.Stop(); |
break; |
} |
} |
|
ServerStoppedEvent.Set(); |
} |
|
public abstract void ProcessHTTPContext(HttpListenerContext context); |
@@ -113,7 +125,13 @@ |
public void Dispose() |
{ |
Stop(); |
|
HTTPListener = null; |
StopServerEvent?.Dispose(); |
ServerStoppedEvent?.Dispose(); |
|
StopServerEvent = null; |
ServerStoppedEvent = null; |
} |
|
private class HTTPServerCallbackState |
/Platform/Windows/Commands/NetSH/URLACL.cs |
@@ -12,19 +12,17 @@ |
{ |
public class URLACL |
{ |
private string domain; |
private string URL; |
public string domain; |
public string URL; |
|
private readonly Regex URLReservationRegex; |
private string username; |
private int timeout; |
public string username; |
|
public URLACL(string URL, string username, string domain, int timeout) |
public URLACL(string URL, string username, string domain) |
{ |
this.URL = URL; |
this.username = username; |
this.domain = domain; |
this.timeout = timeout; |
|
URLReservationRegex = |
new Regex( |
@@ -58,7 +56,7 @@ |
|
checkProcess.Start(); |
checkProcess.BeginOutputReadLine(); |
checkProcess.WaitForExit(60000); |
checkProcess.WaitForExit(); |
|
return URLReservationRegex.IsMatch(netSHOutput.ToString()); |
} |
@@ -72,8 +70,8 @@ |
Verb = @"runas", |
CreateNoWindow = true, |
WindowStyle = ProcessWindowStyle.Hidden, |
UseShellExecute = false |
}).WaitForExit(timeout); |
UseShellExecute = true |
}).WaitForExit(); |
} |
|
public void Release() |
@@ -84,8 +82,8 @@ |
Verb = @"runas", |
CreateNoWindow = true, |
WindowStyle = ProcessWindowStyle.Hidden, |
UseShellExecute = false |
}).WaitForExit(timeout); |
UseShellExecute = true |
}).WaitForExit(); |
} |
} |
} |
/wasSharpNET.csproj |
@@ -46,7 +46,6 @@ |
<Compile Include="Console\ConsoleSpin.cs" /> |
<Compile Include="Cryptography\AES.cs" /> |
<Compile Include="Cryptography\SHA1.cs" /> |
<Compile Include="Diagnostics\ExceptionExtensions.cs" /> |
<Compile Include="Network\HTTP\HTTPServer.cs" /> |
<Compile Include="Network\IPAddressExtensions.cs" /> |
<Compile Include="Network\SubnetMask.cs" /> |
@@ -55,7 +54,6 @@ |
<Compile Include="Process.cs" /> |
<Compile Include="Reflection.cs" /> |
<Compile Include="Properties\AssemblyInfo.cs" /> |
<Compile Include="Serialization\XmlSerializerCache.cs" /> |
<Compile Include="Syndication\ObservableSyndication.cs" /> |
</ItemGroup> |
<ItemGroup> |