You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-15 22:56:30 +09:00
IPv6: Space Wizard Edition.
This PR fixes the IPv6 support *properly*. The two previous PRs, #123 and #126, both made a mess out of it: PR #123 implemented IPv6 by breaking non-dualstack IPv4 support. PR #126 fixed IPv4 support by breaking non-dualstack IPv6 support. This change fixes the mess entirely. IPv4, IPv6 and IPv6-dual-stack are now all independently supported and work as expected. Namely IPv4 can't receive IPv6, IPv6 can only receive IPv4 if NetPeerConfiguration.DualStack is set. You can still have an IPv6-only socket. I'll leave some review comments on the PR for less-immediately obvious changes.
This commit is contained in:
@@ -132,14 +132,19 @@ namespace Lidgren.Network
|
||||
m_socket.SendBufferSize = m_configuration.SendBufferSize;
|
||||
m_socket.Blocking = false;
|
||||
|
||||
if(m_configuration.DualStack && m_configuration.LocalAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||
m_socket.DualMode = true;
|
||||
if (m_configuration.DualStack)
|
||||
{
|
||||
if (m_configuration.LocalAddress.AddressFamily != AddressFamily.InterNetworkV6)
|
||||
{
|
||||
LogWarning("Configuration specifies Dual Stack but does not use IPv6 local address; Dual stack will not work.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_socket.DualMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
var localAddress = m_configuration.DualStack
|
||||
? m_configuration.LocalAddress.MapToIPv6()
|
||||
: m_configuration.LocalAddress;
|
||||
|
||||
var ep = (EndPoint)new NetEndPoint(localAddress, reBind ? m_listenPort : m_configuration.Port);
|
||||
var ep = (EndPoint)new NetEndPoint(m_configuration.LocalAddress, reBind ? m_listenPort : m_configuration.Port);
|
||||
m_socket.Bind(ep);
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user