Skip to content

Commit baba10c

Browse files
author
Jianjun Mao
committed
set deadline
1 parent 6c2d0c0 commit baba10c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,16 @@ func (self *Server) Connect(w http.ResponseWriter, r *http.Request) {
157157

158158
// Proxy is no need to know anything, just exchange data between the client
159159
// the the remote server.
160-
copyAndWait := func(dst io.Writer, src io.Reader, c chan int64) {
160+
copyAndWait := func(dst, src net.Conn, c chan int64) {
161161
n, err := io.Copy(dst, src)
162162
if err != nil {
163163
L.Printf("Copy: %s\n", err.Error())
164164
// FIXME: how to report error to dst ?
165165
}
166+
// src is closed, should close dst, also set src write deadline
167+
t := time.Now().Add(10 * time.Second)
168+
dst.SetDeadline(t)
169+
src.SetDeadline(t)
166170
c <- n
167171
}
168172

0 commit comments

Comments
 (0)