|
|
@ -92,14 +92,14 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
|
|
|
|
|
|
|
|
|
|
|
|
switch buffer[40] {
|
|
|
|
switch buffer[40] {
|
|
|
|
case AddrTypeIPv4:
|
|
|
|
case AddrTypeIPv4:
|
|
|
|
nBytes, err = io.ReadFull(decryptor, buffer[41:45]) // 4 bytes
|
|
|
|
_, err = io.ReadFull(decryptor, buffer[41:45]) // 4 bytes
|
|
|
|
bufferLen += 4
|
|
|
|
bufferLen += 4
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.New("VMess|Server: Failed to read IPv4: " + err.Error())
|
|
|
|
return nil, errors.New("VMess|Server: Failed to read IPv4: " + err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
request.Address = v2net.IPAddress(buffer[41:45])
|
|
|
|
request.Address = v2net.IPAddress(buffer[41:45])
|
|
|
|
case AddrTypeIPv6:
|
|
|
|
case AddrTypeIPv6:
|
|
|
|
nBytes, err = io.ReadFull(decryptor, buffer[41:57]) // 16 bytes
|
|
|
|
_, err = io.ReadFull(decryptor, buffer[41:57]) // 16 bytes
|
|
|
|
bufferLen += 16
|
|
|
|
bufferLen += 16
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.New("VMess|Server: Failed to read IPv6 address: " + err.Error())
|
|
|
|
return nil, errors.New("VMess|Server: Failed to read IPv6 address: " + err.Error())
|
|
|
@ -114,7 +114,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
|
|
|
|
if domainLength == 0 {
|
|
|
|
if domainLength == 0 {
|
|
|
|
return nil, errors.New("VMess|Server: Zero domain length.")
|
|
|
|
return nil, errors.New("VMess|Server: Zero domain length.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nBytes, err = io.ReadFull(decryptor, buffer[42:42+domainLength])
|
|
|
|
_, err = io.ReadFull(decryptor, buffer[42:42+domainLength])
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.New("VMess|Server: Failed to read domain: " + err.Error())
|
|
|
|
return nil, errors.New("VMess|Server: Failed to read domain: " + err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -122,7 +122,7 @@ func (v *ServerSession) DecodeRequestHeader(reader io.Reader) (*protocol.Request
|
|
|
|
request.Address = v2net.DomainAddress(string(buffer[42 : 42+domainLength]))
|
|
|
|
request.Address = v2net.DomainAddress(string(buffer[42 : 42+domainLength]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nBytes, err = io.ReadFull(decryptor, buffer[bufferLen:bufferLen+4])
|
|
|
|
_, err = io.ReadFull(decryptor, buffer[bufferLen:bufferLen+4])
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.New("VMess|Server: Failed to read checksum: " + err.Error())
|
|
|
|
return nil, errors.New("VMess|Server: Failed to read checksum: " + err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|