2dust/v2rayN · error · ArgumentException
Invalid SOCKS5 UDP packet: IPv6 address incomplete
Error message
Invalid SOCKS5 UDP packet: IPv6 address incomplete
What it means
Thrown when ATYP indicates IPv6 (0x04) but fewer than 16 bytes remain for the 128-bit address. Same truncation guard as the IPv4 case but sized for 16 octets.
Source
Thrown at v2rayN/ServiceLib.UdpTest/Socks5UdpChannel.cs:144
switch (addressType)
{
case Socks5AddressData.AddrTypeIPv4:
if (packet.Length < offset + 4)
{
throw new ArgumentException("Invalid SOCKS5 UDP packet: IPv4 address incomplete");
}
var ipv4Bytes = new byte[4];
Array.Copy(packet, offset, ipv4Bytes, 0, 4);
host = new IPAddress(ipv4Bytes).ToString();
addressLength = 4;
isDomain = false;
break;
case Socks5AddressData.AddrTypeIPv6:
if (packet.Length < offset + 16)
{
throw new ArgumentException("Invalid SOCKS5 UDP packet: IPv6 address incomplete");
}
var ipv6Bytes = new byte[16];
Array.Copy(packet, offset, ipv6Bytes, 0, 16);
host = new IPAddress(ipv6Bytes).ToString();
addressLength = 16;
isDomain = false;
break;
case Socks5AddressData.AddrTypeDomain:
if (packet.Length < offset + 1)
{
throw new ArgumentException("Invalid SOCKS5 UDP packet: domain length missing");
}
var domainLength = packet[offset++];
if (packet.Length < offset + domainLength)
{View on GitHub (pinned to e01717d832)
Solutions
- Catch ArgumentException per attempt and continue (the response is unusable but the test loop can retry).
- Confirm the proxy encodes IPv6 with ATYP 0x04 + 16 address bytes + 2 port bytes per RFC 1928.
- If the target resolves to IPv6, prefer a dual-stack proxy and ensure the relay path supports 16-byte address headers.
- Log ATYP and remaining-length at failure to confirm truncation vs. proxy bug.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check IPv6 address availability static bool HasFullIPv6(byte[] p, int offset) => p != null && p.Length >= offset + 16;
Type guard
static bool IsCompleteIPv6Packet(byte[] packet, int offset) => packet != null && offset + 16 + 2 <= packet.Length;
Try / catch
try
{
var (remote, data) = ParseSocks5UdpPacket(packet);
}
catch (ArgumentException ex) when (ex.Message.Contains("IPv6 address incomplete"))
{
// truncated IPv6 relay packet; retry or mark attempt failed
} Prevention
- Catch the ArgumentException per attempt rather than letting it propagate.
- Verify the proxy writes 16-byte IPv6 addresses with ATYP 0x04.
- Ensure the relay path supports the larger IPv6-headed packet without truncation.
When it happens
Trigger: ParseSocks5UdpPacket reads ATYP == AddrTypeIPv6 then packet.Length < offset + 16; the datagram was cut short inside the IPv6 address field.
Common situations: Truncated IPv6 relay response; proxy reporting an IPv6 ATYP without a full 16-byte address; MTU/fragmentation truncating an already-large IPv6-headed packet.
Related errors
- Invalid SOCKS5 UDP packet: too short
- Invalid SOCKS5 UDP packet: IPv4 address incomplete
- Invalid SOCKS5 UDP packet: domain length missing
- Invalid SOCKS5 UDP packet: domain incomplete
- Unsupported SOCKS5 address type: {addressType}
AI-assisted analysis of 2dust/v2rayN@e01717d832 (2026-08-13).
Data as JSON: /api/errors/f3a38b10e573fad9.
Report an issue: GitHub.