mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-17 09:56:18 -05:00
remove redundent code
This commit is contained in:
parent
7e6b45ace4
commit
0920af171b
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user