Disassembled CarotDav v1.14.7 with dotPeek 2017.2

This commit is contained in:
2017-10-06 17:20:58 +02:00
commit 2002a53fb5
191 changed files with 69359 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright (C) Rei HOBARA 2015-2016")]
[assembly: AssemblyCompany("Rei Software")]
[assembly: AssemblyDescription("HttpServer Support Library")]
[assembly: ComVisible(false)]
[assembly: AssemblyProduct("Rei.Net.HttpServer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyTitle("Rei.Net.HttpServer")]
[assembly: Guid("ae9e344a-bb01-4d81-97ed-f2c3bdacf0f7")]
[assembly: AssemblyVersion("1.13.2.9297")]

View File

@@ -0,0 +1,424 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.LineReadableSocketStream
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
namespace Rei.Net.HttpServer
{
public class LineReadableSocketStream : Stream
{
private Socket _soc;
private long _readbytes;
private long _writebytes;
private bool _shutdownreceive;
private bool _shutdownsend;
private int _receive_bufcount;
private byte[] _receive_buf;
private int _readtimeout;
private int _writetimeout;
private bool disposedValue;
public LineReadableSocketStream(Socket basesocket)
{
this._shutdownreceive = false;
this._shutdownsend = false;
this._readtimeout = 10000;
this._writetimeout = 10000;
this.disposedValue = false;
if (basesocket == null)
throw new ArgumentNullException();
this._soc = basesocket;
this._receive_buf = new byte[65536];
}
public void Shutdown(SocketShutdown how)
{
if (this._soc == null)
throw new ObjectDisposedException(this.ToString());
this._soc.Shutdown(how);
if (how == SocketShutdown.Both)
{
this._shutdownreceive = true;
this._shutdownsend = true;
}
else if (how == SocketShutdown.Receive)
{
this._shutdownreceive = true;
}
else
{
if (how != SocketShutdown.Send)
return;
this._shutdownsend = true;
}
}
public override bool CanSeek
{
get
{
return false;
}
}
public override void Flush()
{
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override long Length
{
get
{
throw new NotImplementedException();
}
}
public override long Position
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public long ReadBytes
{
get
{
return this._readbytes;
}
}
public override bool CanRead
{
get
{
return !this._shutdownreceive;
}
}
public override int ReadTimeout
{
get
{
return this._readtimeout;
}
set
{
this._readtimeout = value;
}
}
public override int Read(byte[] buffer, int offset, int count)
{
IAsyncResult asyncresult = this.BeginRead(buffer, offset, count, (AsyncCallback) null, (object) null);
if (!asyncresult.AsyncWaitHandle.WaitOne(this.ReadTimeout, false))
throw new IOException();
return this.EndRead(asyncresult);
}
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object asyncstate)
{
if (this._soc == null)
throw new ObjectDisposedException(this.ToString());
if (count < 0)
throw new ArgumentOutOfRangeException();
int num = this._receive_bufcount;
if (num > count)
num = count;
Array.Copy((Array) this._receive_buf, 0, (Array) buffer, offset, num);
this._receive_bufcount = checked (this._receive_bufcount - num);
Array.Copy((Array) this._receive_buf, num, (Array) this._receive_buf, 0, this._receive_bufcount);
MyAsyncResult myAsyncResult = new MyAsyncResult(callback, RuntimeHelpers.GetObjectValue(asyncstate));
myAsyncResult.ReturnValue = (object) num;
if (count == num)
myAsyncResult.Complete((Exception) null);
else
this._soc.BeginReceive(buffer, checked (offset + num), checked (count - num), SocketFlags.None, new AsyncCallback(this.OnReceive), (object) myAsyncResult);
return (IAsyncResult) myAsyncResult;
}
private void OnReceive(IAsyncResult asyncresult)
{
MyAsyncResult asyncState = (MyAsyncResult) asyncresult.AsyncState;
if (!asyncresult.CompletedSynchronously)
asyncState.SetAsync();
int num;
try
{
num = this._soc.EndReceive(asyncresult);
}
catch (Exception ex1)
{
ProjectData.SetProjectError(ex1);
Exception ex2 = ex1;
asyncState.Complete(ex2);
ProjectData.ClearProjectError();
return;
}
Interlocked.Add(ref this._readbytes, (long) num);
asyncState.ReturnValue = (object) checked ((int) asyncState.ReturnValue + num);
asyncState.Complete();
}
public override int EndRead(IAsyncResult asyncresult)
{
MyAsyncResult myAsyncResult = asyncresult as MyAsyncResult;
myAsyncResult.AsyncEnd();
return (int) myAsyncResult.ReturnValue;
}
public string ReadLine()
{
IAsyncResult asyncresult = this.BeginReadLine((AsyncCallback) null, (object) null);
if (!asyncresult.AsyncWaitHandle.WaitOne(this.ReadTimeout, false))
throw new IOException();
return this.EndReadLine(asyncresult);
}
public IAsyncResult BeginReadLine(AsyncCallback callback, object asyncstate)
{
if (this._soc == null)
throw new ObjectDisposedException(this.ToString());
MyAsyncResult myAsyncResult = new MyAsyncResult(callback, RuntimeHelpers.GetObjectValue(asyncstate));
int num1 = 0;
int num2 = checked (this._receive_bufcount - 1);
int index = num1;
while (index <= num2)
{
if ((int) this._receive_buf[index] == 10)
{
byte[] numArray = index <= 0 || (int) this._receive_buf[checked (index - 1)] != 13 ? new byte[checked (index - 1 + 1)] : new byte[checked (index - 2 + 1)];
Array.Copy((Array) this._receive_buf, 0, (Array) numArray, 0, numArray.Length);
this._receive_bufcount = checked (this._receive_bufcount - index + 1);
Array.Copy((Array) this._receive_buf, checked (index + 1), (Array) this._receive_buf, 0, this._receive_bufcount);
myAsyncResult.ReturnValue = (object) numArray;
myAsyncResult.Complete();
return (IAsyncResult) myAsyncResult;
}
checked { ++index; }
}
if (checked (this._receive_buf.Length - this._receive_bufcount) < 1024)
this._receive_buf = (byte[]) Utils.CopyArray((Array) this._receive_buf, (Array) new byte[checked (this._receive_buf.Length * 2 - 1 + 1)]);
this._soc.BeginReceive(this._receive_buf, this._receive_bufcount, checked (this._receive_buf.Length - this._receive_bufcount), SocketFlags.None, new AsyncCallback(this.OnReceiveToBuffer), (object) myAsyncResult);
return (IAsyncResult) myAsyncResult;
}
private void OnReceiveToBuffer(IAsyncResult asyncresult)
{
MyAsyncResult asyncState = (MyAsyncResult) asyncresult.AsyncState;
if (!asyncresult.CompletedSynchronously)
asyncState.SetAsync();
int num1;
try
{
num1 = this._soc.EndReceive(asyncresult);
}
catch (Exception ex1)
{
ProjectData.SetProjectError(ex1);
Exception ex2 = ex1;
asyncState.Complete(ex2);
ProjectData.ClearProjectError();
return;
}
if (num1 == 0)
{
asyncState.ReturnValue = (object) null;
asyncState.Complete();
}
else
{
Interlocked.Add(ref this._readbytes, (long) num1);
this._receive_bufcount = checked (this._receive_bufcount + num1);
int num2 = 0;
int num3 = checked (this._receive_bufcount - 1);
int index = num2;
while (index <= num3)
{
if ((int) this._receive_buf[index] == 10)
{
byte[] numArray = index <= 0 || (int) this._receive_buf[checked (index - 1)] != 13 ? new byte[checked (index - 1 + 1)] : new byte[checked (index - 2 + 1)];
Array.Copy((Array) this._receive_buf, 0, (Array) numArray, 0, numArray.Length);
this._receive_bufcount = checked (this._receive_bufcount - index + 1);
Array.Copy((Array) this._receive_buf, checked (index + 1), (Array) this._receive_buf, 0, this._receive_bufcount);
asyncState.ReturnValue = (object) numArray;
asyncState.Complete();
return;
}
checked { ++index; }
}
if (checked (this._receive_buf.Length - this._receive_bufcount) < 1024)
this._receive_buf = (byte[]) Utils.CopyArray((Array) this._receive_buf, (Array) new byte[checked (this._receive_buf.Length * 2 - 1 + 1)]);
this._soc.BeginReceive(this._receive_buf, this._receive_bufcount, checked (this._receive_buf.Length - this._receive_bufcount), SocketFlags.None, new AsyncCallback(this.OnReceiveToBuffer), (object) asyncState);
}
}
public string EndReadLine(IAsyncResult asyncresult)
{
MyAsyncResult myAsyncResult = (MyAsyncResult) asyncresult;
myAsyncResult.AsyncEnd();
if (myAsyncResult.ReturnValue == null)
return (string) null;
return Encoding.UTF8.GetString((byte[]) myAsyncResult.ReturnValue);
}
public long WriteBytes
{
get
{
return this._writebytes;
}
}
public override bool CanWrite
{
get
{
return !this._shutdownsend;
}
}
public override int WriteTimeout
{
get
{
return this._writetimeout;
}
set
{
this._writetimeout = value;
}
}
public override void Write(byte[] buffer, int offset, int count)
{
IAsyncResult asyncResult = this.BeginWrite(buffer, offset, count, (AsyncCallback) null, (object) null);
if (!asyncResult.AsyncWaitHandle.WaitOne(this.WriteTimeout, false))
throw new IOException();
this.EndWrite(asyncResult);
}
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
if (this._soc == null)
throw new ObjectDisposedException(this.ToString());
MyAsyncResult myAsyncResult = new MyAsyncResult(callback, RuntimeHelpers.GetObjectValue(state));
LineReadableSocketStream.StreamReadWriteParameter readWriteParameter = new LineReadableSocketStream.StreamReadWriteParameter();
if (count < 0)
throw new ArgumentOutOfRangeException();
if (count == 0)
{
myAsyncResult.ReturnValue = (object) 0;
myAsyncResult.Complete();
}
else
{
IAsyncResult asyncResult;
try
{
readWriteParameter.buffer = buffer;
readWriteParameter.offset = offset;
readWriteParameter.count = count;
myAsyncResult.Tag = (object) readWriteParameter;
this._soc.BeginSend(readWriteParameter.buffer, readWriteParameter.offset, readWriteParameter.count, SocketFlags.None, new AsyncCallback(this.OnSend), (object) myAsyncResult);
goto label_8;
}
catch (Exception ex1)
{
ProjectData.SetProjectError(ex1);
Exception ex2 = ex1;
myAsyncResult.Complete(ex2);
asyncResult = (IAsyncResult) myAsyncResult;
ProjectData.ClearProjectError();
}
return asyncResult;
}
label_8:
return (IAsyncResult) myAsyncResult;
}
private void OnSend(IAsyncResult asyncresult)
{
MyAsyncResult asyncState = (MyAsyncResult) asyncresult.AsyncState;
LineReadableSocketStream.StreamReadWriteParameter tag = (LineReadableSocketStream.StreamReadWriteParameter) asyncState.Tag;
if (!asyncresult.CompletedSynchronously)
asyncState.SetAsync();
try
{
int num = this._soc.EndSend(asyncresult);
Interlocked.Add(ref this._writebytes, (long) num);
LineReadableSocketStream.StreamReadWriteParameter readWriteParameter1 = tag;
readWriteParameter1.count = checked (readWriteParameter1.count - num);
LineReadableSocketStream.StreamReadWriteParameter readWriteParameter2 = tag;
readWriteParameter2.offset = checked (readWriteParameter2.offset + num);
if (tag.count > 0)
{
this._soc.BeginSend(tag.buffer, tag.offset, tag.count, SocketFlags.None, new AsyncCallback(this.OnSend), (object) asyncState);
return;
}
}
catch (Exception ex1)
{
ProjectData.SetProjectError(ex1);
Exception ex2 = ex1;
asyncState.Complete(ex2);
ProjectData.ClearProjectError();
return;
}
asyncState.Complete();
}
public override void EndWrite(IAsyncResult asyncResult)
{
((MyAsyncResult) asyncResult).AsyncEnd();
}
protected override void Dispose(bool disposing)
{
if (!this.disposedValue && disposing && this._soc != null)
{
this._soc.Close();
this._soc = (Socket) null;
}
this.disposedValue = true;
base.Dispose(disposing);
}
private class StreamReadWriteParameter
{
public byte[] buffer;
public int offset;
public int count;
[DebuggerNonUserCode]
public StreamReadWriteParameter()
{
}
}
}
}

View File

@@ -0,0 +1,23 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.My.MyApplication
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic.ApplicationServices;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
namespace Rei.Net.HttpServer.My
{
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("MyTemplate", "8.0.0.0")]
internal class MyApplication : ApplicationBase
{
[DebuggerNonUserCode]
public MyApplication()
{
}
}
}

