1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00

try fix connection reuse settings

This commit is contained in:
Darien Raymond 2016-12-12 13:08:31 +01:00
parent f159d504f2
commit a67d525fc2
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
4 changed files with 5 additions and 8 deletions

View File

@ -30,7 +30,7 @@ func TestRequestSerialization(t *testing.T) {
Version: 1,
User: user,
Command: protocol.RequestCommandTCP,
Option: protocol.RequestOption(0),
Option: protocol.RequestOptionConnectionReuse,
Address: v2net.DomainAddress("www.v2ray.com"),
Port: v2net.Port(443),
Security: protocol.Security(protocol.SecurityType_AES128_GCM),

View File

@ -153,6 +153,8 @@ func (v *VMessInboundHandler) HandleConnection(connection internet.Connection) {
request, err := session.DecodeRequestHeader(reader)
v.RUnlock()
connection.SetReusable(request.Option.Has(protocol.RequestOptionConnectionReuse))
if err != nil {
if errors.Cause(err) != io.EOF {
log.Access(connection.RemoteAddr(), "", log.AccessRejected, err)

View File

@ -138,9 +138,7 @@ func (v *VMessOutboundHandler) handleResponse(session *encoding.ClientSession, c
}
go v.handleCommand(dest, header.Command)
if !header.Option.Has(protocol.ResponseOptionConnectionReuse) {
conn.SetReusable(false)
}
conn.SetReusable(header.Option.Has(protocol.ResponseOptionConnectionReuse))
reader.SetCached(false)
bodyReader := session.DecodeResponseBody(request, reader)

View File

@ -93,14 +93,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.ConnectionReuse.IsEnabled() && v.reusable
}
func (v *Connection) SysFd() (int, error) {