From e6214b7a8746af0a1dc6b9c6be81dcce46356188 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Thu, 29 Dec 2016 00:58:00 +0100 Subject: [PATCH] fix lint warnings --- app/proxy/proxy.go | 28 ++++++++++++++-------------- app/proxy/proxy_test.go | 7 ++++--- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/app/proxy/proxy.go b/app/proxy/proxy.go index d2d0f0b5..7d63e16a 100644 --- a/app/proxy/proxy.go +++ b/app/proxy/proxy.go @@ -50,14 +50,14 @@ func (v *OutboundProxy) Dial(src v2net.Address, dest v2net.Destination, options log.Info("Proxy: Dialing to ", dest) stream := ray.NewRay() go handler.Dispatch(dest, nil, stream) - return NewProxyConnection(src, dest, stream), nil + return NewConnection(src, dest, stream), nil } func (v *OutboundProxy) Release() { } -type ProxyConnection struct { +type Connection struct { stream ray.Ray closed bool localAddr net.Addr @@ -67,8 +67,8 @@ type ProxyConnection struct { writer *buf.BytesToBufferWriter } -func NewProxyConnection(src v2net.Address, dest v2net.Destination, stream ray.Ray) *ProxyConnection { - return &ProxyConnection{ +func NewConnection(src v2net.Address, dest v2net.Destination, stream ray.Ray) *Connection { + return &Connection{ stream: stream, localAddr: &net.TCPAddr{ IP: []byte{0, 0, 0, 0}, @@ -83,21 +83,21 @@ func NewProxyConnection(src v2net.Address, dest v2net.Destination, stream ray.Ra } } -func (v *ProxyConnection) Read(b []byte) (int, error) { +func (v *Connection) Read(b []byte) (int, error) { if v.closed { return 0, io.EOF } return v.reader.Read(b) } -func (v *ProxyConnection) Write(b []byte) (int, error) { +func (v *Connection) Write(b []byte) (int, error) { if v.closed { return 0, io.ErrClosedPipe } return v.writer.Write(b) } -func (v *ProxyConnection) Close() error { +func (v *Connection) Close() error { v.closed = true v.stream.InboundInput().Close() v.stream.InboundOutput().Release() @@ -106,30 +106,30 @@ func (v *ProxyConnection) Close() error { return nil } -func (v *ProxyConnection) LocalAddr() net.Addr { +func (v *Connection) LocalAddr() net.Addr { return v.localAddr } -func (v *ProxyConnection) RemoteAddr() net.Addr { +func (v *Connection) RemoteAddr() net.Addr { return v.remoteAddr } -func (v *ProxyConnection) SetDeadline(t time.Time) error { +func (v *Connection) SetDeadline(t time.Time) error { return nil } -func (v *ProxyConnection) SetReadDeadline(t time.Time) error { +func (v *Connection) SetReadDeadline(t time.Time) error { return nil } -func (v *ProxyConnection) SetWriteDeadline(t time.Time) error { +func (v *Connection) SetWriteDeadline(t time.Time) error { return nil } -func (v *ProxyConnection) Reusable() bool { +func (v *Connection) Reusable() bool { return false } -func (v *ProxyConnection) SetReusable(bool) { +func (v *Connection) SetReusable(bool) { } diff --git a/app/proxy/proxy_test.go b/app/proxy/proxy_test.go index 14bd0d7e..902cefb3 100644 --- a/app/proxy/proxy_test.go +++ b/app/proxy/proxy_test.go @@ -7,6 +7,7 @@ import ( . "v2ray.com/core/app/proxy" "v2ray.com/core/app/proxyman" "v2ray.com/core/app/proxyman/outbound" + "v2ray.com/core/common" v2net "v2ray.com/core/common/net" "v2ray.com/core/proxy" "v2ray.com/core/proxy/freedom" @@ -21,12 +22,12 @@ func TestProxyDial(t *testing.T) { space := app.NewSpace() outboundManager := outbound.New() - outboundManager.SetHandler("tag", freedom.New(&freedom.Config{}, space, &proxy.OutboundHandlerMeta{ + common.Must(outboundManager.SetHandler("tag", freedom.New(&freedom.Config{}, space, &proxy.OutboundHandlerMeta{ Tag: "tag", StreamSettings: &internet.StreamConfig{ Network: v2net.Network_RawTCP, }, - })) + }))) space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, outboundManager) proxy := NewOutboundProxy(space) @@ -65,6 +66,6 @@ func TestProxyDial(t *testing.T) { assert.Bytes(xor(b[:nBytes])).Equals([]byte{'a', 'b', 'c', 'd'}) - conn.Close() + common.Must(conn.Close()) tcpServer.Close() }