兼容tls1.2握手
增加稳定性
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user