1
0
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:
Darien Raymond 2016-11-01 00:41:46 +01:00
parent ac3b91a877
commit 72339a3509
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 16 additions and 16 deletions

View File

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

View File

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