|
@@ -1,3 +1,4 @@
|
|
|
+using Dns.Net.Abstractions;
|
|
|
using Dns.Net.Clients;
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
using STUN.Client;
|
|
@@ -12,10 +13,13 @@ namespace UnitTest
|
|
|
[TestClass]
|
|
|
public class UnitTest
|
|
|
{
|
|
|
+ private readonly IDnsClient dnsClient = new DefaultDnsClient();
|
|
|
+
|
|
|
[TestMethod]
|
|
|
public async Task BindingTest()
|
|
|
{
|
|
|
- using var client = new StunClient5389UDP(new DefaultDnsClient(), @"stun.syncthing.net", 3478, new IPEndPoint(IPAddress.Any, 0));
|
|
|
+ var server = await dnsClient.QueryAsync(@"stun.syncthing.net");
|
|
|
+ using var client = new StunClient5389UDP(server, 3478, new IPEndPoint(IPAddress.Any, 0));
|
|
|
await client.BindingTestAsync();
|
|
|
var result = client.Status;
|
|
|
|
|
@@ -31,7 +35,8 @@ namespace UnitTest
|
|
|
[TestMethod]
|
|
|
public async Task MappingBehaviorTest()
|
|
|
{
|
|
|
- using var client = new StunClient5389UDP(new DefaultDnsClient(), @"stun.syncthing.net", 3478, new IPEndPoint(IPAddress.Any, 0));
|
|
|
+ var server = await dnsClient.QueryAsync(@"stun.syncthing.net");
|
|
|
+ using var client = new StunClient5389UDP(server, 3478, new IPEndPoint(IPAddress.Any, 0));
|
|
|
await client.MappingBehaviorTestAsync();
|
|
|
var result = client.Status;
|
|
|
|
|
@@ -52,7 +57,8 @@ namespace UnitTest
|
|
|
[TestMethod]
|
|
|
public async Task FilteringBehaviorTest()
|
|
|
{
|
|
|
- using var client = new StunClient5389UDP(new DefaultDnsClient(), @"stun.syncthing.net", 3478, new IPEndPoint(IPAddress.Any, 0));
|
|
|
+ var server = await dnsClient.QueryAsync(@"stun.syncthing.net");
|
|
|
+ using var client = new StunClient5389UDP(server, 3478, new IPEndPoint(IPAddress.Any, 0));
|
|
|
await client.FilteringBehaviorTestAsync();
|
|
|
var result = client.Status;
|
|
|
|
|
@@ -72,7 +78,8 @@ namespace UnitTest
|
|
|
[TestMethod]
|
|
|
public async Task CombiningTest()
|
|
|
{
|
|
|
- using var client = new StunClient5389UDP(new DefaultDnsClient(), @"stun.syncthing.net", 3478, new IPEndPoint(IPAddress.Any, 0));
|
|
|
+ var server = await dnsClient.QueryAsync(@"stun.syncthing.net");
|
|
|
+ using var client = new StunClient5389UDP(server, 3478, new IPEndPoint(IPAddress.Any, 0));
|
|
|
await client.QueryAsync();
|
|
|
var result = client.Status;
|
|
|
|
|
@@ -98,7 +105,8 @@ namespace UnitTest
|
|
|
public async Task ProxyTest()
|
|
|
{
|
|
|
using var proxy = ProxyFactory.CreateProxy(ProxyType.Socks5, IPEndPoint.Parse(@"0.0.0.0:0"), IPEndPoint.Parse(@"127.0.0.1:10000"));
|
|
|
- using var client = new StunClient5389UDP(new DefaultDnsClient(), @"stun.syncthing.net", 3478, new IPEndPoint(IPAddress.Any, 0), proxy);
|
|
|
+ var server = await dnsClient.QueryAsync(@"stun.syncthing.net");
|
|
|
+ using var client = new StunClient5389UDP(server, 3478, new IPEndPoint(IPAddress.Any, 0));
|
|
|
await client.QueryAsync();
|
|
|
var result = client.Status;
|
|
|
|