Fix Ctrl-C handling
This commit is contained in:
@@ -3,7 +3,6 @@ package deconnector
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -16,7 +15,9 @@ func (d *Deconnector) handleDeconnect(clientConn net.Conn, connectReq *http.Requ
|
||||
// Read the real HTTP request the client sends through the tunnel
|
||||
innerReq, err := http.ReadRequest(bufio.NewReader(clientConn))
|
||||
if err != nil {
|
||||
log.Printf("failed to read inner request after CONNECT:80: %v", err)
|
||||
d.app.Logger().WithError(err).
|
||||
Error("Failed to read inner request after CONNECT:80")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@ import "errors"
|
||||
|
||||
var (
|
||||
ErrDeconnector = errors.New("deconnector")
|
||||
ErrConnectDependencies = errors.New("failed to connect dependencies")
|
||||
ErrConnectDependencies = errors.New("function ConnectDependencies()")
|
||||
)
|
||||
|
||||
@@ -32,5 +32,6 @@ func (d *Deconnector) forwardHTTP(clientConn net.Conn, req *http.Request, upstre
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
resp.Write(clientConn)
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ func (d *Deconnector) Handle(clientConn net.Conn) {
|
||||
if req.URL.Host == "" {
|
||||
req.URL.Host = req.Host
|
||||
}
|
||||
|
||||
req.URL.Scheme = "http"
|
||||
d.app.Logger().
|
||||
WithField("method", req.Method).
|
||||
|
||||
@@ -37,7 +37,9 @@ func (d *Deconnector) handleTunnel(clientConn net.Conn, host string, upstreamURL
|
||||
fmt.Fprintf(clientConn, "HTTP/1.1 200 Connection established\r\n\r\n")
|
||||
|
||||
done := make(chan struct{}, 2)
|
||||
|
||||
go func() { io.Copy(upstreamConn, clientConn); done <- struct{}{} }()
|
||||
go func() { io.Copy(clientConn, upstreamConn); done <- struct{}{} }()
|
||||
|
||||
<-done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user