Просмотр исходного кода

Ensure passthrough is not interrupted by a pre-existing deadline

mirokuratczyk 2 лет назад
Родитель
Сommit
66a520ce7e
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      psiphon/common/transforms/httpNormalizer.go

+ 6 - 1
psiphon/common/transforms/httpNormalizer.go

@@ -575,10 +575,16 @@ func passthrough(conn net.Conn, address string, dialer func(network, address str
 
 
 	defer conn.Close()
 	defer conn.Close()
 
 
+	// Remove any pre-existing deadlines to ensure the passthrough
+	// is not interrupted.
+	_ = conn.SetDeadline(time.Time{})
+
 	passthroughConn, err := dialer("tcp", address)
 	passthroughConn, err := dialer("tcp", address)
 	if err != nil {
 	if err != nil {
 		return
 		return
 	}
 	}
+	defer passthroughConn.Close()
+
 	_, err = passthroughConn.Write(buf)
 	_, err = passthroughConn.Write(buf)
 	if err != nil {
 	if err != nil {
 		return
 		return
@@ -588,7 +594,6 @@ func passthrough(conn net.Conn, address string, dialer func(network, address str
 		_, _ = io.Copy(passthroughConn, conn)
 		_, _ = io.Copy(passthroughConn, conn)
 		passthroughConn.Close()
 		passthroughConn.Close()
 	}()
 	}()
-
 	_, _ = io.Copy(conn, passthroughConn)
 	_, _ = io.Copy(conn, passthroughConn)
 }
 }