Browse Source

fix lint warnings

Darien Raymond 9 years ago
parent
commit
e6214b7a87
2 changed files with 18 additions and 17 deletions
  1. 14 14
      app/proxy/proxy.go
  2. 4 3
      app/proxy/proxy_test.go

+ 14 - 14
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) {
 
 }

+ 4 - 3
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()
 }