mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
refine proto settings
This commit is contained in:
parent
2a52ae9e96
commit
58ae7e4967
@ -5,11 +5,11 @@ import (
|
||||
"v2ray.com/core/transport/internet"
|
||||
)
|
||||
|
||||
func (v *ConnectionReuse) IsEnabled() bool {
|
||||
if v == nil {
|
||||
func (v *Config) IsConnectionReuse() bool {
|
||||
if v == nil || v.ConnectionReuse == nil {
|
||||
return true
|
||||
}
|
||||
return v.Enable
|
||||
return v.ConnectionReuse.Enable
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -39,7 +39,7 @@ func NewConnection(id internal.ConnectionId, conn net.Conn, manager ConnectionMa
|
||||
id: id,
|
||||
conn: conn,
|
||||
listener: manager,
|
||||
reusable: config.ConnectionReuse.IsEnabled(),
|
||||
reusable: config.IsConnectionReuse(),
|
||||
config: config,
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ func (v *Connection) SetReusable(reusable bool) {
|
||||
}
|
||||
|
||||
func (v *Connection) Reusable() bool {
|
||||
return v.config.ConnectionReuse.IsEnabled() && v.reusable
|
||||
return v.config.IsConnectionReuse() && v.reusable
|
||||
}
|
||||
|
||||
func (v *Connection) SysFd() (int, error) {
|
||||
|
@ -3,6 +3,7 @@ package tcp
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
|
||||
"v2ray.com/core/common/errors"
|
||||
"v2ray.com/core/common/log"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
@ -28,7 +29,7 @@ func Dial(src v2net.Address, dest v2net.Destination, options internet.DialerOpti
|
||||
|
||||
id := internal.NewConnectionId(src, dest)
|
||||
var conn net.Conn
|
||||
if dest.Network == v2net.Network_TCP && tcpSettings.ConnectionReuse.IsEnabled() {
|
||||
if dest.Network == v2net.Network_TCP && tcpSettings.IsConnectionReuse() {
|
||||
conn = globalCache.Get(id)
|
||||
}
|
||||
if conn == nil {
|
||||
|
@ -5,11 +5,11 @@ import (
|
||||
"v2ray.com/core/transport/internet"
|
||||
)
|
||||
|
||||
func (v *ConnectionReuse) IsEnabled() bool {
|
||||
if v == nil {
|
||||
func (c *Config) IsConnectionReuse() bool {
|
||||
if c == nil || c.ConnectionReuse == nil {
|
||||
return false
|
||||
}
|
||||
return v.Enable
|
||||
return c.ConnectionReuse.Enable
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -29,7 +29,7 @@ func NewConnection(dest string, conn *wsconn, manager ConnectionManager, config
|
||||
dest: dest,
|
||||
conn: conn,
|
||||
listener: manager,
|
||||
reusable: config.ConnectionReuse.IsEnabled(),
|
||||
reusable: config.IsConnectionReuse(),
|
||||
config: config,
|
||||
}
|
||||
}
|
||||
@ -83,14 +83,11 @@ func (v *Connection) SetWriteDeadline(t time.Time) error {
|
||||
}
|
||||
|
||||
func (v *Connection) SetReusable(reusable bool) {
|
||||
if !v.config.ConnectionReuse.IsEnabled() {
|
||||
return
|
||||
}
|
||||
v.reusable = reusable
|
||||
}
|
||||
|
||||
func (v *Connection) Reusable() bool {
|
||||
return v.reusable
|
||||
return v.config.IsConnectionReuse() && v.reusable
|
||||
}
|
||||
|
||||
func (v *Connection) SysFd() (int, error) {
|
||||
|
@ -28,7 +28,7 @@ func Dial(src v2net.Address, dest v2net.Destination, options internet.DialerOpti
|
||||
|
||||
id := src.String() + "-" + dest.NetAddr()
|
||||
var conn *wsconn
|
||||
if dest.Network == v2net.Network_TCP && wsSettings.ConnectionReuse.IsEnabled() {
|
||||
if dest.Network == v2net.Network_TCP && wsSettings.IsConnectionReuse() {
|
||||
connt := globalCache.Get(id)
|
||||
if connt != nil {
|
||||
conn = connt.(*wsconn)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*Package ws implements Websocket transport
|
||||
/*Package websocket implements Websocket transport
|
||||
|
||||
Websocket transport implements a HTTP(S) compliable, surveillance proof transport method with plausible deniability.
|
||||
|
||||
|
@ -159,13 +159,10 @@ func (ws *wsconn) setup() {
|
||||
}
|
||||
|
||||
func (ws *wsconn) Reusable() bool {
|
||||
return ws.reusable && !ws.connClosing
|
||||
return ws.config.IsConnectionReuse() && ws.reusable && !ws.connClosing
|
||||
}
|
||||
|
||||
func (ws *wsconn) SetReusable(reusable bool) {
|
||||
if !ws.config.ConnectionReuse.IsEnabled() {
|
||||
return
|
||||
}
|
||||
ws.reusable = reusable
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user