1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

refine proto settings

This commit is contained in:
Darien Raymond 2017-01-01 21:19:12 +01:00
parent 2a52ae9e96
commit 58ae7e4967
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
8 changed files with 15 additions and 20 deletions

View File

@ -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() {

View File

@ -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) {

View File

@ -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 {

View File

@ -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() {

View File

@ -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) {

View File

@ -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)

View File

@ -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.

View File

@ -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
}