2019-10-09 15:10:16 +00:00
#pragma warning disable CS1591
2018-12-27 23:27:57 +00:00
using System ;
2019-01-13 19:25:11 +00:00
using System.Collections.Generic ;
2019-07-07 19:03:26 +00:00
using System.Net ;
2019-08-09 21:16:24 +00:00
using System.Net.NetworkInformation ;
2018-12-27 23:27:57 +00:00
namespace MediaBrowser.Common.Net
{
public interface INetworkManager
{
event EventHandler NetworkChanged ;
2020-04-29 11:24:01 +00:00
/// <summary>
/// Contains a function to return the list of user defined LAN addresses
/// </summary>
2019-12-10 23:13:57 +00:00
Func < string [ ] > LocalSubnetsFn { get ; set ; }
2018-12-27 23:27:57 +00:00
/// <summary>
2020-04-29 11:24:01 +00:00
/// Gets a random port TCP number that is currently available.
2018-12-27 23:27:57 +00:00
/// </summary>
/// <returns>System.Int32.</returns>
int GetRandomUnusedTcpPort ( ) ;
2020-04-29 11:24:01 +00:00
/// <summary>
/// Gets a random port UDP number that is currently available.
/// </summary>
/// <returns>System.Int32.</returns>
2018-12-27 23:27:57 +00:00
int GetRandomUnusedUdpPort ( ) ;
/// <summary>
2019-12-10 23:13:57 +00:00
/// Returns the MAC Address from first Network Card in Computer.
2018-12-27 23:27:57 +00:00
/// </summary>
2019-12-10 23:13:57 +00:00
/// <returns>The MAC Address.</returns>
2019-08-09 21:16:24 +00:00
List < PhysicalAddress > GetMacAddresses ( ) ;
2018-12-27 23:27:57 +00:00
/// <summary>
/// Determines whether [is in private address space] [the specified endpoint].
/// </summary>
/// <param name="endpoint">The endpoint.</param>
/// <returns><c>true</c> if [is in private address space] [the specified endpoint]; otherwise, <c>false</c>.</returns>
bool IsInPrivateAddressSpace ( string endpoint ) ;
2020-04-29 11:24:01 +00:00
/// <summary>
/// Determines whether [is in private address space 10.x.x.x] [the specified endpoint] and exists in the subnets returned by GetSubnets().
/// </summary>
/// <param name="endpoint">The endpoint.</param>
/// <returns><c>true</c> if [is in private address space 10.x.x.x] [the specified endpoint]; otherwise, <c>false</c>.</returns>
bool IsInPrivateAddressSpaceAndLocalSubnet ( string endpoint ) ;
2018-12-27 23:27:57 +00:00
/// <summary>
/// Determines whether [is in local network] [the specified endpoint].
/// </summary>
/// <param name="endpoint">The endpoint.</param>
/// <returns><c>true</c> if [is in local network] [the specified endpoint]; otherwise, <c>false</c>.</returns>
bool IsInLocalNetwork ( string endpoint ) ;
2020-04-29 11:24:01 +00:00
/// <summary>
/// Investigates an caches a list of interface addresses, excluding local link and LAN excluded addresses
/// </summary>
/// <returns>The list of ipaddresses</returns>
2020-04-28 20:57:39 +00:00
IPAddress [ ] GetLocalIpAddresses ( ) ;
2020-04-29 11:24:01 +00:00
/// <summary>
2020-05-17 19:43:54 +00:00
/// Checks if the given address falls within the ranges given in [subnets]. The addresses in subnets can be hosts or subnets in the CIDR format.
2020-04-29 11:24:01 +00:00
/// </summary>
/// <param name="addressString">The address to check</param>
2020-05-17 19:44:19 +00:00
/// <param name="subnets">If true, check against addresses in the LAN settings surrounded by brackets ([])</param>
2020-05-17 19:44:35 +00:00
/// <returns><c>true</c>if the address is in at least one of the given subnets, <c>false</c> otherwise.</returns>
2018-12-27 23:27:57 +00:00
bool IsAddressInSubnets ( string addressString , string [ ] subnets ) ;
2019-02-22 04:06:49 +00:00
2020-04-29 11:24:01 +00:00
/// <summary>
/// Returns true if address is in the LAN list in the config file
/// </summary>
/// <param name="address">The address to check</param>
/// <param name="excludeInterfaces">If true, check against addresses in the LAN settings which have [] arroud and return true if it matches the address give in address</param>
/// <param name="excludeRFC">If true, returns false if address is in the 127.x.x.x or 169.128.x.x range</param>
/// <returns><c>false</c>if the address isn't in the LAN list, <c>true</c> if the address has been defined as a LAN address</returns>
2020-04-28 20:57:39 +00:00
bool IsAddressInSubnets ( IPAddress address , bool excludeInterfaces , bool excludeRFC ) ;
2020-04-29 11:24:01 +00:00
/// <summary>
/// Checks if address is in the LAN list in the config file
/// </summary>
/// <param name="address1">Source address to check</param>
/// <param name="address2">Destination address to check against</param>
/// <param name="subnetMask">Destination subnet to check against</param>
/// <returns><c>true/false</c>depending on whether address1 is in the same subnet as IPAddress2 with subnetMas</returns>
2019-07-07 19:03:26 +00:00
bool IsInSameSubnet ( IPAddress address1 , IPAddress address2 , IPAddress subnetMask ) ;
2020-04-29 11:24:01 +00:00
/// <summary>
/// Returns the subnet mask of an interface with the given address
/// </summary>
/// <param name="address">The address to check</param>
/// <returns>Returns the subnet mask of an interface with the given address, or null if an interface match cannot be found</returns>
2019-07-07 19:03:26 +00:00
IPAddress GetLocalIpSubnetMask ( IPAddress address ) ;
2018-12-27 23:27:57 +00:00
}
2019-01-13 19:30:41 +00:00
}