兼容tls1.2握手

增加稳定性
This commit is contained in:
wenyifan
2022-09-01 17:23:45 +08:00
parent 7213e64b89
commit 0b338de152
5 changed files with 50 additions and 120 deletions

View File

@ -49,12 +49,11 @@ func handler(conn net.Conn, targetAddress string, fakeAddress string) {
fmt.Printf("[Server] Dial fake error : %v\n", err)
return
}
waitCh := make(chan int, 2)
waitCh := make(chan int, 1)
go processHandshake(conn, fakeConn, waitCh)
go processHandshake(fakeConn, conn, waitCh)
<-waitCh
<-waitCh
//Process real tcp connection
@ -83,8 +82,16 @@ func processHandshake(src net.Conn, dst net.Conn, waitCh chan int) {
header := ParseAndVerifyTLSHeader(buf[0:nr])
nw, ew := dst.Write(buf[0:nr])
if header != nil && header.Type == ChangeCipherSpec {
//fmt.Println(header.toString())
fmt.Println("[Server] handshake complete")
dst.Close()
if header.ChangeCipherSpecNext == AppData {
dst.Close()
waitCh <- 1
} else {
src.Close()
waitCh <- 1
return
}
break
}
if nw < 0 || nr < nw {