func appendAddress(buffer *buf.Buffer, address v2net.Address, port v2net.Port) { switch address.Family() { case v2net.AddressFamilyIPv4: buffer.AppendBytes(0x01) buffer.Append(address.IP()) case v2net.AddressFamilyIPv6: buffer.AppendBytes(0x04) buffer.Append(address.IP()) case v2net.AddressFamilyDomain: buffer.AppendBytes(0x03, byte(len(address.Domain()))) buffer.AppendSupplier(serial.WriteString(address.Domain())) } buffer.AppendSupplier(serial.WriteUint16(port.Value())) }
func appendAddress(request []byte, address v2net.Address) []byte { switch address.Family() { case v2net.AddressFamilyIPv4: request = append(request, byte(0x01)) request = append(request, address.IP()...) case v2net.AddressFamilyIPv6: request = append(request, byte(0x04)) request = append(request, address.IP()...) case v2net.AddressFamilyDomain: request = append(request, byte(0x03), byte(len(address.Domain()))) request = append(request, []byte(address.Domain())...) } return request }