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 {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if options.Stream != nil && options.Stream.HasSecuritySettings() {
|
||||
securitySettings, err := options.Stream.GetEffectiveSecuritySettings()
|
||||
if err != nil {
|
||||
log.Error("TCP: Failed to get security settings: ", err)
|
||||
return nil, err
|
||||
}
|
||||
tlsConfig, ok := securitySettings.(*v2tls.Config)
|
||||
if ok {
|
||||
config := tlsConfig.GetTLSConfig()
|
||||
if dest.Address.Family().IsDomain() {
|
||||
config.ServerName = dest.Address.Domain()
|
||||
if options.Stream != nil && options.Stream.HasSecuritySettings() {
|
||||
securitySettings, err := options.Stream.GetEffectiveSecuritySettings()
|
||||
if err != nil {
|
||||
log.Error("TCP: Failed to get security settings: ", err)
|
||||
return nil, err
|
||||
}
|
||||
tlsConfig, ok := securitySettings.(*v2tls.Config)
|
||||
if ok {
|
||||
config := tlsConfig.GetTLSConfig()
|
||||
if dest.Address.Family().IsDomain() {
|
||||
config.ServerName = dest.Address.Domain()
|
||||
}
|
||||
conn = tls.Client(conn, config)
|
||||
}
|
||||
conn = tls.Client(conn, config)
|
||||
}
|
||||
}
|
||||
return NewConnection(id, conn, globalCache, tcpSettings), nil
|
||||
|
@ -77,9 +77,6 @@ func (this *TCPListener) Accept() (internet.Connection, error) {
|
||||
return nil, connErr.err
|
||||
}
|
||||
conn := connErr.conn
|
||||
if this.tlsConfig != nil {
|
||||
conn = tls.Server(conn, this.tlsConfig)
|
||||
}
|
||||
return NewConnection("", conn, this, this.config), nil
|
||||
case <-time.After(time.Second * 2):
|
||||
}
|
||||
@ -95,6 +92,9 @@ func (this *TCPListener) KeepAccepting() {
|
||||
this.Unlock()
|
||||
break
|
||||
}
|
||||
if this.tlsConfig != nil {
|
||||
conn = tls.Server(conn, this.tlsConfig)
|
||||
}
|
||||
select {
|
||||
case this.awaitingConns <- &ConnectionWithError{
|
||||
conn: conn,
|
||||
|
Loading…
Reference in New Issue
Block a user