This commit is contained in:
parent
e41632fe95
commit
9c5abc3b0d
48 changed files with 261 additions and 70 deletions
|
|
@ -66,8 +66,8 @@ namespace Server.Misc
|
|||
|
||||
IPEndPoint ipep = (IPEndPoint)s.LocalEndPoint;
|
||||
|
||||
IPAddress localAddress = ipep.Address;
|
||||
int localPort = ipep.Port;
|
||||
IPAddress localAddress = ipep.Address;
|
||||
int localPort = ipep.Port;
|
||||
|
||||
if ( IsPrivateNetwork( localAddress ) ) {
|
||||
ipep = (IPEndPoint)s.RemoteEndPoint;
|
||||
|
|
@ -88,7 +88,7 @@ namespace Server.Misc
|
|||
if ( !HasPublicIPAddress() ) {
|
||||
Console.Write( "ServerList: Auto-detecting public IP address..." );
|
||||
m_PublicAddress = FindPublicAddress();
|
||||
|
||||
|
||||
if ( m_PublicAddress != null )
|
||||
Console.WriteLine( "done ({0})", m_PublicAddress.ToString() );
|
||||
else
|
||||
|
|
@ -118,8 +118,10 @@ namespace Server.Misc
|
|||
IPAddress[] ips = iphe.AddressList;
|
||||
|
||||
for ( int i = 0; i < ips.Length; ++i )
|
||||
if ( !IsPrivateNetwork( ips[i] ) )
|
||||
{
|
||||
if ( ips[i].AddressFamily != AddressFamily.InterNetworkV6 && !IsPrivateNetwork( ips[i] ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -130,6 +132,9 @@ namespace Server.Misc
|
|||
// 172.16.0.0/12
|
||||
// 192.168.0.0/16
|
||||
|
||||
if ( ip.AddressFamily == AddressFamily.InterNetworkV6 )
|
||||
return false;
|
||||
|
||||
if ( Utility.IPMatch( "192.168.*", ip ) )
|
||||
return true;
|
||||
else if ( Utility.IPMatch( "10.*", ip ) )
|
||||
|
|
@ -150,7 +155,7 @@ namespace Server.Misc
|
|||
|
||||
Stream s = res.GetResponseStream();
|
||||
|
||||
StreamReader sr = new StreamReader( s );
|
||||
StreamReader sr = new StreamReader( s );
|
||||
|
||||
IPAddress ip = IPAddress.Parse( sr.ReadLine() );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue