fix proxying
This commit is contained in:
parent
d9230a4d63
commit
af6ce456f9
19
request.go
19
request.go
@ -154,17 +154,18 @@ func (s *Server) handleConnect(ctx context.Context, writer io.Writer, request *R
|
||||
}
|
||||
|
||||
// Start proxying
|
||||
eCh1 := make(chan error, 1)
|
||||
eCh2 := make(chan error, 1)
|
||||
|
||||
s.submit(func() { eCh1 <- s.Proxy(target, request.Reader) })
|
||||
s.submit(func() { eCh2 <- s.Proxy(writer, target) })
|
||||
errCh := make(chan error, 2)
|
||||
s.submit(func() { errCh <- s.Proxy(target, request.Reader) })
|
||||
s.submit(func() { errCh <- s.Proxy(writer, target) })
|
||||
// Wait
|
||||
select {
|
||||
case err = <-eCh1:
|
||||
case err = <-eCh2:
|
||||
for i := 0; i < 2; i++ {
|
||||
e := <-errCh
|
||||
if e != nil {
|
||||
// return from this function closes target (and conn).
|
||||
return e
|
||||
}
|
||||
}
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
// handleBind is used to handle a connect command
|
||||
|
Loading…
Reference in New Issue
Block a user