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 {
|
if _, err := c.flush(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
|
||||||
if err := hs.readClientCertificate(); err != nil {
|
if err := hs.readClientCertificate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
28
tls.go
28
tls.go
@ -32,6 +32,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pires/go-proxyproto"
|
"github.com/pires/go-proxyproto"
|
||||||
@ -354,13 +355,36 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) {
|
|||||||
s2cSaved = s2cSaved[handshakeLen:]
|
s2cSaved = s2cSaved[handshakeLen:]
|
||||||
handshakeLen = 0
|
handshakeLen = 0
|
||||||
}
|
}
|
||||||
|
start := time.Now()
|
||||||
err = hs.handshake()
|
err = hs.handshake()
|
||||||
if config.Show {
|
if config.Show {
|
||||||
fmt.Printf("REALITY remoteAddr: %v\ths.handshake() err: %v\n", remoteAddr, err)
|
fmt.Printf("REALITY remoteAddr: %v\ths.handshake() err: %v\n", remoteAddr, err)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err != nil {
|
||||||
handled = true
|
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
|
break
|
||||||
}
|
}
|
||||||
if done {
|
if done {
|
||||||
|
Loading…
Reference in New Issue
Block a user