INetworkManager.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using MediaBrowser.Model.IO;
  5. using MediaBrowser.Model.Net;
  6. namespace MediaBrowser.Common.Net
  7. {
  8. public interface INetworkManager
  9. {
  10. event EventHandler NetworkChanged;
  11. /// <summary>
  12. /// Gets a random port number that is currently available
  13. /// </summary>
  14. /// <returns>System.Int32.</returns>
  15. int GetRandomUnusedTcpPort();
  16. int GetRandomUnusedUdpPort();
  17. Func<string[]> LocalSubnetsFn { get; set; }
  18. /// <summary>
  19. /// Returns MAC Address from first Network Card in Computer
  20. /// </summary>
  21. /// <returns>[string] MAC Address</returns>
  22. List<string> GetMacAddresses();
  23. /// <summary>
  24. /// Determines whether [is in private address space] [the specified endpoint].
  25. /// </summary>
  26. /// <param name="endpoint">The endpoint.</param>
  27. /// <returns><c>true</c> if [is in private address space] [the specified endpoint]; otherwise, <c>false</c>.</returns>
  28. bool IsInPrivateAddressSpace(string endpoint);
  29. /// <summary>
  30. /// Gets the network shares.
  31. /// </summary>
  32. /// <param name="path">The path.</param>
  33. /// <returns>IEnumerable{NetworkShare}.</returns>
  34. IEnumerable<NetworkShare> GetNetworkShares(string path);
  35. /// <summary>
  36. /// Gets available devices within the domain
  37. /// </summary>
  38. /// <returns>PC's in the Domain</returns>
  39. IEnumerable<FileSystemEntryInfo> GetNetworkDevices();
  40. /// <summary>
  41. /// Determines whether [is in local network] [the specified endpoint].
  42. /// </summary>
  43. /// <param name="endpoint">The endpoint.</param>
  44. /// <returns><c>true</c> if [is in local network] [the specified endpoint]; otherwise, <c>false</c>.</returns>
  45. bool IsInLocalNetwork(string endpoint);
  46. IpAddressInfo[] GetLocalIpAddresses(bool ignoreVirtualInterface);
  47. IpAddressInfo ParseIpAddress(string ipAddress);
  48. bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo);
  49. Task<IpAddressInfo[]> GetHostAddressesAsync(string host);
  50. bool IsAddressInSubnets(string addressString, string[] subnets);
  51. bool IsInSameSubnet(IpAddressInfo address1, IpAddressInfo address2, IpAddressInfo subnetMask);
  52. IpAddressInfo GetLocalIpSubnetMask(IpAddressInfo address);
  53. }
  54. }