XTLS Vision: Suppress outer CloseNotify after switching to direct copy (#6834)
https://github.com/XTLS/Xray-core/pull/6816#issuecomment-5828082031 https://github.com/XTLS/Xray-core/issues/6794#issuecomment-5847200576 https://github.com/XTLS/Xray-core/pull/6834#issuecomment-5860728689 Fixes https://github.com/XTLS/Xray-core/issues/6794#issuecomment-5754894283 Fixes https://github.com/XTLS/Xray-core/issues/6124#issuecomment-4439918073 Fixes https://github.com/XTLS/Xray-core/issues/4878#issuecomment-5754638401 --------- Co-authored-by: Artem Lytkin <146867384+4RH1T3CT0R7@users.noreply.github.com>
This commit is contained in:
1 parent
7780db9bbe
commit
e5e85ca9da
3 files changed
+61
-4
No files matched your search
@@ -18,6 +18,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
@@ -36,6 +37,18 @@ import (
|
||||
|
||||
type Conn struct {
|
||||
*reality.Conn
|
||||
suppressCloseNotify atomic.Bool
|
||||
}
|
||||
|
||||
func (c *Conn) SuppressCloseNotify() {
|
||||
c.suppressCloseNotify.Store(true)
|
||||
}
|
||||
|
||||
func (c *Conn) Close() error {
|
||||
if c.suppressCloseNotify.Load() {
|
||||
return c.Conn.NetConn().Close()
|
||||
}
|
||||
return c.Conn.Close()
|
||||
}
|
||||
|
||||
func (c *Conn) HandshakeAddress() net.Address {
|
||||
@@ -56,10 +69,22 @@ func Server(c net.Conn, config *reality.Config) (net.Conn, error) {
|
||||
|
||||
type UConn struct {
|
||||
*utls.UConn
|
||||
Config *Config
|
||||
ServerName string
|
||||
AuthKey []byte
|
||||
Verified bool
|
||||
Config *Config
|
||||
ServerName string
|
||||
AuthKey []byte
|
||||
Verified bool
|
||||
suppressCloseNotify atomic.Bool
|
||||
}
|
||||
|
||||
func (c *UConn) SuppressCloseNotify() {
|
||||
c.suppressCloseNotify.Store(true)
|
||||
}
|
||||
|
||||
func (c *UConn) Close() error {
|
||||
if c.suppressCloseNotify.Load() {
|
||||
return c.NetConn().Close()
|
||||
}
|
||||
return c.UConn.Close()
|
||||
}
|
||||
|
||||
func (c *UConn) HandshakeAddress() net.Address {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/tls"
|
||||
"math/big"
|
||||
"slices"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
utls "github.com/refraction-networking/utls"
|
||||
@@ -29,11 +30,19 @@ var (
|
||||
|
||||
type Conn struct {
|
||||
*tls.Conn
|
||||
suppressCloseNotify atomic.Bool
|
||||
}
|
||||
|
||||
const tlsCloseTimeout = 250 * time.Millisecond
|
||||
|
||||
func (c *Conn) SuppressCloseNotify() {
|
||||
c.suppressCloseNotify.Store(true)
|
||||
}
|
||||
|
||||
func (c *Conn) Close() error {
|
||||
if c.suppressCloseNotify.Load() {
|
||||
return c.Conn.NetConn().Close()
|
||||
}
|
||||
timer := time.AfterFunc(tlsCloseTimeout, func() {
|
||||
c.Conn.NetConn().Close()
|
||||
})
|
||||
@@ -74,11 +83,19 @@ func Server(c net.Conn, config *tls.Config) net.Conn {
|
||||
|
||||
type UConn struct {
|
||||
*utls.UConn
|
||||
suppressCloseNotify atomic.Bool
|
||||
}
|
||||
|
||||
var _ Interface = (*UConn)(nil)
|
||||
|
||||
func (c *UConn) SuppressCloseNotify() {
|
||||
c.suppressCloseNotify.Store(true)
|
||||
}
|
||||
|
||||
func (c *UConn) Close() error {
|
||||
if c.suppressCloseNotify.Load() {
|
||||
return c.Conn.NetConn().Close()
|
||||
}
|
||||
timer := time.AfterFunc(tlsCloseTimeout, func() {
|
||||
c.Conn.NetConn().Close()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user