mirror of
https://github.com/XTLS/REALITY.git
synced 2025-08-29 18:05:32 +00:00
Apply target's time-out to hs.readClientFinished()
This commit is contained in:
parent
6288e760a9
commit
a7ae8b57f1
@ -131,6 +131,8 @@ func (hs *serverHandshakeStateTLS13) handshake() error {
|
||||
if _, err := c.flush(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
if err := hs.readClientCertificate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
28
tls.go
28
tls.go
@ -32,6 +32,7 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/pires/go-proxyproto"
|
||||
@ -354,13 +355,36 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) {
|
||||
s2cSaved = s2cSaved[handshakeLen:]
|
||||
handshakeLen = 0
|
||||
}
|
||||
start := time.Now()
|
||||
err = hs.handshake()
|
||||
if config.Show {
|
||||
fmt.Printf("REALITY remoteAddr: %v\ths.handshake() err: %v\n", remoteAddr, err)
|
||||
}
|
||||
if err == nil {
|
||||
handled = true
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
go func() { // TODO: Probe target's maxUselessRecords and some time-outs in advance.
|
||||
if handshakeLen-len(s2cSaved) > 0 {
|
||||
io.ReadFull(target, buf[:handshakeLen-len(s2cSaved)])
|
||||
}
|
||||
if n, err := target.Read(buf); !hs.c.handshakeComplete() {
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
}
|
||||
if config.Show {
|
||||
fmt.Printf("REALITY remoteAddr: %v\ttime.Since(start): %v\tn: %v\terr: %v\n", remoteAddr, time.Since(start), n, err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
err = hs.readClientFinished()
|
||||
if config.Show {
|
||||
fmt.Printf("REALITY remoteAddr: %v\ths.readClientFinished() err: %v\n", remoteAddr, err)
|
||||
}
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
atomic.StoreUint32(&hs.c.handshakeStatus, 1)
|
||||
handled = true
|
||||
break
|
||||
}
|
||||
if done {
|
||||
|
Loading…
Reference in New Issue
Block a user