风扇滑翔翼andArtem Lytkin authored and GitHub committed 2026-09-27 23:39:21 +00:00
1 parent 7780db9bbe
commit e5e85ca9da
3 files changed
+61 -4

No files matched your search

+29 -4
View File
@@ -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 {
+17
View File
@@ -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()
})