mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-30 05:56:54 -05:00
style
This commit is contained in:
parent
76da31c755
commit
031b1c14b8
@ -195,7 +195,7 @@ func (v *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.Respon
|
||||
}
|
||||
|
||||
if buffer[2] != 0 {
|
||||
cmdId := buffer[2]
|
||||
cmdID := buffer[2]
|
||||
dataLen := int(buffer[3])
|
||||
_, err := io.ReadFull(v.responseReader, buffer[:dataLen])
|
||||
if err != nil {
|
||||
@ -203,7 +203,7 @@ func (v *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.Respon
|
||||
return nil, err
|
||||
}
|
||||
data := buffer[:dataLen]
|
||||
command, err := UnmarshalCommand(cmdId, data)
|
||||
command, err := UnmarshalCommand(cmdID, data)
|
||||
if err == nil {
|
||||
header.Command = command
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ func MarshalCommand(command interface{}, writer io.Writer) error {
|
||||
return ErrUnknownCommand
|
||||
}
|
||||
|
||||
var cmdId byte
|
||||
var cmdID byte
|
||||
var factory CommandFactory
|
||||
switch command.(type) {
|
||||
case *protocol.CommandSwitchAccount:
|
||||
factory = new(CommandSwitchAccountFactory)
|
||||
cmdId = 1
|
||||
cmdID = 1
|
||||
default:
|
||||
return ErrUnknownCommand
|
||||
}
|
||||
@ -46,12 +46,12 @@ func MarshalCommand(command interface{}, writer io.Writer) error {
|
||||
return ErrCommandTooLarge
|
||||
}
|
||||
|
||||
writer.Write([]byte{cmdId, byte(len), byte(auth >> 24), byte(auth >> 16), byte(auth >> 8), byte(auth)})
|
||||
writer.Write([]byte{cmdID, byte(len), byte(auth >> 24), byte(auth >> 16), byte(auth >> 8), byte(auth)})
|
||||
writer.Write(buffer.Bytes())
|
||||
return nil
|
||||
}
|
||||
|
||||
func UnmarshalCommand(cmdId byte, data []byte) (protocol.ResponseCommand, error) {
|
||||
func UnmarshalCommand(cmdID byte, data []byte) (protocol.ResponseCommand, error) {
|
||||
if len(data) <= 4 {
|
||||
return nil, errors.New("VMess|Command: Insufficient length.")
|
||||
}
|
||||
@ -62,7 +62,7 @@ func UnmarshalCommand(cmdId byte, data []byte) (protocol.ResponseCommand, error)
|
||||
}
|
||||
|
||||
var factory CommandFactory
|
||||
switch cmdId {
|
||||
switch cmdID {
|
||||
case 1:
|
||||
factory = new(CommandSwitchAccountFactory)
|
||||
default:
|
||||
@ -129,12 +129,12 @@ func (v *CommandSwitchAccountFactory) Unmarshal(data []byte) (interface{}, error
|
||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
||||
}
|
||||
cmd.ID, _ = uuid.ParseBytes(data[idStart : idStart+16])
|
||||
alterIdStart := idStart + 16
|
||||
if len(data) < alterIdStart+2 {
|
||||
alterIDStart := idStart + 16
|
||||
if len(data) < alterIDStart+2 {
|
||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
||||
}
|
||||
cmd.AlterIds = serial.BytesToUint16(data[alterIdStart : alterIdStart+2])
|
||||
levelStart := alterIdStart + 2
|
||||
cmd.AlterIds = serial.BytesToUint16(data[alterIDStart : alterIDStart+2])
|
||||
levelStart := alterIDStart + 2
|
||||
if len(data) < levelStart+1 {
|
||||
return nil, errors.New("VMess|SwitchAccountCommand: Insufficient length.")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user