introduce address family in v2net

This commit is contained in:
v2ray
2016-08-14 18:14:12 +02:00
parent a9d583b92f
commit 4419f1e3d6
15 changed files with 73 additions and 78 deletions
+4 -4
View File
@@ -26,12 +26,12 @@ func (request *Socks5UDPRequest) Destination() v2net.Destination {
func (request *Socks5UDPRequest) Write(buffer *alloc.Buffer) {
buffer.AppendBytes(0, 0, request.Fragment)
switch {
case request.Address.IsIPv4():
switch request.Address.Family() {
case v2net.AddressFamilyIPv4:
buffer.AppendBytes(AddrTypeIPv4).Append(request.Address.IP())
case request.Address.IsIPv6():
case v2net.AddressFamilyIPv6:
buffer.AppendBytes(AddrTypeIPv6).Append(request.Address.IP())
case request.Address.IsDomain():
case v2net.AddressFamilyDomain:
buffer.AppendBytes(AddrTypeDomain, byte(len(request.Address.Domain()))).Append([]byte(request.Address.Domain()))
}
buffer.AppendUint16(request.Port.Value())
+4 -4
View File
@@ -238,12 +238,12 @@ func (this *Server) handleUDP(reader io.Reader, writer *v2io.BufferedWriter) err
udpAddr := this.udpAddress
response.Port = udpAddr.Port()
switch {
case udpAddr.Address().IsIPv4():
switch udpAddr.Address().Family() {
case v2net.AddressFamilyIPv4:
response.SetIPv4(udpAddr.Address().IP())
case udpAddr.Address().IsIPv6():
case v2net.AddressFamilyIPv6:
response.SetIPv6(udpAddr.Address().IP())
case udpAddr.Address().IsDomain():
case v2net.AddressFamilyDomain:
response.SetDomain(udpAddr.Address().Domain())
}