fix lint warnings

pull/255/merge
Darien Raymond 2016-12-29 00:58:00 +01:00
parent 7bc98503a8
commit e6214b7a87
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 18 additions and 17 deletions

View File

@ -50,14 +50,14 @@ func (v *OutboundProxy) Dial(src v2net.Address, dest v2net.Destination, options
log.Info("Proxy: Dialing to ", dest) log.Info("Proxy: Dialing to ", dest)
stream := ray.NewRay() stream := ray.NewRay()
go handler.Dispatch(dest, nil, stream) go handler.Dispatch(dest, nil, stream)
return NewProxyConnection(src, dest, stream), nil return NewConnection(src, dest, stream), nil
} }
func (v *OutboundProxy) Release() { func (v *OutboundProxy) Release() {
} }
type ProxyConnection struct { type Connection struct {
stream ray.Ray stream ray.Ray
closed bool closed bool
localAddr net.Addr localAddr net.Addr
@ -67,8 +67,8 @@ type ProxyConnection struct {
writer *buf.BytesToBufferWriter writer *buf.BytesToBufferWriter
} }
func NewProxyConnection(src v2net.Address, dest v2net.Destination, stream ray.Ray) *ProxyConnection { func NewConnection(src v2net.Address, dest v2net.Destination, stream ray.Ray) *Connection {
return &ProxyConnection{ return &Connection{
stream: stream, stream: stream,
localAddr: &net.TCPAddr{ localAddr: &net.TCPAddr{
IP: []byte{0, 0, 0, 0}, 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 { if v.closed {
return 0, io.EOF return 0, io.EOF
} }
return v.reader.Read(b) return v.reader.Read(b)
} }
func (v *ProxyConnection) Write(b []byte) (int, error) { func (v *Connection) Write(b []byte) (int, error) {
if v.closed { if v.closed {
return 0, io.ErrClosedPipe return 0, io.ErrClosedPipe
} }
return v.writer.Write(b) return v.writer.Write(b)
} }
func (v *ProxyConnection) Close() error { func (v *Connection) Close() error {
v.closed = true v.closed = true
v.stream.InboundInput().Close() v.stream.InboundInput().Close()
v.stream.InboundOutput().Release() v.stream.InboundOutput().Release()
@ -106,30 +106,30 @@ func (v *ProxyConnection) Close() error {
return nil return nil
} }
func (v *ProxyConnection) LocalAddr() net.Addr { func (v *Connection) LocalAddr() net.Addr {
return v.localAddr return v.localAddr
} }
func (v *ProxyConnection) RemoteAddr() net.Addr { func (v *Connection) RemoteAddr() net.Addr {
return v.remoteAddr return v.remoteAddr
} }
func (v *ProxyConnection) SetDeadline(t time.Time) error { func (v *Connection) SetDeadline(t time.Time) error {
return nil return nil
} }
func (v *ProxyConnection) SetReadDeadline(t time.Time) error { func (v *Connection) SetReadDeadline(t time.Time) error {
return nil return nil
} }
func (v *ProxyConnection) SetWriteDeadline(t time.Time) error { func (v *Connection) SetWriteDeadline(t time.Time) error {
return nil return nil
} }
func (v *ProxyConnection) Reusable() bool { func (v *Connection) Reusable() bool {
return false return false
} }
func (v *ProxyConnection) SetReusable(bool) { func (v *Connection) SetReusable(bool) {
} }

View File

@ -7,6 +7,7 @@ import (
. "v2ray.com/core/app/proxy" . "v2ray.com/core/app/proxy"
"v2ray.com/core/app/proxyman" "v2ray.com/core/app/proxyman"
"v2ray.com/core/app/proxyman/outbound" "v2ray.com/core/app/proxyman/outbound"
"v2ray.com/core/common"
v2net "v2ray.com/core/common/net" v2net "v2ray.com/core/common/net"
"v2ray.com/core/proxy" "v2ray.com/core/proxy"
"v2ray.com/core/proxy/freedom" "v2ray.com/core/proxy/freedom"
@ -21,12 +22,12 @@ func TestProxyDial(t *testing.T) {
space := app.NewSpace() space := app.NewSpace()
outboundManager := outbound.New() 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", Tag: "tag",
StreamSettings: &internet.StreamConfig{ StreamSettings: &internet.StreamConfig{
Network: v2net.Network_RawTCP, Network: v2net.Network_RawTCP,
}, },
})) })))
space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, outboundManager) space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, outboundManager)
proxy := NewOutboundProxy(space) proxy := NewOutboundProxy(space)
@ -65,6 +66,6 @@ func TestProxyDial(t *testing.T) {
assert.Bytes(xor(b[:nBytes])).Equals([]byte{'a', 'b', 'c', 'd'}) assert.Bytes(xor(b[:nBytes])).Equals([]byte{'a', 'b', 'c', 'd'})
conn.Close() common.Must(conn.Close())
tcpServer.Close() tcpServer.Close()
} }