fix: Fixes networking (#822)

* Fixes wepoll to be POSIX compliant.
This commit is contained in:
Kamron Batman 2021-10-09 11:55:31 -07:00 • committed by GitHub
parent 05ff3f2ad9
commit 81486772f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 60 additions and 161 deletions

View file

@ -68,7 +68,11 @@ namespace Server.Misc
{
var ns = e.State;
var ipep = (IPEndPoint)ns.Connection.LocalEndPoint;
var ipep = (IPEndPoint)ns.Connection?.LocalEndPoint;
if (ipep == null)
{
return;
}
var localAddress = ipep.Address;
var localPort = ipep.Port;
@ -76,7 +80,7 @@ namespace Server.Misc
if (IsPrivateNetwork(localAddress))
{
ipep = (IPEndPoint)ns.Connection.RemoteEndPoint;
if (!IsPrivateNetwork(ipep.Address) && _publicAddress != null)
if (ipep == null || !IsPrivateNetwork(ipep.Address) && _publicAddress != null)
{
localAddress = _publicAddress;
}