1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-05 00:47:51 -05:00

fix lint warnings

This commit is contained in:
Darien Raymond 2017-12-03 16:40:10 +01:00
parent 443fd7c9a5
commit e8e7921613
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 6 additions and 7 deletions

View File

@ -198,8 +198,6 @@ type Connection struct {
dataUpdater *Updater dataUpdater *Updater
pingUpdater *Updater pingUpdater *Updater
mergingWriter buf.Writer
} }
// NewConnection create a new KCP connection between local and remote. // NewConnection create a new KCP connection between local and remote.
@ -285,7 +283,7 @@ func (v *Connection) ReadMultiBuffer() (buf.MultiBuffer, error) {
duration := time.Minute duration := time.Minute
if !v.rd.IsZero() { if !v.rd.IsZero() {
duration = v.rd.Sub(time.Now()) duration = time.Until(v.rd)
if duration < 0 { if duration < 0 {
return nil, ErrIOTimeout return nil, ErrIOTimeout
} }
@ -322,7 +320,7 @@ func (v *Connection) Read(b []byte) (int, error) {
duration := time.Minute duration := time.Minute
if !v.rd.IsZero() { if !v.rd.IsZero() {
duration = v.rd.Sub(time.Now()) duration = time.Until(v.rd)
if duration < 0 { if duration < 0 {
return 0, ErrIOTimeout return 0, ErrIOTimeout
} }
@ -358,7 +356,7 @@ func (v *Connection) Write(b []byte) (int, error) {
duration := time.Minute duration := time.Minute
if !v.wd.IsZero() { if !v.wd.IsZero() {
duration = v.wd.Sub(time.Now()) duration = time.Until(v.wd)
if duration < 0 { if duration < 0 {
return totalWritten, ErrIOTimeout return totalWritten, ErrIOTimeout
} }

View File

@ -1,6 +1,7 @@
package kcp package kcp
import ( import (
"v2ray.com/core/common"
"v2ray.com/core/common/buf" "v2ray.com/core/common/buf"
"v2ray.com/core/common/serial" "v2ray.com/core/common/serial"
) )
@ -65,9 +66,9 @@ func (v *DataSegment) SetData(data []byte) {
if v.Data == nil { if v.Data == nil {
v.Data = buf.New() v.Data = buf.New()
} }
v.Data.Reset(func(b []byte) (int, error) { common.Must(v.Data.Reset(func(b []byte) (int, error) {
return copy(b, data), nil return copy(b, data), nil
}) }))
} }
func (v *DataSegment) Bytes() buf.Supplier { func (v *DataSegment) Bytes() buf.Supplier {