using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net;
using System.Net.NetworkInformation;
using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Common.Net
{
    /// 
    /// Interface for the NetworkManager class.
    /// 
    public interface INetworkManager
    {
        /// 
        /// Event triggered on network changes.
        /// 
        event EventHandler NetworkChanged;
        /// 
        /// Gets the published server urls list.
        /// 
        Dictionary PublishedServerUrls { get; }
        /// 
        /// Gets a value indicating whether is all IPv6 interfaces are trusted as internal.
        /// 
        bool TrustAllIP6Interfaces { get; }
        /// 
        /// Gets the remote address filter.
        /// 
        Collection RemoteAddressFilter { get; }
        /// 
        /// Gets or sets a value indicating whether iP6 is enabled.
        /// 
        bool IsIP6Enabled { get; set; }
        /// 
        /// Gets or sets a value indicating whether iP4 is enabled.
        /// 
        bool IsIP4Enabled { get; set; }
        /// 
        /// Calculates the list of interfaces to use for Kestrel.
        /// 
        /// A Collection{IPObject} object containing all the interfaces to bind.
        /// If all the interfaces are specified, and none are excluded, it returns zero items
        /// to represent any address.
        /// When false, return  or  for all interfaces.
        Collection GetAllBindInterfaces(bool individualInterfaces = false);
        /// 
        /// Returns a collection containing the loopback interfaces.
        /// 
        /// Collection{IPObject}.
        Collection GetLoopbacks();
        /// 
        /// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
        /// If no bind addresses are specified, an internal interface address is selected.
        /// The priority of selection is as follows:-
        ///
        /// The value contained in the startup parameter --published-server-url.
        ///
        /// If the user specified custom subnet overrides, the correct subnet for the source address.
        ///
        /// If the user specified bind interfaces to use:-
        ///  The bind interface that contains the source subnet.
        ///  The first bind interface specified that suits best first the source's endpoint. eg. external or internal.
        ///
        /// If the source is from a public subnet address range and the user hasn't specified any bind addresses:-
        ///  The first public interface that isn't a loopback and contains the source subnet.
        ///  The first public interface that isn't a loopback. Priority is given to interfaces with gateways.
        ///  An internal interface if there are no public ip addresses.
        ///
        /// If the source is from a private subnet address range and the user hasn't specified any bind addresses:-
        ///  The first private interface that contains the source subnet.
        ///  The first private interface that isn't a loopback. Priority is given to interfaces with gateways.
        ///
        /// If no interfaces meet any of these criteria, then a loopback address is returned.
        ///
        /// Interface that have been specifically excluded from binding are not used in any of the calculations.
        /// 
        /// Source of the request.
        /// Optional port returned, if it's part of an override.
        /// IP Address to use, or loopback address if all else fails.
        string GetBindInterface(IPObject source, out int? port);
        /// 
        /// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
        /// If no bind addresses are specified, an internal interface address is selected.
        /// (See .
        /// 
        /// Source of the request.
        /// Optional port returned, if it's part of an override.
        /// IP Address to use, or loopback address if all else fails.
        string GetBindInterface(HttpRequest source, out int? port);
        /// 
        /// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
        /// If no bind addresses are specified, an internal interface address is selected.
        /// (See .
        /// 
        /// IP address of the request.
        /// Optional port returned, if it's part of an override.
        /// IP Address to use, or loopback address if all else fails.
        string GetBindInterface(IPAddress source, out int? port);
        /// 
        /// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
        /// If no bind addresses are specified, an internal interface address is selected.
        /// (See .
        /// 
        /// Source of the request.
        /// Optional port returned, if it's part of an override.
        /// IP Address to use, or loopback address if all else fails.
        string GetBindInterface(string source, out int? port);
        /// 
        /// Checks to see if the ip address is specifically excluded in LocalNetworkAddresses.
        /// 
        /// IP address to check.
        /// True if it is.
        bool IsExcludedInterface(IPAddress address);
        /// 
        /// Get a list of all the MAC addresses associated with active interfaces.
        /// 
        /// List of MAC addresses.
        IReadOnlyCollection GetMacAddresses();
        /// 
        /// Checks to see if the IP Address provided matches an interface that has a gateway.
        /// 
        /// IP to check. Can be an IPAddress or an IPObject.
        /// Result of the check.
        bool IsGatewayInterface(IPObject? addressObj);
        /// 
        /// Checks to see if the IP Address provided matches an interface that has a gateway.
        /// 
        /// IP to check. Can be an IPAddress or an IPObject.
        /// Result of the check.
        bool IsGatewayInterface(IPAddress? addressObj);
        /// 
        /// Returns true if the address is a private address.
        /// The configuration option TrustIP6Interfaces overrides this functions behaviour.
        /// 
        /// Address to check.
        /// True or False.
        bool IsPrivateAddressRange(IPObject address);
        /// 
        /// Returns true if the address is part of the user defined LAN.
        /// The configuration option TrustIP6Interfaces overrides this functions behaviour.
        /// 
        /// IP to check.
        /// True if endpoint is within the LAN range.
        bool IsInLocalNetwork(string address);
        /// 
        /// Returns true if the address is part of the user defined LAN.
        /// The configuration option TrustIP6Interfaces overrides this functions behaviour.
        /// 
        /// IP to check.
        /// True if endpoint is within the LAN range.
        bool IsInLocalNetwork(IPObject address);
        /// 
        /// Returns true if the address is part of the user defined LAN.
        /// The configuration option TrustIP6Interfaces overrides this functions behaviour.
        /// 
        /// IP to check.
        /// True if endpoint is within the LAN range.
        bool IsInLocalNetwork(IPAddress address);
        /// 
        /// Attempts to convert the token to an IP address, permitting for interface descriptions and indexes.
        /// eg. "eth1", or "TP-LINK Wireless USB Adapter".
        /// 
        /// Token to parse.
        /// Resultant object's ip addresses, if successful.
        /// Success of the operation.
        bool TryParseInterface(string token, out Collection? result);
        /// 
        /// Parses an array of strings into a Collection{IPObject}.
        /// 
        /// Values to parse.
        /// When true, only include values beginning with !. When false, ignore ! values.
        /// IPCollection object containing the value strings.
        Collection CreateIPCollection(string[] values, bool negated = false);
        /// 
        /// Returns all the internal Bind interface addresses.
        /// 
        /// An internal list of interfaces addresses.
        Collection GetInternalBindAddresses();
        /// 
        /// Checks to see if an IP address is still a valid interface address.
        /// 
        /// IP address to check.
        /// True if it is.
        bool IsValidInterfaceAddress(IPAddress address);
        /// 
        /// Returns true if the IP address is in the excluded list.
        /// 
        /// IP to check.
        /// True if excluded.
        bool IsExcluded(IPAddress ip);
        /// 
        /// Returns true if the IP address is in the excluded list.
        /// 
        /// IP to check.
        /// True if excluded.
        bool IsExcluded(EndPoint ip);
        /// 
        /// Gets the filtered LAN ip addresses.
        /// 
        /// Optional filter for the list.
        /// Returns a filtered list of LAN addresses.
        Collection GetFilteredLANSubnets(Collection? filter = null);
        /// 
        /// Checks to see if  has access.
        /// 
        /// IP Address of client.
        /// True if has access, otherwise false.
        bool HasRemoteAccess(IPAddress remoteIp);
    }
}