[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [meek/master] Put timeouts on helper interaction.



commit 2d766407d82ee4ff9329041dc803301a5adace1c
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Tue Mar 18 11:04:47 2014 -0700

    Put timeouts on helper interaction.
---
 meek-client/meek-client.go |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meek-client/meek-client.go b/meek-client/meek-client.go
index 1f64d9e..930b123 100644
--- a/meek-client/meek-client.go
+++ b/meek-client/meek-client.go
@@ -30,6 +30,8 @@ const initPollInterval = 100 * time.Millisecond
 const maxPollInterval = 5 * time.Second
 const pollIntervalMultiplier = 1.5
 const maxHelperResponseLength = 10000000
+const helperReadTimeout = 60 * time.Second
+const helperWriteTimeout = 2 * time.Second
 
 var ptInfo pt.ClientInfo
 
@@ -119,6 +121,7 @@ func roundTripWithHelper(buf []byte, info *RequestInfo) (*http.Response, error)
 	// log.Printf("encoded %s", encReq)
 
 	// Send the request.
+	s.SetWriteDeadline(time.Now().Add(helperWriteTimeout))
 	err = binary.Write(s, binary.BigEndian, uint32(len(encReq)))
 	if err != nil {
 		return nil, err
@@ -130,6 +133,7 @@ func roundTripWithHelper(buf []byte, info *RequestInfo) (*http.Response, error)
 
 	// Read the response.
 	var length uint32
+	s.SetReadDeadline(time.Now().Add(helperReadTimeout))
 	err = binary.Read(s, binary.BigEndian, &length)
 	if err != nil {
 		return nil, err



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits