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

Commit c1248f6

Browse files
committed
Patch NetcodeIO.NET to accept connections in production
1 parent 990786b commit c1248f6

File tree

4 files changed

+23
-1815
lines changed

4 files changed

+23
-1815
lines changed

ThirdParty/Netcode.IO.NET/Public/Server.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public int NumConnectedClients
198198

199199
#endregion
200200

201-
public Server(int maxSlots, string address, int port, ulong protocolID, byte[] privateKey)
201+
public Server(int maxSlots, int port, ulong protocolID, byte[] privateKey)
202202
{
203203
this.tickrate = 60;
204204

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

213-
this.listenEndpoint = new IPEndPoint(IPAddress.Parse(address), port);
213+
this.listenEndpoint = new IPEndPoint(IPAddress.Any, port);
214214

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

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

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

241-
this.listenEndpoint = new IPEndPoint(IPAddress.Parse(address), port);
241+
this.listenEndpoint = new IPEndPoint(IPAddress.Any, port);
242242

243243
this.listenSocket = socketContext;
244244

@@ -699,12 +699,18 @@ private void processConnectionRequest(ByteArrayReaderWriter reader, int size, En
699699
}
700700

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

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

0 commit comments

Comments
 (0)