Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Patch NetcodeIO.NET to accept connections in production
Browse files Browse the repository at this point in the history
  • Loading branch information
hach-que committed Mar 20, 2018
1 parent 990786b commit c1248f6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1,815 deletions.
14 changes: 10 additions & 4 deletions ThirdParty/Netcode.IO.NET/Public/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public int NumConnectedClients

#endregion

public Server(int maxSlots, string address, int port, ulong protocolID, byte[] privateKey)
public Server(int maxSlots, int port, ulong protocolID, byte[] privateKey)
{
this.tickrate = 60;

Expand All @@ -210,7 +210,7 @@ public Server(int maxSlots, string address, int port, ulong protocolID, byte[] p
this.clientSlots = new RemoteClient[maxSlots];
this.encryptionManager = new EncryptionManager(maxSlots);

this.listenEndpoint = new IPEndPoint(IPAddress.Parse(address), port);
this.listenEndpoint = new IPEndPoint(IPAddress.Any, port);

if (this.listenEndpoint.AddressFamily == AddressFamily.InterNetwork)
this.listenSocket = new UDPSocketContext(AddressFamily.InterNetwork);
Expand All @@ -226,7 +226,7 @@ public Server(int maxSlots, string address, int port, ulong protocolID, byte[] p
KeyUtils.GenerateKey(this.challengeKey);
}

internal Server(ISocketContext socketContext, int maxSlots, string address, int port, ulong protocolID, byte[] privateKey)
internal Server(ISocketContext socketContext, int maxSlots, int port, ulong protocolID, byte[] privateKey)
{
this.tickrate = 60;

Expand All @@ -238,7 +238,7 @@ internal Server(ISocketContext socketContext, int maxSlots, string address, int
this.clientSlots = new RemoteClient[maxSlots];
this.encryptionManager = new EncryptionManager(maxSlots);

this.listenEndpoint = new IPEndPoint(IPAddress.Parse(address), port);
this.listenEndpoint = new IPEndPoint(IPAddress.Any, port);

this.listenSocket = socketContext;

Expand Down Expand Up @@ -699,12 +699,18 @@ private void processConnectionRequest(ByteArrayReaderWriter reader, int size, En
}

// if this server's public IP is not in the list of endpoints, packet is not valid
/*
* We run in Docker, so our listen endpoint (0.0.0.0:40000) won't ever appear in the connect
* token's IP endpoint (<public IP>:40000). We don't really need this "security", since the
* private keypair secures servers anyway.
*
bool serverAddressInEndpoints = privateConnectToken.ConnectServers.Any(x => x.Endpoint.CompareEndpoint(this.listenEndpoint, this.Port));
if (!serverAddressInEndpoints)
{
log("Server address not listen in token", NetcodeLogLevel.Debug);
return;
}
*/

// if a client from packet source IP / port is already connected, ignore the packet
if (clientSlots.Any(x => x != null && x.RemoteEndpoint.Equals(sender)))
Expand Down
Loading

0 comments on commit c1248f6

Please sign in to comment.