1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-18 18:36:11 -05:00
v2fly/common/protocol/headers.go

56 lines
1.1 KiB
Go
Raw Normal View History

2016-02-15 18:42:52 -05:00
package protocol
import (
v2net "github.com/v2ray/v2ray-core/common/net"
2016-02-26 18:05:53 -05:00
"github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/common/uuid"
2016-02-15 18:42:52 -05:00
)
type RequestCommand byte
const (
RequestCommandTCP = RequestCommand(0x01)
RequestCommandUDP = RequestCommand(0x02)
)
const (
RequestOptionChunkStream = RequestOption(0x01)
)
2016-02-27 10:41:21 -05:00
type RequestOption byte
func (this RequestOption) IsChunkStream() bool {
return (this & RequestOptionChunkStream) == RequestOptionChunkStream
}
2016-02-15 18:42:52 -05:00
type RequestHeader struct {
Version byte
User *User
Command RequestCommand
Option RequestOption
Address v2net.Address
Port v2net.Port
}
2016-02-27 11:28:21 -05:00
func (this *RequestHeader) Destination() v2net.Destination {
if this.Command == RequestCommandUDP {
return v2net.UDPDestination(this.Address, this.Port)
}
return v2net.TCPDestination(this.Address, this.Port)
}
2016-02-15 18:42:52 -05:00
type ResponseCommand interface{}
type ResponseHeader struct {
Command ResponseCommand
}
2016-02-26 18:05:53 -05:00
type CommandSwitchAccount struct {
Host v2net.Address
Port v2net.Port
ID *uuid.UUID
AlterIds serial.Uint16Literal
Level UserLevel
ValidMin byte
}