mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-12 07:19:01 -05:00
remove rawtcp
This commit is contained in:
parent
3732de18b1
commit
31d6e74482
@ -25,7 +25,7 @@ func TestProxyDial(t *testing.T) {
|
|||||||
common.Must(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_TCP,
|
||||||
},
|
},
|
||||||
})))
|
})))
|
||||||
space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, outboundManager)
|
space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, outboundManager)
|
||||||
@ -49,7 +49,7 @@ func TestProxyDial(t *testing.T) {
|
|||||||
|
|
||||||
conn, err := proxy.Dial(v2net.LocalHostIP, dest, internet.DialerOptions{
|
conn, err := proxy.Dial(v2net.LocalHostIP, dest, internet.DialerOptions{
|
||||||
Stream: &internet.StreamConfig{
|
Stream: &internet.StreamConfig{
|
||||||
Network: v2net.Network_RawTCP,
|
Network: v2net.Network_TCP,
|
||||||
},
|
},
|
||||||
Proxy: &internet.ProxyConfig{
|
Proxy: &internet.ProxyConfig{
|
||||||
Tag: "tag",
|
Tag: "tag",
|
||||||
|
@ -30,7 +30,7 @@ func (v Network) AsList() *NetworkList {
|
|||||||
|
|
||||||
func (v Network) SystemString() string {
|
func (v Network) SystemString() string {
|
||||||
switch v {
|
switch v {
|
||||||
case Network_TCP, Network_RawTCP:
|
case Network_TCP:
|
||||||
return "tcp"
|
return "tcp"
|
||||||
case Network_UDP, Network_KCP:
|
case Network_UDP, Network_KCP:
|
||||||
return "udp"
|
return "udp"
|
||||||
@ -41,7 +41,7 @@ func (v Network) SystemString() string {
|
|||||||
|
|
||||||
func (v Network) URLPrefix() string {
|
func (v Network) URLPrefix() string {
|
||||||
switch v {
|
switch v {
|
||||||
case Network_TCP, Network_RawTCP:
|
case Network_TCP:
|
||||||
return "tcp"
|
return "tcp"
|
||||||
case Network_UDP:
|
case Network_UDP:
|
||||||
return "udp"
|
return "udp"
|
||||||
|
@ -10,7 +10,7 @@ enum Network {
|
|||||||
Unknown = 0;
|
Unknown = 0;
|
||||||
|
|
||||||
// Native TCP provided by system.
|
// Native TCP provided by system.
|
||||||
RawTCP = 1;
|
RawTCP = 1 [deprecated=true];
|
||||||
|
|
||||||
// V2Ray specific TCP.
|
// V2Ray specific TCP.
|
||||||
TCP = 2;
|
TCP = 2;
|
||||||
|
@ -43,7 +43,7 @@ type Factory struct{}
|
|||||||
// StreamCapability implements OutboundHandlerFactory.StreamCapability().
|
// StreamCapability implements OutboundHandlerFactory.StreamCapability().
|
||||||
func (v *Factory) StreamCapability() v2net.NetworkList {
|
func (v *Factory) StreamCapability() v2net.NetworkList {
|
||||||
return v2net.NetworkList{
|
return v2net.NetworkList{
|
||||||
Network: []v2net.Network{v2net.Network_RawTCP},
|
Network: []v2net.Network{v2net.Network_TCP},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ func (v *DokodemoDoor) ListenTCP() error {
|
|||||||
|
|
||||||
func (v *DokodemoDoor) HandleTCPConnection(conn internet.Connection) {
|
func (v *DokodemoDoor) HandleTCPConnection(conn internet.Connection) {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
conn.SetReusable(false)
|
||||||
|
|
||||||
var dest v2net.Destination
|
var dest v2net.Destination
|
||||||
if v.config.FollowRedirect {
|
if v.config.FollowRedirect {
|
||||||
@ -209,7 +210,7 @@ type Factory struct{}
|
|||||||
|
|
||||||
func (v *Factory) StreamCapability() v2net.NetworkList {
|
func (v *Factory) StreamCapability() v2net.NetworkList {
|
||||||
return v2net.NetworkList{
|
return v2net.NetworkList{
|
||||||
Network: []v2net.Network{v2net.Network_RawTCP},
|
Network: []v2net.Network{v2net.Network_TCP},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func TestDokodemoTCP(t *testing.T) {
|
|||||||
&proxy.OutboundHandlerMeta{
|
&proxy.OutboundHandlerMeta{
|
||||||
Address: v2net.LocalHostIP,
|
Address: v2net.LocalHostIP,
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
Network: v2net.Network_RawTCP,
|
Network: v2net.Network_TCP,
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, ohm)
|
space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, ohm)
|
||||||
@ -64,7 +64,7 @@ func TestDokodemoTCP(t *testing.T) {
|
|||||||
Address: v2net.LocalHostIP,
|
Address: v2net.LocalHostIP,
|
||||||
Port: port,
|
Port: port,
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
Network: v2net.Network_RawTCP,
|
Network: v2net.Network_TCP,
|
||||||
}})
|
}})
|
||||||
defer dokodemo.Close()
|
defer dokodemo.Close()
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ func TestDokodemoUDP(t *testing.T) {
|
|||||||
&proxy.OutboundHandlerMeta{
|
&proxy.OutboundHandlerMeta{
|
||||||
Address: v2net.AnyIP,
|
Address: v2net.AnyIP,
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
Network: v2net.Network_RawTCP,
|
Network: v2net.Network_TCP,
|
||||||
}}))
|
}}))
|
||||||
space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, ohm)
|
space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, ohm)
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ func TestDokodemoUDP(t *testing.T) {
|
|||||||
Address: v2net.LocalHostIP,
|
Address: v2net.LocalHostIP,
|
||||||
Port: port,
|
Port: port,
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
Network: v2net.Network_RawTCP,
|
Network: v2net.Network_TCP,
|
||||||
}})
|
}})
|
||||||
defer dokodemo.Close()
|
defer dokodemo.Close()
|
||||||
|
|
||||||
|
@ -94,6 +94,8 @@ func (v *Handler) Dispatch(destination v2net.Destination, payload *buf.Buffer, r
|
|||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
conn.SetReusable(false)
|
||||||
|
|
||||||
if !payload.IsEmpty() {
|
if !payload.IsEmpty() {
|
||||||
if _, err := conn.Write(payload.Bytes()); err != nil {
|
if _, err := conn.Write(payload.Bytes()); err != nil {
|
||||||
log.Warning("Freedom: Failed to write to destination: ", destination, ": ", err)
|
log.Warning("Freedom: Failed to write to destination: ", destination, ": ", err)
|
||||||
@ -144,7 +146,7 @@ type Factory struct{}
|
|||||||
|
|
||||||
func (v *Factory) StreamCapability() v2net.NetworkList {
|
func (v *Factory) StreamCapability() v2net.NetworkList {
|
||||||
return v2net.NetworkList{
|
return v2net.NetworkList{
|
||||||
Network: []v2net.Network{v2net.Network_RawTCP},
|
Network: []v2net.Network{v2net.Network_TCP},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ func TestSinglePacket(t *testing.T) {
|
|||||||
&proxy.OutboundHandlerMeta{
|
&proxy.OutboundHandlerMeta{
|
||||||
Address: v2net.AnyIP,
|
Address: v2net.AnyIP,
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
Network: v2net.Network_RawTCP,
|
Network: v2net.Network_TCP,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
assert.Error(space.Initialize()).IsNil()
|
assert.Error(space.Initialize()).IsNil()
|
||||||
@ -86,7 +86,7 @@ func TestIPResolution(t *testing.T) {
|
|||||||
&proxy.OutboundHandlerMeta{
|
&proxy.OutboundHandlerMeta{
|
||||||
Address: v2net.AnyIP,
|
Address: v2net.AnyIP,
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
Network: v2net.Network_RawTCP,
|
Network: v2net.Network_TCP,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -100,6 +100,8 @@ func parseHost(rawHost string, defaultPort v2net.Port) (v2net.Destination, error
|
|||||||
|
|
||||||
func (v *Server) handleConnection(conn internet.Connection) {
|
func (v *Server) handleConnection(conn internet.Connection) {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
conn.SetReusable(false)
|
||||||
|
|
||||||
timedReader := v2net.NewTimeOutReader(v.config.Timeout, conn)
|
timedReader := v2net.NewTimeOutReader(v.config.Timeout, conn)
|
||||||
reader := bufio.OriginalReaderSize(timedReader, 2048)
|
reader := bufio.OriginalReaderSize(timedReader, 2048)
|
||||||
|
|
||||||
@ -289,7 +291,7 @@ type ServerFactory struct{}
|
|||||||
// StreamCapability implements InboundHandlerFactory.StreamCapability().
|
// StreamCapability implements InboundHandlerFactory.StreamCapability().
|
||||||
func (v *ServerFactory) StreamCapability() v2net.NetworkList {
|
func (v *ServerFactory) StreamCapability() v2net.NetworkList {
|
||||||
return v2net.NetworkList{
|
return v2net.NetworkList{
|
||||||
Network: []v2net.Network{v2net.Network_RawTCP},
|
Network: []v2net.Network{v2net.Network_TCP},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ func TestNormalGetRequest(t *testing.T) {
|
|||||||
Address: v2net.LocalHostIP,
|
Address: v2net.LocalHostIP,
|
||||||
Port: port,
|
Port: port,
|
||||||
StreamSettings: &internet.StreamConfig{
|
StreamSettings: &internet.StreamConfig{
|
||||||
Network: v2net.Network_RawTCP,
|
Network: v2net.Network_TCP,
|
||||||
}})
|
}})
|
||||||
defer httpProxy.Close()
|
defer httpProxy.Close()
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ type ClientFactory struct{}
|
|||||||
// StreamCapability implements OutboundHandlerFactory.StreamCapability().
|
// StreamCapability implements OutboundHandlerFactory.StreamCapability().
|
||||||
func (v *ClientFactory) StreamCapability() v2net.NetworkList {
|
func (v *ClientFactory) StreamCapability() v2net.NetworkList {
|
||||||
return v2net.NetworkList{
|
return v2net.NetworkList{
|
||||||
Network: []v2net.Network{v2net.Network_TCP, v2net.Network_RawTCP},
|
Network: []v2net.Network{v2net.Network_TCP},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ type ServerFactory struct{}
|
|||||||
|
|
||||||
func (v *ServerFactory) StreamCapability() v2net.NetworkList {
|
func (v *ServerFactory) StreamCapability() v2net.NetworkList {
|
||||||
return v2net.NetworkList{
|
return v2net.NetworkList{
|
||||||
Network: []v2net.Network{v2net.Network_TCP, v2net.Network_RawTCP},
|
Network: []v2net.Network{v2net.Network_TCP},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// Package shadowsocks provides compatible functionality to Shadowsocks.
|
// Package shadowsocks provides compatible functionality to Shadowsocks.
|
||||||
//
|
//
|
||||||
// Shadowsocks client and server are implemented as outbound and inbound respectively in V2Ray's term.
|
// Shadowsocks client and server are implemented as outbound and inbound respectively in V2Ray's term.
|
||||||
// Shadowsocks OTA is fully supported.
|
//
|
||||||
|
// Shadowsocks OTA is fully supported. By default both client and server enable OTA, but it can be optionally disabled.
|
||||||
|
//
|
||||||
// Supperted Ciphers:
|
// Supperted Ciphers:
|
||||||
// * AES-256-CFB
|
// * AES-256-CFB
|
||||||
// * AES-128-CFB
|
// * AES-128-CFB
|
||||||
|
@ -107,6 +107,8 @@ func (v *Server) Start() error {
|
|||||||
func (v *Server) handleConnection(connection internet.Connection) {
|
func (v *Server) handleConnection(connection internet.Connection) {
|
||||||
defer connection.Close()
|
defer connection.Close()
|
||||||
|
|
||||||
|
connection.SetReusable(false)
|
||||||
|
|
||||||
timedReader := v2net.NewTimeOutReader(v.config.Timeout, connection)
|
timedReader := v2net.NewTimeOutReader(v.config.Timeout, connection)
|
||||||
reader := bufio.NewReader(timedReader)
|
reader := bufio.NewReader(timedReader)
|
||||||
defer reader.Release()
|
defer reader.Release()
|
||||||
@ -336,7 +338,7 @@ type ServerFactory struct{}
|
|||||||
|
|
||||||
func (v *ServerFactory) StreamCapability() v2net.NetworkList {
|
func (v *ServerFactory) StreamCapability() v2net.NetworkList {
|
||||||
return v2net.NetworkList{
|
return v2net.NetworkList{
|
||||||
Network: []v2net.Network{v2net.Network_RawTCP},
|
Network: []v2net.Network{v2net.Network_TCP},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ type StreamConfig struct {
|
|||||||
|
|
||||||
func (v *StreamConfig) Build() (*internet.StreamConfig, error) {
|
func (v *StreamConfig) Build() (*internet.StreamConfig, error) {
|
||||||
config := &internet.StreamConfig{
|
config := &internet.StreamConfig{
|
||||||
Network: v2net.Network_RawTCP,
|
Network: v2net.Network_TCP,
|
||||||
}
|
}
|
||||||
if v.Network != nil {
|
if v.Network != nil {
|
||||||
config.Network = (*v.Network).Build()
|
config.Network = (*v.Network).Build()
|
||||||
|
@ -2,6 +2,7 @@ package internet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"v2ray.com/core/common/errors"
|
"v2ray.com/core/common/errors"
|
||||||
"v2ray.com/core/common/log"
|
"v2ray.com/core/common/log"
|
||||||
v2net "v2ray.com/core/common/net"
|
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)
|
type Dialer func(src v2net.Address, dest v2net.Destination, options DialerOptions) (Connection, error)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
TCPDialer Dialer
|
TCPDialer Dialer
|
||||||
KCPDialer Dialer
|
KCPDialer Dialer
|
||||||
RawTCPDialer Dialer
|
UDPDialer Dialer
|
||||||
UDPDialer Dialer
|
WSDialer Dialer
|
||||||
WSDialer Dialer
|
ProxyDialer Dialer
|
||||||
ProxyDialer Dialer
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Dial(src v2net.Address, dest v2net.Destination, options DialerOptions) (Connection, error) {
|
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)
|
connection, err = KCPDialer(src, dest, options)
|
||||||
case v2net.Network_WebSocket:
|
case v2net.Network_WebSocket:
|
||||||
connection, err = WSDialer(src, dest, options)
|
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:
|
default:
|
||||||
return nil, ErrUnsupportedStreamType
|
return nil, ErrUnsupportedStreamType
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,6 @@ import (
|
|||||||
"v2ray.com/core/transport/internet/internal"
|
"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 {
|
type Connection struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
id internal.ConnectionID
|
id internal.ConnectionID
|
||||||
|
@ -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()
|
|
||||||
}
|
|
@ -68,19 +68,6 @@ func Dial(src v2net.Address, dest v2net.Destination, options internet.DialerOpti
|
|||||||
return NewConnection(id, conn, globalCache, tcpSettings), nil
|
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() {
|
func init() {
|
||||||
internet.TCPDialer = Dial
|
internet.TCPDialer = Dial
|
||||||
internet.RawTCPDialer = DialRaw
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"v2ray.com/core/common/errors"
|
"v2ray.com/core/common/errors"
|
||||||
"v2ray.com/core/common/log"
|
"v2ray.com/core/common/log"
|
||||||
v2net "v2ray.com/core/common/net"
|
v2net "v2ray.com/core/common/net"
|
||||||
@ -156,47 +157,6 @@ func (v *TCPListener) Close() error {
|
|||||||
return nil
|
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() {
|
func init() {
|
||||||
internet.TCPListenFunc = ListenTCP
|
internet.TCPListenFunc = ListenTCP
|
||||||
internet.RawTCPListenFunc = ListenRawTCP
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package internet
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"v2ray.com/core/common/errors"
|
"v2ray.com/core/common/errors"
|
||||||
"v2ray.com/core/common/log"
|
"v2ray.com/core/common/log"
|
||||||
v2net "v2ray.com/core/common/net"
|
v2net "v2ray.com/core/common/net"
|
||||||
@ -12,10 +13,9 @@ import (
|
|||||||
var (
|
var (
|
||||||
ErrClosedConnection = errors.New("Connection already closed.")
|
ErrClosedConnection = errors.New("Connection already closed.")
|
||||||
|
|
||||||
KCPListenFunc ListenFunc
|
KCPListenFunc ListenFunc
|
||||||
TCPListenFunc ListenFunc
|
TCPListenFunc ListenFunc
|
||||||
RawTCPListenFunc ListenFunc
|
WSListenFunc ListenFunc
|
||||||
WSListenFunc ListenFunc
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ListenFunc func(address v2net.Address, port v2net.Port, options ListenOptions) (Listener, error)
|
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)
|
listener, err = KCPListenFunc(address, port, options)
|
||||||
case v2net.Network_WebSocket:
|
case v2net.Network_WebSocket:
|
||||||
listener, err = WSListenFunc(address, port, options)
|
listener, err = WSListenFunc(address, port, options)
|
||||||
case v2net.Network_RawTCP:
|
|
||||||
listener, err = RawTCPListenFunc(address, port, options)
|
|
||||||
default:
|
default:
|
||||||
log.Error("Internet|Listener: Unknown stream type: ", settings.Network)
|
log.Error("Internet|Listener: Unknown stream type: ", settings.Network)
|
||||||
err = ErrUnsupportedStreamType
|
err = ErrUnsupportedStreamType
|
||||||
|
Loading…
Reference in New Issue
Block a user