public void ReadFromV5(BinaryReader reader) { var hostNameType = reader.ReadByte(); switch (hostNameType) { case 1: // IPv4 HostNameType = EndPointType.IPv4; Host = NetworkConverter.ToIPv4(reader.ReadBytes(4)); break; case 3: // Host name HostNameType = EndPointType.HostName; { var data = reader.ReadBytes(reader.ReadByte()); Host = SocksUtilities.DefaultEncoding.GetString(data, 0, data.Length); } break; case 4: // IPv6 HostNameType = EndPointType.IPv6; Host = NetworkConverter.ToIPv6(reader.ReadBytes(16)); break; default: throw new NotSupportedException(); } Port = NetworkConverter.ToPort(reader.ReadBytes(2)); }
public void ReadFromV4(BinaryReader reader) { Port = NetworkConverter.ToPort(reader.ReadBytes(2)); // IPv4 HostNameType = EndPointType.IPv4; Host = NetworkConverter.ToIPv4(reader.ReadBytes(4)); }