Browse Source

6️⃣ Backend: use dual-stack socket when possible

Listener on [::]:1080 now accepts traffic from both IPv4 and IPv6.
pull/3127/head
database64128 3 years ago
parent
commit
0b317b75c3
No known key found for this signature in database GPG Key ID: 1CA27546BEDB8B01
2 changed files with 2 additions and 0 deletions
  1. +1
    -0
      Shadowsocks.Net/TCPListener.cs
  2. +1
    -0
      Shadowsocks.Net/UDPListener.cs

+ 1
- 0
Shadowsocks.Net/TCPListener.cs View File

@@ -68,6 +68,7 @@ namespace Shadowsocks.Net
// Create a TCP/IP socket.
_tcpSocket = new Socket(_localEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
_tcpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
_tcpSocket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false);

// Bind the socket to the local endpoint and listen for incoming connections.
_tcpSocket.Bind(_localEndPoint);


+ 1
- 0
Shadowsocks.Net/UDPListener.cs View File

@@ -63,6 +63,7 @@ namespace Shadowsocks.Net
// Create a TCP/IP socket.
_udpSocket = new Socket(_localEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
_udpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
_udpSocket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false);

// Bind the socket to the local endpoint and listen for incoming connections.
_udpSocket.Bind(_localEndPoint);


Loading…
Cancel
Save