You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/common/protocol/headers.go

90 lines
1.6 KiB

package protocol
import (
v2net "v2ray.com/core/common/net"
"v2ray.com/core/common/uuid"
)
type RequestCommand byte
const (
RequestCommandTCP = RequestCommand(0x01)
RequestCommandUDP = RequestCommand(0x02)
)
9 years ago
type RequestOption byte
const (
RequestOptionChunkStream = RequestOption(0x01)
RequestOptionConnectionReuse = RequestOption(0x02)
)
8 years ago
func (v RequestOption) Has(option RequestOption) bool {
return (v & option) == option
}
8 years ago
func (v *RequestOption) Set(option RequestOption) {
*v = (*v | option)
}
8 years ago
func (v *RequestOption) Clear(option RequestOption) {
*v = (*v & (^option))
}
type Security byte
func (v Security) Is(t SecurityType) bool {
return v == Security(t)
}
type RequestHeader struct {
Version byte
User *User
Command RequestCommand
Option RequestOption
Security Security
Address v2net.Address
Port v2net.Port
}
8 years ago
func (v *RequestHeader) Destination() v2net.Destination {
if v.Command == RequestCommandUDP {
return v2net.UDPDestination(v.Address, v.Port)
}
8 years ago
return v2net.TCPDestination(v.Address, v.Port)
}
type ResponseOption byte
9 years ago
const (
ResponseOptionConnectionReuse = ResponseOption(1)
)
8 years ago
func (v *ResponseOption) Set(option ResponseOption) {
*v = (*v | option)
}
8 years ago
func (v ResponseOption) Has(option ResponseOption) bool {
return (v | option) == option
}
8 years ago
func (v *ResponseOption) Clear(option ResponseOption) {
*v = (*v & (^option))
}
type ResponseCommand interface{}
type ResponseHeader struct {
Option ResponseOption
Command ResponseCommand
}
type CommandSwitchAccount struct {
Host v2net.Address
Port v2net.Port
ID *uuid.UUID
9 years ago
AlterIds uint16
Level uint32
ValidMin byte
}