mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
fix TCP conn reuse with tls
This commit is contained in:
parent
ac3b91a877
commit
72339a3509
@ -36,20 +36,20 @@ func Dial(src v2net.Address, dest v2net.Destination, options internet.DialerOpti
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
if options.Stream != nil && options.Stream.HasSecuritySettings() {
|
||||||
if options.Stream != nil && options.Stream.HasSecuritySettings() {
|
securitySettings, err := options.Stream.GetEffectiveSecuritySettings()
|
||||||
securitySettings, err := options.Stream.GetEffectiveSecuritySettings()
|
if err != nil {
|
||||||
if err != nil {
|
log.Error("TCP: Failed to get security settings: ", err)
|
||||||
log.Error("TCP: Failed to get security settings: ", err)
|
return nil, err
|
||||||
return nil, err
|
}
|
||||||
}
|
tlsConfig, ok := securitySettings.(*v2tls.Config)
|
||||||
tlsConfig, ok := securitySettings.(*v2tls.Config)
|
if ok {
|
||||||
if ok {
|
config := tlsConfig.GetTLSConfig()
|
||||||
config := tlsConfig.GetTLSConfig()
|
if dest.Address.Family().IsDomain() {
|
||||||
if dest.Address.Family().IsDomain() {
|
config.ServerName = dest.Address.Domain()
|
||||||
config.ServerName = dest.Address.Domain()
|
}
|
||||||
|
conn = tls.Client(conn, config)
|
||||||
}
|
}
|
||||||
conn = tls.Client(conn, config)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NewConnection(id, conn, globalCache, tcpSettings), nil
|
return NewConnection(id, conn, globalCache, tcpSettings), nil
|
||||||
|
@ -77,9 +77,6 @@ func (this *TCPListener) Accept() (internet.Connection, error) {
|
|||||||
return nil, connErr.err
|
return nil, connErr.err
|
||||||
}
|
}
|
||||||
conn := connErr.conn
|
conn := connErr.conn
|
||||||
if this.tlsConfig != nil {
|
|
||||||
conn = tls.Server(conn, this.tlsConfig)
|
|
||||||
}
|
|
||||||
return NewConnection("", conn, this, this.config), nil
|
return NewConnection("", conn, this, this.config), nil
|
||||||
case <-time.After(time.Second * 2):
|
case <-time.After(time.Second * 2):
|
||||||
}
|
}
|
||||||
@ -95,6 +92,9 @@ func (this *TCPListener) KeepAccepting() {
|
|||||||
this.Unlock()
|
this.Unlock()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if this.tlsConfig != nil {
|
||||||
|
conn = tls.Server(conn, this.tlsConfig)
|
||||||
|
}
|
||||||
select {
|
select {
|
||||||
case this.awaitingConns <- &ConnectionWithError{
|
case this.awaitingConns <- &ConnectionWithError{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
|
Loading…
Reference in New Issue
Block a user