File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 1
1
using Dns . Net . Clients ;
2
+ using STUN ;
2
3
using STUN . Client ;
3
4
using System ;
4
5
using System . Net ;
@@ -9,24 +10,22 @@ namespace NatTypeTester
9
10
internal static class Program
10
11
{
11
12
/// <summary>
12
- /// stun.qq.com 3478 0.0.0.0:0
13
+ /// stun.qq.com: 3478 0.0.0.0:0
13
14
/// </summary>
14
15
private static async Task Main ( string [ ] args )
15
16
{
16
17
var server = @"stun.syncthing.net" ;
17
18
ushort port = 3478 ;
18
- IPEndPoint ? local = null ;
19
- if ( args . Length > 0 && ( Uri . CheckHostName ( args [ 0 ] ) == UriHostNameType . Dns || IPAddress . TryParse ( args [ 0 ] , out _ ) ) )
19
+ var local = new IPEndPoint ( IPAddress . Any , 0 ) ;
20
+
21
+ if ( args . Length > 0 && StunServer . TryParse ( args [ 0 ] , out var stun ) )
20
22
{
21
- server = args [ 0 ] ;
23
+ server = stun . Hostname ;
24
+ port = stun . Port ;
22
25
}
23
26
if ( args . Length > 1 )
24
27
{
25
- ushort . TryParse ( args [ 1 ] , out port ) ;
26
- }
27
- if ( args . Length > 2 )
28
- {
29
- local = IPEndPoint . Parse ( args [ 2 ] ) ;
28
+ IPEndPoint . TryParse ( args [ 2 ] , out local ) ;
30
29
}
31
30
32
31
using var client = new StunClient5389UDP ( new DefaultDnsClient ( ) , server , port , local ) ;
You can’t perform that action at this time.
0 commit comments