View File

@@ -0,0 +1,24 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.My.MyComputer
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic.Devices;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
namespace Rei.Net.HttpServer.My
{
[GeneratedCode("MyTemplate", "8.0.0.0")]
[EditorBrowsable(EditorBrowsableState.Never)]
internal class MyComputer : Computer
{
[EditorBrowsable(EditorBrowsableState.Never)]
[DebuggerHidden]
public MyComputer()
{
}
}
}

View File

@@ -0,0 +1,153 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.My.MyProject
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.ApplicationServices;
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.VisualBasic.MyServices.Internal;
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Rei.Net.HttpServer.My
{
[HideModuleName]
[StandardModule]
[GeneratedCode("MyTemplate", "8.0.0.0")]
internal sealed class MyProject
{
private static readonly MyProject.ThreadSafeObjectProvider<MyComputer> m_ComputerObjectProvider = new MyProject.ThreadSafeObjectProvider<MyComputer>();
private static readonly MyProject.ThreadSafeObjectProvider<MyApplication> m_AppObjectProvider = new MyProject.ThreadSafeObjectProvider<MyApplication>();
private static readonly MyProject.ThreadSafeObjectProvider<User> m_UserObjectProvider = new MyProject.ThreadSafeObjectProvider<User>();
private static readonly MyProject.ThreadSafeObjectProvider<MyProject.MyWebServices> m_MyWebServicesObjectProvider = new MyProject.ThreadSafeObjectProvider<MyProject.MyWebServices>();
[DebuggerNonUserCode]
static MyProject()
{
}
[HelpKeyword("My.Computer")]
internal static MyComputer Computer
{
[DebuggerHidden] get
{
return MyProject.m_ComputerObjectProvider.GetInstance;
}
}
[HelpKeyword("My.Application")]
internal static MyApplication Application
{
[DebuggerHidden] get
{
return MyProject.m_AppObjectProvider.GetInstance;
}
}
[HelpKeyword("My.User")]
internal static User User
{
[DebuggerHidden] get
{
return MyProject.m_UserObjectProvider.GetInstance;
}
}
[HelpKeyword("My.WebServices")]
internal static MyProject.MyWebServices WebServices
{
[DebuggerHidden] get
{
return MyProject.m_MyWebServicesObjectProvider.GetInstance;
}
}
[MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")]
[EditorBrowsable(EditorBrowsableState.Never)]
internal sealed class MyWebServices
{
[DebuggerHidden]
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object o)
{
return base.Equals(RuntimeHelpers.GetObjectValue(o));
}
[EditorBrowsable(EditorBrowsableState.Never)]
[DebuggerHidden]
public override int GetHashCode()
{
return base.GetHashCode();
}
[EditorBrowsable(EditorBrowsableState.Never)]
[DebuggerHidden]
internal new Type GetType()
{
return typeof (MyProject.MyWebServices);
}
[DebuggerHidden]
[EditorBrowsable(EditorBrowsableState.Never)]
public override string ToString()
{
return base.ToString();
}
[DebuggerHidden]
private static T Create__Instance__<T>(T instance) where T : new()
{
if ((object) instance == null)
return Activator.CreateInstance<T>();
return instance;
}
[DebuggerHidden]
private void Dispose__Instance__<T>(ref T instance)
{
instance = default (T);
}
[EditorBrowsable(EditorBrowsableState.Never)]
[DebuggerHidden]
public MyWebServices()
{
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ComVisible(false)]
internal sealed class ThreadSafeObjectProvider<T> where T : new()
{
private readonly ContextValue<T> m_Context;
internal T GetInstance
{
[DebuggerHidden] get
{
T instance = this.m_Context.Value;
if ((object) instance == null)
{
instance = Activator.CreateInstance<T>();
this.m_Context.Value = instance;
}
return instance;
}
}
[DebuggerHidden]
[EditorBrowsable(EditorBrowsableState.Never)]
public ThreadSafeObjectProvider()
{
this.m_Context = new ContextValue<T>();
}
}
}
}

View File

@@ -0,0 +1,35 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.My.MySettings
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Rei.Net.HttpServer.My
{
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal sealed class MySettings : ApplicationSettingsBase
{
private static MySettings defaultInstance = (MySettings) SettingsBase.Synchronized((SettingsBase) new MySettings());
[DebuggerNonUserCode]
public MySettings()
{
}
public static MySettings Default
{
get
{
return MySettings.defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,30 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.My.MySettingsProperty
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Rei.Net.HttpServer.My
{
[DebuggerNonUserCode]
[StandardModule]
[CompilerGenerated]
[HideModuleName]
internal sealed class MySettingsProperty
{
[HelpKeyword("My.Settings")]
internal static MySettings Settings
{
get
{
return MySettings.Default;
}
}
}
}

View File

@@ -0,0 +1,52 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.My.Resources.Resources
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Resources;
using System.Runtime.CompilerServices;
namespace Rei.Net.HttpServer.My.Resources
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[HideModuleName]
[CompilerGenerated]
[DebuggerNonUserCode]
[StandardModule]
internal sealed class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (object.ReferenceEquals((object) Rei.Net.HttpServer.My.Resources.Resources.resourceMan, (object) null))
Rei.Net.HttpServer.My.Resources.Resources.resourceMan = new ResourceManager("Rei.Net.HttpServer.Resources", typeof (Rei.Net.HttpServer.My.Resources.Resources).Assembly);
return Rei.Net.HttpServer.My.Resources.Resources.resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return Rei.Net.HttpServer.My.Resources.Resources.resourceCulture;
}
set
{
Rei.Net.HttpServer.My.Resources.Resources.resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,189 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.MyAsyncResult
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Rei.Net.HttpServer
{
public class MyAsyncResult : IAsyncResult
{
private AsyncCallback _callback;
private object _asyncstate;
private bool _iscompleted;
private bool _isended;
private bool _async;
private ManualResetEvent _waithandle;
private object _returnvalue;
private object _syncobject;
private IAsyncResult _baseasyncresult;
private object _tag;
private Exception _ex;
public MyAsyncResult(AsyncCallback callback, object asyncstate)
{
this._callback = callback;
this._asyncstate = RuntimeHelpers.GetObjectValue(asyncstate);
this._isended = false;
this._iscompleted = false;
this._async = false;
this._waithandle = (ManualResetEvent) null;
this._returnvalue = (object) null;
this._syncobject = RuntimeHelpers.GetObjectValue(new object());
}
public bool IsCompleted
{
get
{
return this._iscompleted;
}
}
public object AsyncState
{
get
{
return this._asyncstate;
}
}
public bool CompletedSynchronously
{
get
{
return this.IsCompleted && !this._async;
}
}
public WaitHandle AsyncWaitHandle
{
get
{
object syncobject = this._syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject);
Monitor.Enter(syncobject);
try
{
if (this._waithandle == null)
this._waithandle = new ManualResetEvent(this._iscompleted);
}
finally
{
Monitor.Exit(syncobject);
}
return (WaitHandle) this._waithandle;
}
}
internal object ReturnValue
{
get
{
return this._returnvalue;
}
set
{
this._returnvalue = RuntimeHelpers.GetObjectValue(value);
}
}
internal IAsyncResult BaseAsyncResult
{
get
{
return this._baseasyncresult;
}
set
{
this._baseasyncresult = value;
}
}
internal object Tag
{
get
{
return this._tag;
}
set
{
this._tag = RuntimeHelpers.GetObjectValue(value);
}
}
internal void SetAsync()
{
this._async = true;
}
internal void Complete(Exception ex)
{
object syncobject = this._syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject);
Monitor.Enter(syncobject);
try
{
if (this._iscompleted)
throw new InvalidOperationException();
this._iscompleted = true;
this._ex = ex;
if (this._waithandle != null)
this._waithandle.Set();
}
finally
{
Monitor.Exit(syncobject);
}
Exception ex1 = this._ex;
if (this._callback == null)
return;
this._callback((IAsyncResult) this);
}
internal void Complete()
{
this.Complete((Exception) null);
}
internal void AsyncEnd()
{
object syncobject1 = this._syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject1);
Monitor.Enter(syncobject1);
bool iscompleted;
try
{
if (this._isended)
throw new InvalidOperationException();
this._isended = true;
iscompleted = this._iscompleted;
}
finally
{
Monitor.Exit(syncobject1);
}
if (!iscompleted)
this.AsyncWaitHandle.WaitOne();
object syncobject2 = this._syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject2);
Monitor.Enter(syncobject2);
try
{
if (this._waithandle != null)
this._waithandle.Close();
}
finally
{
Monitor.Exit(syncobject2);
}
if (this._ex != null)
throw new Exception("error", this._ex);
}
}
}

View File

@@ -0,0 +1,145 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.MyEndPoint
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Xml.Serialization;
namespace Rei.Net.HttpServer
{
[DebuggerDisplay("{ToString()}")]
public class MyEndPoint
{
[XmlIgnore]
public IPEndPoint IPEndPoint;
public MyEndPoint()
: this(IPAddress.Loopback, 0)
{
}
public MyEndPoint(IPAddress address, int port)
{
this.IPEndPoint = new IPEndPoint(address, port);
}
public MyEndPoint(string str)
{
this.IPEndPoint = MyEndPoint.Parse(str).IPEndPoint;
}
public MyEndPoint(IPEndPoint ep)
{
this.IPEndPoint = ep;
}
public override bool Equals(object obj)
{
return this.IPEndPoint.Equals((object) (obj as MyEndPoint).IPEndPoint);
}
public override int GetHashCode()
{
return this.IPEndPoint.GetHashCode();
}
[Browsable(false)]
[System.Xml.Serialization.XmlText]
public string XmlText
{
get
{
return this.ToString();
}
set
{
this.IPEndPoint = MyEndPoint.Parse(value).IPEndPoint;
}
}
public bool IsLoopback
{
get
{
return IPAddress.IsLoopback(this.IPEndPoint.Address);
}
}
public string Host
{
get
{
return this.IPEndPoint.Address.ToString();
}
}
public int Port
{
get
{
return this.IPEndPoint.Port;
}
}
public override string ToString()
{
string str = this.IPEndPoint.Address.ToString();
if (this.IPEndPoint.Address.AddressFamily == AddressFamily.InterNetworkV6)
str = "[" + str + "]";
if (this.IPEndPoint.Port < 0)
return str;
return str + ":" + this.IPEndPoint.Port.ToString();
}
public static MyEndPoint Parse(string s)
{
MyEndPoint result = (MyEndPoint) null;
if (MyEndPoint.TryParse(s, ref result))
return result;
throw new ArgumentException();
}
public static bool TryParse(string s, ref MyEndPoint result)
{
if (string.IsNullOrEmpty(s))
return false;
s = s.Trim();
if (s.Length < 2)
return false;
int startIndex1;
int startIndex2;
int startIndex3;
if ((int) s[0] == 91)
{
startIndex1 = 1;
startIndex2 = s.LastIndexOf("]");
if (startIndex2 < 0)
return false;
int num = s.IndexOf(":", startIndex2);
if (num < 0 || num >= checked (s.Length - 1))
return false;
startIndex3 = checked (num + 1);
}
else
{
startIndex1 = 0;
startIndex2 = s.IndexOf(":");
if (startIndex2 < 0 || startIndex2 >= checked (s.Length - 1))
return false;
startIndex3 = checked (startIndex2 + 1);
}
IPAddress address = (IPAddress) null;
int result1;
if (!IPAddress.TryParse(s.Substring(startIndex1, checked (startIndex2 - startIndex1)), out address) || !int.TryParse(s.Substring(startIndex3, checked (s.Length - startIndex3)), out result1) || (result1 < 0 || result1 > (int) ushort.MaxValue))
return false;
result = new MyEndPoint(address, result1);
return true;
}
}
}

View File

@@ -0,0 +1,227 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.MyHttpListener
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Rei.Net.HttpServer
{
[DebuggerDisplay("{toString}")]
public class MyHttpListener : IDisposable
{
private TcpListener m_listener;
private IPEndPoint m_endpoint;
private object m_syncobject;
private string m_servername;
private bool disposedValue;
public MyHttpListener()
{
this.disposedValue = false;
this.m_servername = nameof (ServerName);
this.m_syncobject = RuntimeHelpers.GetObjectValue(new object());
this.m_endpoint = new IPEndPoint(IPAddress.Loopback, 0);
}
public void Start()
{
object syncobject = this.m_syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject);
Monitor.Enter(syncobject);
try
{
if (this.m_listener != null)
throw new ApplicationException();
this.m_listener = new TcpListener(this.m_endpoint);
this.m_listener.Start(100);
}
finally
{
Monitor.Exit(syncobject);
}
}
public void Stop()
{
object syncobject = this.m_syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject);
Monitor.Enter(syncobject);
try
{
if (this.m_listener != null)
this.m_listener.Stop();
this.m_listener = (TcpListener) null;
}
finally
{
Monitor.Exit(syncobject);
}
}
public void Close()
{
this.Dispose();
}
protected virtual void Dispose(bool disposing)
{
if (!this.disposedValue && disposing)
{
object syncobject = this.m_syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject);
Monitor.Enter(syncobject);
try
{
if (this.m_listener != null)
this.m_listener.Stop();
this.m_listener = (TcpListener) null;
}
finally
{
Monitor.Exit(syncobject);
}
}
this.disposedValue = true;
}
void IDisposable.Dispose()
{
this.Dispose(true);
GC.SuppressFinalize((object) this);
}
public IPEndPoint EndPoint
{
get
{
return this.m_endpoint;
}
set
{
if (value == null)
throw new ArgumentNullException();
this.m_endpoint = value;
}
}
public bool IsListening
{
get
{
object syncobject = this.m_syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject);
Monitor.Enter(syncobject);
try
{
return this.m_listener != null;
}
finally
{
Monitor.Exit(syncobject);
}
}
}
public bool IsPending
{
get
{
object syncobject = this.m_syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject);
Monitor.Enter(syncobject);
try
{
return this.m_listener != null && this.m_listener.Pending();
}
finally
{
Monitor.Exit(syncobject);
}
}
}
public string ServerName
{
get
{
return this.m_servername;
}
set
{
if (value == null)
throw new ArgumentNullException();
this.m_servername = value;
}
}
public MyHttpServerConnection GetConnection()
{
return this.EndGetConnection(this.BeginGetConnection((AsyncCallback) null, (object) null));
}
public IAsyncResult BeginGetConnection(AsyncCallback callback, object asyncstate)
{
MyAsyncResult myAsyncResult = new MyAsyncResult(callback, RuntimeHelpers.GetObjectValue(asyncstate));
object syncobject = this.m_syncobject;
ObjectFlowControl.CheckForSyncLockOnValueType(syncobject);
Monitor.Enter(syncobject);
try
{
if (this.m_listener == null)
throw new InvalidOperationException();
myAsyncResult.Tag = (object) this.m_listener;
this.m_listener.BeginAcceptSocket(new AsyncCallback(this.OnGetConnection), (object) myAsyncResult);
}
finally
{
Monitor.Exit(syncobject);
}
return (IAsyncResult) myAsyncResult;
}
private void OnGetConnection(IAsyncResult asyncresult)
{
MyAsyncResult asyncState = (MyAsyncResult) asyncresult.AsyncState;
if (!asyncresult.CompletedSynchronously)
asyncState.SetAsync();
TcpListener tag = (TcpListener) asyncState.Tag;
try
{
Socket basesocket = tag.EndAcceptSocket(asyncresult);
basesocket.SendTimeout = 1000;
basesocket.ReceiveTimeout = 1000;
MyHttpServerConnection serverConnection = new MyHttpServerConnection(basesocket);
asyncState.ReturnValue = (object) serverConnection;
}
catch (Exception ex1)
{
ProjectData.SetProjectError(ex1);
Exception ex2 = ex1;
asyncState.Complete(ex2);
ProjectData.ClearProjectError();
return;
}
asyncState.Complete();
}
public MyHttpServerConnection EndGetConnection(IAsyncResult ar)
{
MyAsyncResult myAsyncResult = (MyAsyncResult) ar;
myAsyncResult.AsyncEnd();
return (MyHttpServerConnection) myAsyncResult.ReturnValue;
}
public override string ToString()
{
return this.m_servername + " endpoint:" + this.m_endpoint.ToString();
}
}
}

