1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-04 09:17:32 -05:00

remove redundent code

This commit is contained in:
Darien Raymond 2018-02-22 10:49:06 +01:00
parent 7e6b45ace4
commit 0920af171b
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -139,34 +139,13 @@ func (s *ServerSession) Handshake(reader io.Reader, writer io.Writer) (*protocol
buffer.Clear() buffer.Clear()
request.Version = socks5Version request.Version = socks5Version
switch addrType {
case addrTypeIPv4:
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 4)); err != nil {
return nil, err
}
request.Address = net.IPAddress(buffer.Bytes())
case addrTypeIPv6:
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 16)); err != nil {
return nil, err
}
request.Address = net.IPAddress(buffer.Bytes())
case addrTypeDomain:
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 1)); err != nil {
return nil, err
}
domainLength := int(buffer.Byte(0))
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, domainLength)); err != nil {
return nil, err
}
request.Address = net.ParseAddress(string(buffer.BytesFrom(-domainLength)))
default:
return nil, newError("Unknown address type: ", addrType)
}
if err := buffer.AppendSupplier(buf.ReadFullFrom(reader, 2)); err != nil { addr, port, err := ReadAddress(buffer, addrType, reader)
return nil, err if err != nil {
return nil, newError("failed to read address").Base(err)
} }
request.Port = net.PortFromBytes(buffer.BytesFrom(-2)) request.Address = addr
request.Port = port
responseAddress := net.AnyIP responseAddress := net.AnyIP
responsePort := net.Port(1717) responsePort := net.Port(1717)