NetworkParseTests.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. using System;
  2. using System.Net;
  3. using Jellyfin.Networking.Configuration;
  4. using Jellyfin.Networking.Manager;
  5. using MediaBrowser.Common.Configuration;
  6. using MediaBrowser.Common.Net;
  7. using Moq;
  8. using Microsoft.Extensions.Logging.Abstractions;
  9. using Xunit;
  10. using System.Collections.ObjectModel;
  11. namespace Jellyfin.Networking.Tests
  12. {
  13. public class NetworkParseTests
  14. {
  15. /// <summary>
  16. /// Tries to identify the string and return an object of that class.
  17. /// </summary>
  18. /// <param name="addr">String to parse.</param>
  19. /// <param name="result">IPObject to return.</param>
  20. /// <returns>True if the value parsed successfully.</returns>
  21. private static bool TryParse(string addr, out IPObject result)
  22. {
  23. if (!string.IsNullOrEmpty(addr))
  24. {
  25. // Is it an IP address
  26. if (IPNetAddress.TryParse(addr, out IPNetAddress nw))
  27. {
  28. result = nw;
  29. return true;
  30. }
  31. if (IPHost.TryParse(addr, out IPHost h))
  32. {
  33. result = h;
  34. return true;
  35. }
  36. }
  37. result = IPNetAddress.None;
  38. return false;
  39. }
  40. private static IConfigurationManager GetMockConfig(NetworkConfiguration conf)
  41. {
  42. var configManager = new Mock<IConfigurationManager>
  43. {
  44. CallBase = true
  45. };
  46. configManager.Setup(x => x.GetConfiguration(It.IsAny<string>())).Returns(conf);
  47. return (IConfigurationManager)configManager.Object;
  48. }
  49. /// <summary>
  50. /// Checks the ability to ignore interfaces
  51. /// </summary>
  52. /// <param name="interfaces">Mock network setup, in the format (IP address, interface index, interface name) | .... </param>
  53. /// <param name="lan">LAN addresses.</param>
  54. /// <param name="value">Bind addresses that are excluded.</param>
  55. [Theory]
  56. [InlineData("192.168.1.208/24,-16,eth16|200.200.200.200/24,11,eth11", "192.168.1.0/24;200.200.200.0/24", "[192.168.1.208/24,200.200.200.200/24]")]
  57. [InlineData("192.168.1.208/24,-16,eth16|200.200.200.200/24,11,eth11", "192.168.1.0/24", "[192.168.1.208/24]")]
  58. [InlineData("192.168.1.208/24,-16,vEthernet1|192.168.1.208/24,-16,vEthernet212|200.200.200.200/24,11,eth11", "192.168.1.0/24", "[192.168.1.208/24]")]
  59. public void IgnoreVirtualInterfaces(string interfaces, string lan, string value)
  60. {
  61. var conf = new NetworkConfiguration()
  62. {
  63. EnableIPV6 = true,
  64. EnableIPV4 = true,
  65. LocalNetworkSubnets = lan?.Split(';') ?? throw new ArgumentNullException(nameof(lan))
  66. };
  67. NetworkManager.MockNetworkSettings = interfaces;
  68. using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
  69. NetworkManager.MockNetworkSettings = string.Empty;
  70. Assert.Equal(nm.GetInternalBindAddresses().AsString(), value);
  71. }
  72. /// <summary>
  73. /// Check that the value given is in the network provided.
  74. /// </summary>
  75. /// <param name="network">Network address.</param>
  76. /// <param name="value">Value to check.</param>
  77. [Theory]
  78. [InlineData("192.168.10.0/24, !192.168.10.60/32", "192.168.10.60")]
  79. public void IsInNetwork(string network, string value)
  80. {
  81. if (network == null)
  82. {
  83. throw new ArgumentNullException(nameof(network));
  84. }
  85. var conf = new NetworkConfiguration()
  86. {
  87. EnableIPV6 = true,
  88. EnableIPV4 = true,
  89. LocalNetworkSubnets = network.Split(',')
  90. };
  91. using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
  92. Assert.False(nm.IsInLocalNetwork(value));
  93. }
  94. /// <summary>
  95. /// Checks IP address formats.
  96. /// </summary>
  97. /// <param name="address"></param>
  98. [Theory]
  99. [InlineData("127.0.0.1")]
  100. [InlineData("127.0.0.1:123")]
  101. [InlineData("localhost")]
  102. [InlineData("localhost:1345")]
  103. [InlineData("www.google.co.uk")]
  104. [InlineData("fd23:184f:2029:0:3139:7386:67d7:d517")]
  105. [InlineData("fd23:184f:2029:0:3139:7386:67d7:d517/56")]
  106. [InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517]:124")]
  107. [InlineData("fe80::7add:12ff:febb:c67b%16")]
  108. [InlineData("[fe80::7add:12ff:febb:c67b%16]:123")]
  109. [InlineData("192.168.1.2/255.255.255.0")]
  110. [InlineData("192.168.1.2/24")]
  111. public void ValidIPStrings(string address)
  112. {
  113. Assert.True(TryParse(address, out _));
  114. }
  115. /// <summary>
  116. /// All should be invalid address strings.
  117. /// </summary>
  118. /// <param name="address">Invalid address strings.</param>
  119. [Theory]
  120. [InlineData("256.128.0.0.0.1")]
  121. [InlineData("127.0.0.1#")]
  122. [InlineData("localhost!")]
  123. [InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
  124. [InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
  125. public void InvalidAddressString(string address)
  126. {
  127. Assert.False(TryParse(address, out _));
  128. }
  129. /// <summary>
  130. /// Test collection parsing.
  131. /// </summary>
  132. /// <param name="settings">Collection to parse.</param>
  133. /// <param name="result1">Included addresses from the collection.</param>
  134. /// <param name="result2">Included IP4 addresses from the collection.</param>
  135. /// <param name="result3">Excluded addresses from the collection.</param>
  136. /// <param name="result4">Excluded IP4 addresses from the collection.</param>
  137. /// <param name="result5">Network addresses of the collection.</param>
  138. [Theory]
  139. [InlineData("127.0.0.1#",
  140. "[]",
  141. "[]",
  142. "[]",
  143. "[]",
  144. "[]")]
  145. [InlineData("!127.0.0.1",
  146. "[]",
  147. "[]",
  148. "[127.0.0.1/32]",
  149. "[127.0.0.1/32]",
  150. "[]")]
  151. [InlineData("",
  152. "[]",
  153. "[]",
  154. "[]",
  155. "[]",
  156. "[]")]
  157. [InlineData(
  158. "192.158.1.2/16, localhost, fd23:184f:2029:0:3139:7386:67d7:d517, !10.10.10.10",
  159. "[192.158.1.2/16,127.0.0.1/32,fd23:184f:2029:0:3139:7386:67d7:d517/128]",
  160. "[192.158.1.2/16,127.0.0.1/32]",
  161. "[10.10.10.10/32]",
  162. "[10.10.10.10/32]",
  163. "[192.158.0.0/16,127.0.0.1/32,fd23:184f:2029:0:3139:7386:67d7:d517/128]")]
  164. [InlineData("192.158.1.2/255.255.0.0,192.169.1.2/8",
  165. "[192.158.1.2/16,192.169.1.2/8]",
  166. "[192.158.1.2/16,192.169.1.2/8]",
  167. "[]",
  168. "[]",
  169. "[192.158.0.0/16,192.0.0.0/8]")]
  170. public void TestCollections(string settings, string result1, string result2, string result3, string result4, string result5)
  171. {
  172. if (settings == null)
  173. {
  174. throw new ArgumentNullException(nameof(settings));
  175. }
  176. var conf = new NetworkConfiguration()
  177. {
  178. EnableIPV6 = true,
  179. EnableIPV4 = true,
  180. };
  181. using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
  182. // Test included.
  183. Collection<IPObject> nc = nm.CreateIPCollection(settings.Split(","), false);
  184. Assert.Equal(nc.AsString(), result1);
  185. // Test excluded.
  186. nc = nm.CreateIPCollection(settings.Split(","), true);
  187. Assert.Equal(nc.AsString(), result3);
  188. conf.EnableIPV6 = false;
  189. nm.UpdateSettings(conf);
  190. // Test IP4 included.
  191. nc = nm.CreateIPCollection(settings.Split(","), false);
  192. Assert.Equal(nc.AsString(), result2);
  193. // Test IP4 excluded.
  194. nc = nm.CreateIPCollection(settings.Split(","), true);
  195. Assert.Equal(nc.AsString(), result4);
  196. conf.EnableIPV6 = true;
  197. nm.UpdateSettings(conf);
  198. // Test network addresses of collection.
  199. nc = nm.CreateIPCollection(settings.Split(","), false);
  200. nc = nc.AsNetworks();
  201. Assert.Equal(nc.AsString(), result5);
  202. }
  203. /// <summary>
  204. /// Union two collections.
  205. /// </summary>
  206. /// <param name="settings">Source.</param>
  207. /// <param name="compare">Destination.</param>
  208. /// <param name="result">Result.</param>
  209. [Theory]
  210. [InlineData("127.0.0.1", "fd23:184f:2029:0:3139:7386:67d7:d517/64,fd23:184f:2029:0:c0f0:8a8a:7605:fffa/128,fe80::3139:7386:67d7:d517%16/64,192.168.1.208/24,::1/128,127.0.0.1/8", "[127.0.0.1/32]")]
  211. [InlineData("127.0.0.1", "127.0.0.1/8", "[127.0.0.1/32]")]
  212. public void UnionCheck(string settings, string compare, string result)
  213. {
  214. if (settings == null)
  215. {
  216. throw new ArgumentNullException(nameof(settings));
  217. }
  218. if (compare == null)
  219. {
  220. throw new ArgumentNullException(nameof(compare));
  221. }
  222. if (result == null)
  223. {
  224. throw new ArgumentNullException(nameof(result));
  225. }
  226. var conf = new NetworkConfiguration()
  227. {
  228. EnableIPV6 = true,
  229. EnableIPV4 = true,
  230. };
  231. using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
  232. Collection<IPObject> nc1 = nm.CreateIPCollection(settings.Split(","), false);
  233. Collection<IPObject> nc2 = nm.CreateIPCollection(compare.Split(","), false);
  234. Assert.Equal(nc1.Union(nc2).AsString(), result);
  235. }
  236. [Theory]
  237. [InlineData("192.168.5.85/24", "192.168.5.1")]
  238. [InlineData("192.168.5.85/24", "192.168.5.254")]
  239. [InlineData("10.128.240.50/30", "10.128.240.48")]
  240. [InlineData("10.128.240.50/30", "10.128.240.49")]
  241. [InlineData("10.128.240.50/30", "10.128.240.50")]
  242. [InlineData("10.128.240.50/30", "10.128.240.51")]
  243. [InlineData("127.0.0.1/8", "127.0.0.1")]
  244. public void IpV4SubnetMaskMatchesValidIpAddress(string netMask, string ipAddress)
  245. {
  246. var ipAddressObj = IPNetAddress.Parse(netMask);
  247. Assert.True(ipAddressObj.Contains(IPAddress.Parse(ipAddress)));
  248. }
  249. [Theory]
  250. [InlineData("192.168.5.85/24", "192.168.4.254")]
  251. [InlineData("192.168.5.85/24", "191.168.5.254")]
  252. [InlineData("10.128.240.50/30", "10.128.240.47")]
  253. [InlineData("10.128.240.50/30", "10.128.240.52")]
  254. [InlineData("10.128.240.50/30", "10.128.239.50")]
  255. [InlineData("10.128.240.50/30", "10.127.240.51")]
  256. public void IpV4SubnetMaskDoesNotMatchInvalidIpAddress(string netMask, string ipAddress)
  257. {
  258. var ipAddressObj = IPNetAddress.Parse(netMask);
  259. Assert.False(ipAddressObj.Contains(IPAddress.Parse(ipAddress)));
  260. }
  261. [Theory]
  262. [InlineData("2001:db8:abcd:0012::0/64", "2001:0DB8:ABCD:0012:0000:0000:0000:0000")]
  263. [InlineData("2001:db8:abcd:0012::0/64", "2001:0DB8:ABCD:0012:FFFF:FFFF:FFFF:FFFF")]
  264. [InlineData("2001:db8:abcd:0012::0/64", "2001:0DB8:ABCD:0012:0001:0000:0000:0000")]
  265. [InlineData("2001:db8:abcd:0012::0/64", "2001:0DB8:ABCD:0012:FFFF:FFFF:FFFF:FFF0")]
  266. [InlineData("2001:db8:abcd:0012::0/128", "2001:0DB8:ABCD:0012:0000:0000:0000:0000")]
  267. public void IpV6SubnetMaskMatchesValidIpAddress(string netMask, string ipAddress)
  268. {
  269. var ipAddressObj = IPNetAddress.Parse(netMask);
  270. Assert.True(ipAddressObj.Contains(IPAddress.Parse(ipAddress)));
  271. }
  272. [Theory]
  273. [InlineData("2001:db8:abcd:0012::0/64", "2001:0DB8:ABCD:0011:FFFF:FFFF:FFFF:FFFF")]
  274. [InlineData("2001:db8:abcd:0012::0/64", "2001:0DB8:ABCD:0013:0000:0000:0000:0000")]
  275. [InlineData("2001:db8:abcd:0012::0/64", "2001:0DB8:ABCD:0013:0001:0000:0000:0000")]
  276. [InlineData("2001:db8:abcd:0012::0/64", "2001:0DB8:ABCD:0011:FFFF:FFFF:FFFF:FFF0")]
  277. [InlineData("2001:db8:abcd:0012::0/128", "2001:0DB8:ABCD:0012:0000:0000:0000:0001")]
  278. public void IpV6SubnetMaskDoesNotMatchInvalidIpAddress(string netMask, string ipAddress)
  279. {
  280. var ipAddressObj = IPNetAddress.Parse(netMask);
  281. Assert.False(ipAddressObj.Contains(IPAddress.Parse(ipAddress)));
  282. }
  283. [Theory]
  284. [InlineData("10.0.0.0/255.0.0.0", "10.10.10.1/32")]
  285. [InlineData("10.0.0.0/8", "10.10.10.1/32")]
  286. [InlineData("10.0.0.0/255.0.0.0", "10.10.10.1")]
  287. [InlineData("10.10.0.0/255.255.0.0", "10.10.10.1/32")]
  288. [InlineData("10.10.0.0/16", "10.10.10.1/32")]
  289. [InlineData("10.10.0.0/255.255.0.0", "10.10.10.1")]
  290. [InlineData("10.10.10.0/255.255.255.0", "10.10.10.1/32")]
  291. [InlineData("10.10.10.0/24", "10.10.10.1/32")]
  292. [InlineData("10.10.10.0/255.255.255.0", "10.10.10.1")]
  293. public void TestSubnetContains(string network, string ip)
  294. {
  295. Assert.True(TryParse(network, out IPObject? networkObj));
  296. Assert.True(TryParse(ip, out IPObject? ipObj));
  297. Assert.True(networkObj.Contains(ipObj));
  298. }
  299. [Theory]
  300. [InlineData("192.168.1.2/24,10.10.10.1/24,172.168.1.2/24", "172.168.1.2/24", "172.168.1.2/24")]
  301. [InlineData("192.168.1.2/24,10.10.10.1/24,172.168.1.2/24", "172.168.1.2/24, 10.10.10.1", "172.168.1.2/24,10.10.10.1/24")]
  302. [InlineData("192.168.1.2/24,10.10.10.1/24,172.168.1.2/24", "192.168.1.2/255.255.255.0, 10.10.10.1", "192.168.1.2/24,10.10.10.1/24")]
  303. [InlineData("192.168.1.2/24,10.10.10.1/24,172.168.1.2/24", "192.168.1.2/24, 100.10.10.1", "192.168.1.2/24")]
  304. [InlineData("192.168.1.2/24,10.10.10.1/24,172.168.1.2/24", "194.168.1.2/24, 100.10.10.1", "")]
  305. public void TestCollectionEquality(string source, string dest, string result)
  306. {
  307. if (source == null)
  308. {
  309. throw new ArgumentNullException(nameof(source));
  310. }
  311. if (dest == null)
  312. {
  313. throw new ArgumentNullException(nameof(dest));
  314. }
  315. if (result == null)
  316. {
  317. throw new ArgumentNullException(nameof(result));
  318. }
  319. var conf = new NetworkConfiguration()
  320. {
  321. EnableIPV6 = true,
  322. EnableIPV4 = true
  323. };
  324. using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
  325. // Test included, IP6.
  326. Collection<IPObject> ncSource = nm.CreateIPCollection(source.Split(","));
  327. Collection<IPObject> ncDest = nm.CreateIPCollection(dest.Split(","));
  328. Collection<IPObject> ncResult = ncSource.Union(ncDest);
  329. Collection<IPObject> resultCollection = nm.CreateIPCollection(result.Split(","));
  330. Assert.True(ncResult.Compare(resultCollection));
  331. }
  332. [Theory]
  333. [InlineData("10.1.1.1/32", "10.1.1.1")]
  334. [InlineData("192.168.1.254/32", "192.168.1.254/255.255.255.255")]
  335. public void TestEquals(string source, string dest)
  336. {
  337. Assert.True(IPNetAddress.Parse(source).Equals(IPNetAddress.Parse(dest)));
  338. Assert.True(IPNetAddress.Parse(dest).Equals(IPNetAddress.Parse(source)));
  339. }
  340. [Theory]
  341. // Testing bind interfaces.
  342. // On my system eth16 is internal, eth11 external (Windows defines the indexes).
  343. //
  344. // This test is to replicate how DNLA requests work throughout the system.
  345. // User on internal network, we're bound internal and external - so result is internal.
  346. [InlineData("192.168.1.1", "eth16,eth11", false, "eth16")]
  347. // User on external network, we're bound internal and external - so result is external.
  348. [InlineData("8.8.8.8", "eth16,eth11", false, "eth11")]
  349. // User on internal network, we're bound internal only - so result is internal.
  350. [InlineData("10.10.10.10", "eth16", false, "eth16")]
  351. // User on internal network, no binding specified - so result is the 1st internal.
  352. [InlineData("192.168.1.1", "", false, "eth16")]
  353. // User on external network, internal binding only - so result is the 1st internal.
  354. [InlineData("jellyfin.org", "eth16", false, "eth16")]
  355. // User on external network, no binding - so result is the 1st external.
  356. [InlineData("jellyfin.org", "", false, "eth11")]
  357. // User assumed to be internal, no binding - so result is the 1st internal.
  358. [InlineData("", "", false, "eth16")]
  359. public void TestBindInterfaces(string source, string bindAddresses, bool ipv6enabled, string result)
  360. {
  361. if (source == null)
  362. {
  363. throw new ArgumentNullException(nameof(source));
  364. }
  365. if (bindAddresses == null)
  366. {
  367. throw new ArgumentNullException(nameof(bindAddresses));
  368. }
  369. if (result == null)
  370. {
  371. throw new ArgumentNullException(nameof(result));
  372. }
  373. var conf = new NetworkConfiguration()
  374. {
  375. LocalNetworkAddresses = bindAddresses.Split(','),
  376. EnableIPV6 = ipv6enabled,
  377. EnableIPV4 = true
  378. };
  379. NetworkManager.MockNetworkSettings = "192.168.1.208/24,-16,eth16|200.200.200.200/24,11,eth11";
  380. using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
  381. NetworkManager.MockNetworkSettings = string.Empty;
  382. _ = nm.TryParseInterface(result, out Collection<IPObject>? resultObj);
  383. if (resultObj != null)
  384. {
  385. result = ((IPNetAddress)resultObj[0]).ToString(true);
  386. var intf = nm.GetBindInterface(source, out int? _);
  387. Assert.Equal(intf, result);
  388. }
  389. }
  390. [Theory]
  391. // Testing bind interfaces. These are set for my system so won't work elsewhere.
  392. // On my system eth16 is internal, eth11 external (Windows defines the indexes).
  393. //
  394. // This test is to replicate how subnet bound ServerPublisherUri work throughout the system.
  395. // User on internal network, we're bound internal and external - so result is internal override.
  396. [InlineData("192.168.1.1", "192.168.1.0/24", "eth16,eth11", false, "192.168.1.0/24=internal.jellyfin", "internal.jellyfin")]
  397. // User on external network, we're bound internal and external - so result is override.
  398. [InlineData("8.8.8.8", "192.168.1.0/24", "eth16,eth11", false, "0.0.0.0=http://helloworld.com", "http://helloworld.com")]
  399. // User on internal network, we're bound internal only, but the address isn't in the LAN - so return the override.
  400. [InlineData("10.10.10.10", "192.168.1.0/24", "eth16", false, "0.0.0.0=http://internalButNotDefinedAsLan.com", "http://internalButNotDefinedAsLan.com")]
  401. // User on internal network, no binding specified - so result is the 1st internal.
  402. [InlineData("192.168.1.1", "192.168.1.0/24", "", false, "0.0.0.0=http://helloworld.com", "eth16")]
  403. // User on external network, internal binding only - so asumption is a proxy forward, return external override.
  404. [InlineData("jellyfin.org", "192.168.1.0/24", "eth16", false, "0.0.0.0=http://helloworld.com", "http://helloworld.com")]
  405. // User on external network, no binding - so result is the 1st external which is overriden.
  406. [InlineData("jellyfin.org", "192.168.1.0/24", "", false, "0.0.0.0 = http://helloworld.com", "http://helloworld.com")]
  407. // User assumed to be internal, no binding - so result is the 1st internal.
  408. [InlineData("", "192.168.1.0/24", "", false, "0.0.0.0=http://helloworld.com", "eth16")]
  409. // User is internal, no binding - so result is the 1st internal, which is then overridden.
  410. [InlineData("192.168.1.1", "192.168.1.0/24", "", false, "eth16=http://helloworld.com", "http://helloworld.com")]
  411. public void TestBindInterfaceOverrides(string source, string lan, string bindAddresses, bool ipv6enabled, string publishedServers, string result)
  412. {
  413. if (lan == null)
  414. {
  415. throw new ArgumentNullException(nameof(lan));
  416. }
  417. if (bindAddresses == null)
  418. {
  419. throw new ArgumentNullException(nameof(bindAddresses));
  420. }
  421. var conf = new NetworkConfiguration()
  422. {
  423. LocalNetworkSubnets = lan.Split(','),
  424. LocalNetworkAddresses = bindAddresses.Split(','),
  425. EnableIPV6 = ipv6enabled,
  426. EnableIPV4 = true,
  427. PublishedServerUriBySubnet = new string[] { publishedServers }
  428. };
  429. NetworkManager.MockNetworkSettings = "192.168.1.208/24,-16,eth16|200.200.200.200/24,11,eth11";
  430. using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
  431. NetworkManager.MockNetworkSettings = string.Empty;
  432. if (nm.TryParseInterface(result, out Collection<IPObject>? resultObj) && resultObj != null)
  433. {
  434. // Parse out IPAddresses so we can do a string comparison. (Ignore subnet masks).
  435. result = ((IPNetAddress)resultObj[0]).ToString(true);
  436. }
  437. var intf = nm.GetBindInterface(source, out int? _);
  438. Assert.Equal(intf, result);
  439. }
  440. }
  441. }