remove rawtcp

This commit is contained in:
Darien Raymond committed 2017-01-03 14:53:59 +01:00
1 parent 3732de18b1
commit 31d6e74482
21 files changed
+41 -124

No files matched your search

+6 -10
View File
@@ -2,6 +2,7 @@ package internet
import (
"net"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/log"
v2net "v2ray.com/core/common/net"
@@ -19,12 +20,11 @@ type DialerOptions struct {
type Dialer func(src v2net.Address, dest v2net.Destination, options DialerOptions) (Connection, error)
var (
TCPDialer Dialer
KCPDialer Dialer
RawTCPDialer Dialer
UDPDialer Dialer
WSDialer Dialer
ProxyDialer Dialer
TCPDialer Dialer
KCPDialer Dialer
UDPDialer Dialer
WSDialer Dialer
ProxyDialer Dialer
)
func Dial(src v2net.Address, dest v2net.Destination, options DialerOptions) (Connection, error) {
@@ -43,10 +43,6 @@ func Dial(src v2net.Address, dest v2net.Destination, options DialerOptions) (Con
connection, err = KCPDialer(src, dest, options)
case v2net.Network_WebSocket:
connection, err = WSDialer(src, dest, options)
// This check has to be the last one.
case v2net.Network_RawTCP:
connection, err = RawTCPDialer(src, dest, options)
default:
return nil, ErrUnsupportedStreamType
}
-14
View File
@@ -9,20 +9,6 @@ import (
"v2ray.com/core/transport/internet/internal"
)
type RawConnection struct {
net.TCPConn
}
func (v *RawConnection) Reusable() bool {
return false
}
func (v *RawConnection) SetReusable(b bool) {}
func (v *RawConnection) SysFd() (int, error) {
return internal.GetSysFd(&v.TCPConn)
}
type Connection struct {
sync.RWMutex
id internal.ConnectionID
-19
View File
@@ -1,19 +0,0 @@
package tcp_test
import (
"net"
"testing"
"v2ray.com/core/testing/assert"
. "v2ray.com/core/transport/internet/tcp"
)
func TestRawConnection(t *testing.T) {
assert := assert.On(t)
rawConn := RawConnection{net.TCPConn{}}
assert.Bool(rawConn.Reusable()).IsFalse()
rawConn.SetReusable(true)
assert.Bool(rawConn.Reusable()).IsFalse()
}
-13
View File
@@ -68,19 +68,6 @@ func Dial(src v2net.Address, dest v2net.Destination, options internet.DialerOpti
return NewConnection(id, conn, globalCache, tcpSettings), nil
}
func DialRaw(src v2net.Address, dest v2net.Destination, options internet.DialerOptions) (internet.Connection, error) {
log.Info("Internet|TCP: Dailing Raw TCP to ", dest)
conn, err := internet.DialToDest(src, dest)
if err != nil {
return nil, err
}
// TODO: handle dialer options
return &RawConnection{
TCPConn: *conn.(*net.TCPConn),
}, nil
}
func init() {
internet.TCPDialer = Dial
internet.RawTCPDialer = DialRaw
}
+1 -41
View File
@@ -5,6 +5,7 @@ import (
"net"
"sync"
"time"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/log"
v2net "v2ray.com/core/common/net"
@@ -156,47 +157,6 @@ func (v *TCPListener) Close() error {
return nil
}
type RawTCPListener struct {
accepting bool
listener *net.TCPListener
}
func (v *RawTCPListener) Accept() (internet.Connection, error) {
conn, err := v.listener.AcceptTCP()
if err != nil {
return nil, err
}
return &RawConnection{
TCPConn: *conn,
}, nil
}
func (v *RawTCPListener) Addr() net.Addr {
return v.listener.Addr()
}
func (v *RawTCPListener) Close() error {
v.accepting = false
v.listener.Close()
return nil
}
func ListenRawTCP(address v2net.Address, port v2net.Port, options internet.ListenOptions) (internet.Listener, error) {
listener, err := net.ListenTCP("tcp", &net.TCPAddr{
IP: address.IP(),
Port: int(port),
})
if err != nil {
return nil, err
}
// TODO: handle listen options
return &RawTCPListener{
accepting: true,
listener: listener,
}, nil
}
func init() {
internet.TCPListenFunc = ListenTCP
internet.RawTCPListenFunc = ListenRawTCP
}
+4 -6
View File
@@ -3,6 +3,7 @@ package internet
import (
"net"
"sync"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/log"
v2net "v2ray.com/core/common/net"
@@ -12,10 +13,9 @@ import (
var (
ErrClosedConnection = errors.New("Connection already closed.")
KCPListenFunc ListenFunc
TCPListenFunc ListenFunc
RawTCPListenFunc ListenFunc
WSListenFunc ListenFunc
KCPListenFunc ListenFunc
TCPListenFunc ListenFunc
WSListenFunc ListenFunc
)
type ListenFunc func(address v2net.Address, port v2net.Port, options ListenOptions) (Listener, error)
@@ -49,8 +49,6 @@ func ListenTCP(address v2net.Address, port v2net.Port, callback ConnectionHandle
listener, err = KCPListenFunc(address, port, options)
case v2net.Network_WebSocket:
listener, err = WSListenFunc(address, port, options)
case v2net.Network_RawTCP:
listener, err = RawTCPListenFunc(address, port, options)
default:
log.Error("Internet|Listener: Unknown stream type: ", settings.Network)
err = ErrUnsupportedStreamType