Example #1
0
func (subject *AddressSubject) Equals(another v2net.Address) {
	if subject.value.IsIPv4() && another.IsIPv4() {
		IP(subject.value.IP()).Equals(another.IP())
	} else if subject.value.IsIPv6() && another.IsIPv6() {
		IP(subject.value.IP()).Equals(another.IP())
	} else if subject.value.IsDomain() && another.IsDomain() {
		assert.StringLiteral(subject.value.Domain()).Equals(another.Domain())
	} else {
		subject.Fail(subject.DisplayString(), "equals to", another)
	}
}
Example #2
0
func appendAddress(request []byte, address v2net.Address) []byte {
	switch {
	case address.IsIPv4():
		request = append(request, byte(0x01))
		request = append(request, address.IP()...)

	case address.IsIPv6():
		request = append(request, byte(0x04))
		request = append(request, address.IP()...)

	case address.IsDomain():
		request = append(request, byte(0x03), byte(len(address.Domain())))
		request = append(request, []byte(address.Domain())...)

	}
	return request
}