1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00

rename command

This commit is contained in:
v2ray 2016-07-14 22:10:37 +02:00
parent ffdce592ec
commit ef2d49302d
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 16 additions and 16 deletions

View File

@ -429,7 +429,7 @@ func (this *Connection) Input(data []byte) int {
this.dataOutputCond.Signal()
case *CmdOnlySegment:
this.HandleOption(seg.Opt)
if seg.Cmd == SegmentCommandTerminated {
if seg.Cmd == CommandTerminate {
state := this.State()
if state == StateActive ||
state == StatePeerClosed {
@ -469,7 +469,7 @@ func (this *Connection) flush() {
defer seg.Release()
seg.Conv = this.conv
seg.Cmd = SegmentCommandTerminated
seg.Cmd = CommandTerminate
this.output.Write(seg)
this.output.Flush()
@ -493,7 +493,7 @@ func (this *Connection) flush() {
if this.sendingWorker.PingNecessary() || this.receivingWorker.PingNecessary() || current-atomic.LoadUint32(&this.lastPingTime) >= 5000 {
seg := NewCmdOnlySegment()
seg.Conv = this.conv
seg.Cmd = SegmentCommandPing
seg.Cmd = CommandPing
seg.ReceivinNext = this.receivingWorker.nextNumber
seg.SendingNext = this.sendingWorker.firstUnacknowledged
if this.State() == StateReadyToClose {

View File

@ -63,11 +63,11 @@ func (this *Listener) OnReceive(payload *alloc.Buffer, src v2net.Destination) {
return
}
conv := serial.BytesToUint16(payload.Value)
cmd := SegmentCommand(payload.Value[2])
cmd := Command(payload.Value[2])
sourceId := src.NetAddr() + "|" + serial.Uint16ToString(conv)
conn, found := this.sessions[sourceId]
if !found {
if cmd == SegmentCommandTerminated {
if cmd == CommandTerminate {
return
}
log.Debug("KCP|Listener: Creating session with id(", sourceId, ") from ", src)

View File

@ -7,13 +7,13 @@ import (
"github.com/v2ray/v2ray-core/common/serial"
)
type SegmentCommand byte
type Command byte
const (
SegmentCommandACK SegmentCommand = 0
SegmentCommandData SegmentCommand = 1
SegmentCommandTerminated SegmentCommand = 2
SegmentCommandPing SegmentCommand = 3
CommandACK Command = 0
CommandData Command = 1
CommandTerminate Command = 2
CommandPing Command = 3
)
type SegmentOption byte
@ -51,7 +51,7 @@ func NewDataSegment() *DataSegment {
func (this *DataSegment) Bytes(b []byte) []byte {
b = serial.Uint16ToBytes(this.Conv, b)
b = append(b, byte(SegmentCommandData), byte(this.Opt))
b = append(b, byte(CommandData), byte(this.Opt))
b = serial.Uint32ToBytes(this.Timestamp, b)
b = serial.Uint32ToBytes(this.Number, b)
b = serial.Uint32ToBytes(this.SendingNext, b)
@ -99,7 +99,7 @@ func (this *AckSegment) ByteSize() int {
func (this *AckSegment) Bytes(b []byte) []byte {
b = serial.Uint16ToBytes(this.Conv, b)
b = append(b, byte(SegmentCommandACK), byte(this.Opt))
b = append(b, byte(CommandACK), byte(this.Opt))
b = serial.Uint32ToBytes(this.ReceivingWindow, b)
b = serial.Uint32ToBytes(this.ReceivingNext, b)
b = append(b, this.Count)
@ -117,7 +117,7 @@ func (this *AckSegment) Release() {
type CmdOnlySegment struct {
Conv uint16
Cmd SegmentCommand
Cmd Command
Opt SegmentOption
SendingNext uint32
ReceivinNext uint32
@ -150,11 +150,11 @@ func ReadSegment(buf []byte) (Segment, []byte) {
conv := serial.BytesToUint16(buf)
buf = buf[2:]
cmd := SegmentCommand(buf[0])
cmd := Command(buf[0])
opt := SegmentOption(buf[1])
buf = buf[2:]
if cmd == SegmentCommandData {
if cmd == CommandData {
seg := NewDataSegment()
seg.Conv = conv
seg.Opt = opt
@ -182,7 +182,7 @@ func ReadSegment(buf []byte) (Segment, []byte) {
return seg, buf
}
if cmd == SegmentCommandACK {
if cmd == CommandACK {
seg := NewAckSegment()
seg.Conv = conv
seg.Opt = opt