0
0
mirror of https://github.com/XTLS/REALITY.git synced 2025-08-23 06:58:39 +00:00

Use underlying for io.Copy() only

This commit is contained in:
RPRX 2023-02-26 07:26:56 +00:00 committed by GitHub
parent 14f5d5380b
commit f34b4d1743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

10
tls.go
View File

@ -194,7 +194,7 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) {
break break
} }
readerConn := &ReaderConn{ readerConn := &ReaderConn{
Conn: underlying, Conn: conn,
Reader: bytes.NewReader(c2sSaved), Reader: bytes.NewReader(c2sSaved),
} }
hs.c = &Conn{ hs.c = &Conn{
@ -247,15 +247,15 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) {
(config.MaxClientVer == nil || Value(hs.c.ClientVer[:]...) <= Value(config.MaxClientVer...)) && (config.MaxClientVer == nil || Value(hs.c.ClientVer[:]...) <= Value(config.MaxClientVer...)) &&
(config.MaxTimeDiff == 0 || time.Since(hs.c.ClientTime).Abs() <= config.MaxTimeDiff) && (config.MaxTimeDiff == 0 || time.Since(hs.c.ClientTime).Abs() <= config.MaxTimeDiff) &&
(config.ShortIds[hs.c.ClientShortId]) { (config.ShortIds[hs.c.ClientShortId]) {
hs.c.conn = underlying hs.c.conn = conn
} }
hs.clientHello.keyShares[0].group = CurveID(i) hs.clientHello.keyShares[0].group = CurveID(i)
break break
} }
if config.Show { if config.Show {
fmt.Printf("REALITY remoteAddr: %v\ths.c.conn == underlying: %v\n", remoteAddr, hs.c.conn == underlying) fmt.Printf("REALITY remoteAddr: %v\ths.c.conn == conn: %v\n", remoteAddr, hs.c.conn == conn)
} }
if hs.c.conn == underlying { if hs.c.conn == conn {
done = true done = true
} }
break break
@ -288,7 +288,7 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) {
} }
mutex.Lock() mutex.Lock()
s2cSaved = append(s2cSaved, buf[:n]...) s2cSaved = append(s2cSaved, buf[:n]...)
if hs.c == nil || hs.c.conn != underlying { if hs.c == nil || hs.c.conn != conn {
if _, err = conn.Write(buf[:n]); err != nil { if _, err = conn.Write(buf[:n]); err != nil {
done = true done = true
break break