From bdcaf5dd023a6bc0470915e07cc7fe7a46cb6c5d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 27 Oct 2016 23:11:21 -0400 Subject: [PATCH] trim nat project --- .../Archiving/ZipClient.cs | 4 +- .../EntryPoints/ExternalPortForwarding.cs | 19 - Mono.Nat/AbstractNatDevice.cs | 38 -- Mono.Nat/INatDevice.cs | 18 - Mono.Nat/Mono.Nat.csproj | 12 +- Mono.Nat/NatUtility.cs | 19 +- Mono.Nat/Pmp/PmpNatDevice.cs | 338 ++++++-------- .../AsyncResults/GetAllMappingsAsyncResult.cs | 56 --- .../Upnp/AsyncResults/PortMapAsyncResult.cs | 75 --- Mono.Nat/Upnp/Messages/ErrorMessage.cs | 5 - Mono.Nat/Upnp/Messages/GetServicesMessage.cs | 11 - .../Requests/CreatePortMappingMessage.cs | 20 - .../Requests/DeletePortMappingMessage.cs | 71 --- .../Requests/GetExternalIPAddressMessage.cs | 56 --- .../Requests/GetGenericPortMappingEntry.cs | 67 --- .../GetSpecificPortMappingEntryMessage.cs | 74 --- .../CreatePortMappingResponseMessage.cs | 5 - .../DeletePortMappingResponseMessage.cs | 51 --- .../GetExternalIPAddressResponseMessage.cs | 59 --- ...tGenericPortMappingEntryResponseMessage.cs | 114 ----- Mono.Nat/Upnp/Messages/UpnpMessage.cs | 70 --- Mono.Nat/Upnp/UpnpNatDevice.cs | 433 +----------------- 22 files changed, 151 insertions(+), 1464 deletions(-) delete mode 100644 Mono.Nat/Upnp/AsyncResults/GetAllMappingsAsyncResult.cs delete mode 100644 Mono.Nat/Upnp/AsyncResults/PortMapAsyncResult.cs delete mode 100644 Mono.Nat/Upnp/Messages/Requests/DeletePortMappingMessage.cs delete mode 100644 Mono.Nat/Upnp/Messages/Requests/GetExternalIPAddressMessage.cs delete mode 100644 Mono.Nat/Upnp/Messages/Requests/GetGenericPortMappingEntry.cs delete mode 100644 Mono.Nat/Upnp/Messages/Requests/GetSpecificPortMappingEntryMessage.cs delete mode 100644 Mono.Nat/Upnp/Messages/Responses/DeletePortMappingResponseMessage.cs delete mode 100644 Mono.Nat/Upnp/Messages/Responses/GetExternalIPAddressResponseMessage.cs delete mode 100644 Mono.Nat/Upnp/Messages/Responses/GetGenericPortMappingEntryResponseMessage.cs diff --git a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs index 89cde3ff83..24e816aefe 100644 --- a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs +++ b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs @@ -6,8 +6,6 @@ using SharpCompress.Common; using SharpCompress.Reader; using SharpCompress.Reader.Zip; using System.IO; -using MediaBrowser.Common.IO; -using MediaBrowser.Model.IO; namespace MediaBrowser.Common.Implementations.Archiving { @@ -16,7 +14,7 @@ namespace MediaBrowser.Common.Implementations.Archiving /// public class ZipClient : IZipClient { - private IFileSystem _fileSystem; + private readonly IFileSystem _fileSystem; public ZipClient(IFileSystem fileSystem) { diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index 3d860a27bd..9db49f97ae 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -91,9 +91,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints NatUtility.DeviceLost += NatUtility_DeviceLost; - // it is hard to say what one should do when an unhandled exception is raised - // because there isn't anything one can do about it. Probably save a log or ignored it. - NatUtility.UnhandledException += NatUtility_UnhandledException; NatUtility.StartDiscovery(); _timer = new PeriodicTimer(ClearCreatedRules, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); @@ -184,21 +181,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints } } - void NatUtility_UnhandledException(object sender, UnhandledExceptionEventArgs e) - { - var ex = e.ExceptionObject as Exception; - - if (ex == null) - { - //_logger.Error("Unidentified error reported by Mono.Nat"); - } - else - { - // Seeing some blank exceptions coming through here - //_logger.ErrorException("Error reported by Mono.Nat: ", ex); - } - } - void NatUtility_DeviceFound(object sender, DeviceEventArgs e) { try @@ -287,7 +269,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints NatUtility.StopDiscovery(); NatUtility.DeviceFound -= NatUtility_DeviceFound; NatUtility.DeviceLost -= NatUtility_DeviceLost; - NatUtility.UnhandledException -= NatUtility_UnhandledException; } // Statements in try-block will no fail because StopDiscovery is a one-line // method that was no chances to fail. diff --git a/Mono.Nat/AbstractNatDevice.cs b/Mono.Nat/AbstractNatDevice.cs index e998a6ea45..1b42160025 100644 --- a/Mono.Nat/AbstractNatDevice.cs +++ b/Mono.Nat/AbstractNatDevice.cs @@ -52,43 +52,5 @@ namespace Mono.Nat } public abstract Task CreatePortMap(Mapping mapping); - - public virtual void DeletePortMap (Mapping mapping) - { - IAsyncResult result = BeginDeletePortMap (mapping, null, mapping); - EndDeletePortMap(result); - } - - public virtual Mapping[] GetAllMappings () - { - IAsyncResult result = BeginGetAllMappings (null, null); - return EndGetAllMappings (result); - } - - public virtual IPAddress GetExternalIP () - { - IAsyncResult result = BeginGetExternalIP(null, null); - return EndGetExternalIP(result); - } - - public virtual Mapping GetSpecificMapping (Protocol protocol, int port) - { - IAsyncResult result = this.BeginGetSpecificMapping (protocol, port, null, null); - return this.EndGetSpecificMapping(result); - } - - public abstract IAsyncResult BeginCreatePortMap(Mapping mapping, AsyncCallback callback, object asyncState); - public abstract IAsyncResult BeginDeletePortMap (Mapping mapping, AsyncCallback callback, object asyncState); - - public abstract IAsyncResult BeginGetAllMappings (AsyncCallback callback, object asyncState); - public abstract IAsyncResult BeginGetExternalIP (AsyncCallback callback, object asyncState); - public abstract IAsyncResult BeginGetSpecificMapping(Protocol protocol, int externalPort, AsyncCallback callback, object asyncState); - - public abstract void EndCreatePortMap (IAsyncResult result); - public abstract void EndDeletePortMap (IAsyncResult result); - - public abstract Mapping[] EndGetAllMappings (IAsyncResult result); - public abstract IPAddress EndGetExternalIP (IAsyncResult result); - public abstract Mapping EndGetSpecificMapping (IAsyncResult result); } } diff --git a/Mono.Nat/INatDevice.cs b/Mono.Nat/INatDevice.cs index 44ba5223b5..b0401627ba 100644 --- a/Mono.Nat/INatDevice.cs +++ b/Mono.Nat/INatDevice.cs @@ -37,26 +37,8 @@ namespace Mono.Nat public interface INatDevice { Task CreatePortMap (Mapping mapping); - void DeletePortMap (Mapping mapping); IPAddress LocalAddress { get; } - Mapping[] GetAllMappings (); - IPAddress GetExternalIP (); - Mapping GetSpecificMapping (Protocol protocol, int port); - - IAsyncResult BeginCreatePortMap (Mapping mapping, AsyncCallback callback, object asyncState); - IAsyncResult BeginDeletePortMap (Mapping mapping, AsyncCallback callback, object asyncState); - - IAsyncResult BeginGetAllMappings (AsyncCallback callback, object asyncState); - IAsyncResult BeginGetExternalIP (AsyncCallback callback, object asyncState); - IAsyncResult BeginGetSpecificMapping (Protocol protocol, int externalPort, AsyncCallback callback, object asyncState); - - void EndCreatePortMap (IAsyncResult result); - void EndDeletePortMap (IAsyncResult result); - - Mapping[] EndGetAllMappings (IAsyncResult result); - IPAddress EndGetExternalIP (IAsyncResult result); - Mapping EndGetSpecificMapping (IAsyncResult result); DateTime LastSeen { get; set; } } diff --git a/Mono.Nat/Mono.Nat.csproj b/Mono.Nat/Mono.Nat.csproj index c9d79bbdfd..273bdb20c4 100644 --- a/Mono.Nat/Mono.Nat.csproj +++ b/Mono.Nat/Mono.Nat.csproj @@ -56,20 +56,11 @@ - - - - - - - - - @@ -89,6 +80,9 @@ MediaBrowser.Model + + +