From 3ad83da7cbaf07138771ba97957b1fc8390ea8a8 Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 2 Jul 2016 22:17:41 +0200 Subject: [PATCH] rename acksegment --- transport/internet/kcp/kcp.go | 2 +- transport/internet/kcp/receiving.go | 4 ++-- transport/internet/kcp/segment.go | 10 +++++----- transport/internet/kcp/segment_test.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/transport/internet/kcp/kcp.go b/transport/internet/kcp/kcp.go index dd78e9186..8722851ea 100644 --- a/transport/internet/kcp/kcp.go +++ b/transport/internet/kcp/kcp.go @@ -208,7 +208,7 @@ func (kcp *KCP) Input(data []byte) int { kcp.HandleOption(seg.Opt) kcp.receivingWorker.ProcessSegment(seg) kcp.lastPayloadTime = kcp.current - case *ACKSegment: + case *AckSegment: kcp.HandleOption(seg.Opt) if kcp.rmt_wnd < seg.ReceivingWindow { kcp.rmt_wnd = seg.ReceivingWindow diff --git a/transport/internet/kcp/receiving.go b/transport/internet/kcp/receiving.go index 18dfaa153..3552f6a6b 100644 --- a/transport/internet/kcp/receiving.go +++ b/transport/internet/kcp/receiving.go @@ -182,7 +182,7 @@ func (this *AckList) Clear(una uint32) { } func (this *AckList) Flush(current uint32) { - seg := new(ACKSegment) + seg := new(AckSegment) for i := 0; i < len(this.numbers); i++ { if this.nextFlush[i] <= current { seg.Count++ @@ -292,7 +292,7 @@ func (this *ReceivingWorker) Flush() { } func (this *ReceivingWorker) Write(seg ISegment) { - ackSeg := seg.(*ACKSegment) + ackSeg := seg.(*AckSegment) ackSeg.Conv = this.kcp.conv ackSeg.ReceivingNext = this.nextNumber ackSeg.ReceivingWindow = this.nextNumber + this.windowSize diff --git a/transport/internet/kcp/segment.go b/transport/internet/kcp/segment.go index 27907ff42..08fc7d8bd 100644 --- a/transport/internet/kcp/segment.go +++ b/transport/internet/kcp/segment.go @@ -64,7 +64,7 @@ func (this *DataSegment) Release() { this.Data.Release() } -type ACKSegment struct { +type AckSegment struct { Conv uint16 Opt SegmentOption ReceivingWindow uint32 @@ -74,11 +74,11 @@ type ACKSegment struct { TimestampList []uint32 } -func (this *ACKSegment) ByteSize() int { +func (this *AckSegment) ByteSize() int { return 2 + 1 + 1 + 4 + 4 + 1 + int(this.Count)*4 + int(this.Count)*4 } -func (this *ACKSegment) Bytes(b []byte) []byte { +func (this *AckSegment) Bytes(b []byte) []byte { b = serial.Uint16ToBytes(this.Conv, b) b = append(b, byte(SegmentCommandACK), byte(this.Opt)) b = serial.Uint32ToBytes(this.ReceivingWindow, b) @@ -91,7 +91,7 @@ func (this *ACKSegment) Bytes(b []byte) []byte { return b } -func (this *ACKSegment) Release() {} +func (this *AckSegment) Release() {} type CmdOnlySegment struct { Conv uint16 @@ -157,7 +157,7 @@ func ReadSegment(buf []byte) (ISegment, []byte) { } if cmd == SegmentCommandACK { - seg := &ACKSegment{ + seg := &AckSegment{ Conv: conv, Opt: opt, } diff --git a/transport/internet/kcp/segment_test.go b/transport/internet/kcp/segment_test.go index 49f98880d..4ca2460cd 100644 --- a/transport/internet/kcp/segment_test.go +++ b/transport/internet/kcp/segment_test.go @@ -44,7 +44,7 @@ func TestDataSegment(t *testing.T) { func TestACKSegment(t *testing.T) { assert := assert.On(t) - seg := &ACKSegment{ + seg := &AckSegment{ Conv: 1, ReceivingWindow: 2, ReceivingNext: 3, @@ -59,7 +59,7 @@ func TestACKSegment(t *testing.T) { assert.Int(len(bytes)).Equals(nBytes) iseg, _ := ReadSegment(bytes) - seg2 := iseg.(*ACKSegment) + seg2 := iseg.(*AckSegment) assert.Uint16(seg2.Conv).Equals(seg.Conv) assert.Uint32(seg2.ReceivingWindow).Equals(seg.ReceivingWindow) assert.Uint32(seg2.ReceivingNext).Equals(seg.ReceivingNext)