View File

@@ -0,0 +1,29 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.MyHttpServerBadRequestException
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using System;
namespace Rei.Net.HttpServer
{
public class MyHttpServerBadRequestException : Exception
{
private MyHttpServerRequest _req;
internal MyHttpServerBadRequestException(MyHttpServerRequest req)
{
this._req = req;
this._req._badrequest = true;
}
public MyHttpServerRequest Request
{
get
{
return this._req;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.MyHttpServerConnectionClosedException
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using System;
namespace Rei.Net.HttpServer
{
public class MyHttpServerConnectionClosedException : Exception
{
internal MyHttpServerConnectionClosedException(string message)
: base(message)
{
}
public MyHttpServerConnectionClosedException(string message, Exception innerexception)
: base(message, innerexception)
{
}
}
}

View File

@@ -0,0 +1,155 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.MyHttpServerRequest
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using System;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
namespace Rei.Net.HttpServer
{
[DebuggerDisplay("{toString}")]
public class MyHttpServerRequest : IDisposable
{
internal bool _isvalidrequest;
internal string _requestline;
internal string _method;
internal string _version;
internal Uri _requesturi;
internal string _rawuri;
internal NameValueCollection _requestheaders;
internal long _contentlength;
internal Stream _reqstream;
internal string _host;
internal bool _badrequest;
internal bool _expect100continue;
private bool disposedValue;
internal MyHttpServerRequest()
{
this.disposedValue = false;
this._requestheaders = new NameValueCollection();
}
public Uri RequestUri
{
get
{
return this._requesturi;
}
set
{
this._requesturi = value;
}
}
public string Host
{
get
{
return this._host;
}
}
public string RawUri
{
get
{
return this._rawuri;
}
}
public string Method
{
get
{
return this._method;
}
}
public string Version
{
get
{
return this._version;
}
}
public string RequestLine
{
get
{
return this._requestline;
}
}
public NameValueCollection Headers
{
get
{
return this._requestheaders;
}
}
public long ContentLength
{
get
{
return this._contentlength;
}
}
public string ContentType
{
get
{
return this._requestheaders.Get("Content-Type");
}
}
public string UserAgent
{
get
{
return this._requestheaders.Get("User-Agent");
}
}
public bool Expect100Continue
{
get
{
return this._expect100continue;
}
}
public Stream InputStream
{
get
{
return this._reqstream;
}
}
protected virtual void Dispose(bool disposing)
{
if (!this.disposedValue && disposing)
this._reqstream.Close();
this.disposedValue = true;
}
public void Close()
{
this.Dispose(true);
GC.SuppressFinalize((object) this);
}
public override string ToString()
{
return this._requestline + " " + this._host;
}
}
}

View File

@@ -0,0 +1,88 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.MyHttpServerResponse
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic.CompilerServices;
using System.Collections.Specialized;
using System.Diagnostics;
namespace Rei.Net.HttpServer
{
[DebuggerDisplay("{toString}")]
public class MyHttpServerResponse
{
internal int _statuscode;
internal string _statusdesc;
internal NameValueCollection _responseheaders;
internal long _contentlength;
internal bool _sendchunked;
public MyHttpServerResponse()
{
this._responseheaders = new NameValueCollection();
}
public int StatusCode
{
get
{
return this._statuscode;
}
set
{
this._statuscode = value;
}
}
public string StatusDescription
{
get
{
return this._statusdesc;
}
set
{
this._statusdesc = value;
}
}
public long ContentLength
{
get
{
return this._contentlength;
}
set
{
this._contentlength = value;
}
}
public bool SendChunked
{
get
{
return this._sendchunked;
}
set
{
this._sendchunked = value;
}
}
public NameValueCollection Headers
{
get
{
return this._responseheaders;
}
}
public override string ToString()
{
return Conversions.ToString(this._statuscode) + " " + this._statusdesc + " " + Conversions.ToString(this._contentlength);
}
}
}

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--Project was exported from assembly: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll-->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5FF0F1E1-621A-478E-BA41-831A85C694EE}</ProjectGuid>
<OutputType>Library</OutputType>
<AssemblyName>Rei.Net.HttpServer</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ApplicationVersion>1.13.2.9297</ApplicationVersion>
<FileAlignment>512</FileAlignment>
<RootNamespace>Rei.Net.HttpServer</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MyEndPoint.cs" />
<Compile Include="LineReadableSocketStream.cs" />
<Compile Include="MyAsyncResult.cs" />
<Compile Include="MyHttpListener.cs" />
<Compile Include="MyHttpServerConnection.cs" />
<Compile Include="MyHttpServerRequest.cs" />
<Compile Include="MyHttpServerResponse.cs" />
<Compile Include="MyHttpServerBadRequestException.cs" />
<Compile Include="MyHttpServerConnectionClosedException.cs" />
<Compile Include="UPnPManager.cs" />
<Compile Include="My\MyApplication.cs" />
<Compile Include="My\MyComputer.cs" />
<Compile Include="My\MyProject.cs" />
<Compile Include="My\MySettings.cs" />
<Compile Include="My\MySettingsProperty.cs" />
<Compile Include="My\Resources\Resources.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources.resx" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,403 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Net.HttpServer.UPnPManager
// Assembly: Rei.Net.HttpServer, Version=1.13.2.9297, Culture=neutral, PublicKeyToken=null
// MVID: 6174F8E9-E7BA-46AD-8F2E-196645884F28
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Net.HttpServer.dll
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
namespace Rei.Net.HttpServer
{
public class UPnPManager : IDisposable
{
private static string servicetype_1 = "urn:schemas-upnp-org:service:WANIPConnection:1";
private static string servicetype_2 = "urn:schemas-upnp-org:service:WANPPPConnection:1";
private List<UPnPManager.portmappingentry> mappinglist;
private bool disposedValue;
private static Uri GetDeviceDocumentUri(IPAddress gatewayip)
{
IPEndPoint ipEndPoint = new IPEndPoint(gatewayip, 1900);
EndPoint remoteEP = (EndPoint) new IPEndPoint(IPAddress.Any, 0);
byte[] bytes = Encoding.UTF8.GetBytes("M-SEARCH * HTTP/1.1\r\nHost: " + gatewayip.ToString() + ":1900\r\nSt: upnp:rootdevice\r\nMan: \"ssdp:discover\"\r\nMx: 3\r\n\r\n\r\n");
string str1;
using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
{
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 3000);
socket.SendTo(bytes, 0, bytes.Length, SocketFlags.None, (EndPoint) ipEndPoint);
byte[] numArray = new byte[1025];
int from = socket.ReceiveFrom(numArray, 0, numArray.Length, SocketFlags.None, ref remoteEP);
str1 = Encoding.UTF8.GetString(numArray, 0, from);
}
if (string.IsNullOrEmpty(str1))
return (Uri) null;
string[] strArray = str1.Split(new char[2]
{
'\r',
'\n'
}, StringSplitOptions.RemoveEmptyEntries);
int index = 0;
while (index < strArray.Length)
{
string str2 = strArray[index];
if (str2.StartsWith("Location:", StringComparison.InvariantCultureIgnoreCase))
{
string uriString = str2.Substring(9).Trim();
Uri result = (Uri) null;
if (Uri.TryCreate(uriString, UriKind.Absolute, out result))
return result;
return (Uri) null;
}
checked { ++index; }
}
return (Uri) null;
}
private static string GetDeviceDocument(Uri u)
{
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(u);
httpWebRequest.Method = "GET";
httpWebRequest.KeepAlive = false;
httpWebRequest.Proxy = (IWebProxy) null;
httpWebRequest.Timeout = 3000;
string str = (string) null;
try
{
using (HttpWebResponse response = (HttpWebResponse) httpWebRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
str = streamReader.ReadToEnd();
}
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
ProjectData.ClearProjectError();
}
return str;
}
private static Uri FindControlUri(Uri baseuri, string document, string servicename)
{
int startIndex1 = document.IndexOf(servicename);
if (startIndex1 < 0)
return (Uri) null;
int startIndex2 = document.IndexOf("<controlURL>", startIndex1);
int num = document.IndexOf("</controlURL>", startIndex2);
return new Uri(baseuri, document.Substring(checked (startIndex2 + 12), checked (num - startIndex2 - 12)));
}
private static bool AddPortMapping(Uri controluri, string servicename, int externalport, IPAddress internalip, int internalport)
{
string s = "<?xml version=\"1.0\"?><s:Envelope xmlns:s:=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"> <s:Body> <m:AddPortMapping xmlns:m=\"" + servicename + "\"> <NewRemoteHost></NewRemoteHost> <NewExternalPort>" + externalport.ToString() + "</NewExternalPort> <NewProtocol>TCP</NewProtocol> <NewInternalPort>" + internalport.ToString() + "</NewInternalPort> <NewInternalClient>" + internalip.ToString() + "</NewInternalClient> <NewEnabled>1</NewEnabled> <NewPortMappingDescription></NewPortMappingDescription> <NewLeaseDuration>0</NewLeaseDuration> </m:AddPortMapping> </s:Body></s:Envelope>";
Encoding.UTF8.GetBytes(s);
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(controluri);
httpWebRequest.Method = "POST";
httpWebRequest.KeepAlive = false;
httpWebRequest.Proxy = (IWebProxy) null;
httpWebRequest.Timeout = 3000;
httpWebRequest.AllowWriteStreamBuffering = true;
httpWebRequest.SendChunked = false;
httpWebRequest.Headers.Add("Soapaction", servicename + "#AddPortMapping");
httpWebRequest.ContentType = "text/xml;charset=\\\"utf-8\\\"";
string str = (string) null;
try
{
using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
streamWriter.Write(s);
using (HttpWebResponse response = (HttpWebResponse) httpWebRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
str = streamReader.ReadToEnd();
if (response.StatusCode >= HttpStatusCode.OK)
{
if (response.StatusCode < HttpStatusCode.MultipleChoices)
goto label_18;
}
return false;
}
label_18:
return true;
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
ProjectData.ClearProjectError();
}
return false;
}
private static bool DeletePortMapping(Uri controluri, string servicename, int externalport)
{
string s = "<?xml version=\"1.0\"?><s:Envelope xmlns:s:=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"> <s:Body> <m:DeletePortMapping xmlns:m=\"" + servicename + "\"> <NewRemoteHost></NewRemoteHost> <NewExternalPort>" + externalport.ToString() + "</NewExternalPort> <NewProtocol>TCP</NewProtocol> </m:DeletePortMapping> </s:Body></s:Envelope>";
Encoding.UTF8.GetBytes(s);
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(controluri);
httpWebRequest.Method = "POST";
httpWebRequest.KeepAlive = false;
httpWebRequest.Proxy = (IWebProxy) null;
httpWebRequest.Timeout = 3000;
httpWebRequest.AllowWriteStreamBuffering = true;
httpWebRequest.SendChunked = false;
httpWebRequest.Headers.Add("Soapaction", servicename + "#DeletePortMapping");
httpWebRequest.ContentType = "text/xml;charset=\\\"utf-8\\\"";
string str = (string) null;
try
{
using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
streamWriter.Write(s);
using (HttpWebResponse response = (HttpWebResponse) httpWebRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
str = streamReader.ReadToEnd();
if (response.StatusCode >= HttpStatusCode.OK)
{
if (response.StatusCode < HttpStatusCode.MultipleChoices)
goto label_18;
}
return false;
}
label_18:
return true;
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
ProjectData.ClearProjectError();
}
return false;
}
private static IPAddress GetExternalIPAddress(Uri controluri, string servicename)
{
string s = "<?xml version=\"1.0\"?><s:Envelope xmlns:s:=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"> <s:Body> <m:GetExternalIPAddress xmlns:m=\"" + servicename + "\"> </m:GetExternalIPAddress> </s:Body></s:Envelope>";
Encoding.UTF8.GetBytes(s);
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(controluri);
httpWebRequest.Method = "POST";
httpWebRequest.KeepAlive = false;
httpWebRequest.Proxy = (IWebProxy) null;
httpWebRequest.Timeout = 3000;
httpWebRequest.AllowWriteStreamBuffering = true;
httpWebRequest.SendChunked = false;
httpWebRequest.Headers.Add("Soapaction", servicename + "#GetExternalIPAddress");
httpWebRequest.ContentType = "text/xml;charset=\\\"utf-8\\\"";
string str = (string) null;
try
{
using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
streamWriter.Write(s);
using (HttpWebResponse response = (HttpWebResponse) httpWebRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
str = streamReader.ReadToEnd();
if (response.StatusCode >= HttpStatusCode.OK)
{
if (response.StatusCode < HttpStatusCode.MultipleChoices)
goto label_18;
}
return (IPAddress) null;
}
label_18:
int startIndex = str.IndexOf("<NewExternalIPAddress>");
int num = str.IndexOf("</NewExternalIPAddress>", startIndex);
IPAddress address = (IPAddress) null;
if (IPAddress.TryParse(str.Substring(checked (startIndex + 22), checked (num - startIndex - 22)), out address))
return address;
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
ProjectData.ClearProjectError();
}
return (IPAddress) null;
}
public UPnPManager()
{
this.mappinglist = new List<UPnPManager.portmappingentry>();
this.disposedValue = false;
}
public IPEndPoint[] GetExternalEndpoints()
{
List<IPEndPoint> ipEndPointList = new List<IPEndPoint>();
List<UPnPManager.portmappingentry>.Enumerator enumerator;
try
{
enumerator = this.mappinglist.GetEnumerator();
while (enumerator.MoveNext())
{
UPnPManager.portmappingentry current = enumerator.Current;
ipEndPointList.Add(new IPEndPoint(current.externalip, current.externalport));
}
}
finally
{
enumerator.Dispose();
}
return ipEndPointList.ToArray();
}
public void AddPortMapping(bool all, int internalport)
{
Random random = new Random();
List<IPAddress> ipAddressList = new List<IPAddress>();
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
int index = 0;
while (index < networkInterfaces.Length)
{
NetworkInterface networkInterface = networkInterfaces[index];
try
{
if (networkInterface.NetworkInterfaceType != NetworkInterfaceType.Loopback)
{
if (networkInterface.NetworkInterfaceType != NetworkInterfaceType.Tunnel)
{
if (networkInterface.OperationalStatus == OperationalStatus.Up)
{
IPInterfaceProperties ipProperties = networkInterface.GetIPProperties();
IPAddress internalip = (IPAddress) null;
IEnumerator<UnicastIPAddressInformation> enumerator1;
try
{
enumerator1 = ipProperties.UnicastAddresses.GetEnumerator();
while (enumerator1.MoveNext())
{
UnicastIPAddressInformation current = enumerator1.Current;
if (current.Address.AddressFamily == AddressFamily.InterNetwork && !IPAddress.IsLoopback(current.Address))
{
internalip = current.Address;
break;
}
}
}
finally
{
if (enumerator1 != null)
enumerator1.Dispose();
}
IEnumerator<GatewayIPAddressInformation> enumerator2;
if (internalip != null)
{
try
{
enumerator2 = ipProperties.GatewayAddresses.GetEnumerator();
while (enumerator2.MoveNext())
{
GatewayIPAddressInformation current = enumerator2.Current;
if (!object.Equals((object) current.Address, (object) IPAddress.None) && !object.Equals((object) current.Address, (object) IPAddress.Any) && (!object.Equals((object) current.Address, (object) IPAddress.Broadcast) && !object.Equals((object) current.Address, (object) IPAddress.Loopback)))
{
UPnPManager.portmappingentry portmappingentry = new UPnPManager.portmappingentry();
Uri deviceDocumentUri = UPnPManager.GetDeviceDocumentUri(current.Address);
string deviceDocument = UPnPManager.GetDeviceDocument(deviceDocumentUri);
portmappingentry.servicename = UPnPManager.servicetype_1;
portmappingentry.controluri = UPnPManager.FindControlUri(deviceDocumentUri, deviceDocument, portmappingentry.servicename);
if ((object) portmappingentry.controluri == null)
{
portmappingentry.servicename = UPnPManager.servicetype_2;
portmappingentry.controluri = UPnPManager.FindControlUri(deviceDocumentUri, deviceDocument, portmappingentry.servicename);
}
if ((object) portmappingentry.controluri != null)
{
portmappingentry.externalip = UPnPManager.GetExternalIPAddress(portmappingentry.controluri, portmappingentry.servicename);
if (portmappingentry.externalip != null)
{
portmappingentry.externalport = internalport;
int num = 0;
do
{
try
{
if (UPnPManager.AddPortMapping(portmappingentry.controluri, portmappingentry.servicename, portmappingentry.externalport, internalip, internalport))
{
this.mappinglist.Add(portmappingentry);
if (!all)
return;
break;
}
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
ProjectData.ClearProjectError();
}
portmappingentry.externalport = random.Next(30000, 60000);
checked { ++num; }
}
while (num <= 10);
}
}
}
}
}
finally
{
if (enumerator2 != null)
enumerator2.Dispose();
}
}
}
}
}
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
ProjectData.ClearProjectError();
}
checked { ++index; }
}
}
public void DeletePortMapping()
{
while (this.mappinglist.Count > 0)
{
UPnPManager.portmappingentry portmappingentry = this.mappinglist[checked (this.mappinglist.Count - 1)];
try
{
UPnPManager.DeletePortMapping(portmappingentry.controluri, portmappingentry.servicename, portmappingentry.externalport);
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
ProjectData.ClearProjectError();
}
this.mappinglist.RemoveAt(checked (this.mappinglist.Count - 1));
}
}
protected virtual void Dispose(bool disposing)
{
if (!this.disposedValue && disposing)
this.DeletePortMapping();
this.disposedValue = true;
}
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize((object) this);
}
private class portmappingentry
{
public string servicename;
public Uri controluri;
public IPAddress externalip;
public int externalport;
[DebuggerNonUserCode]
public portmappingentry()
{
}
}
}
}