Skip to content

Commit

Permalink
Fix HTTP proxy handler
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Sep 26, 2023
1 parent 7127eed commit 4c63acf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion x/httpproxy/connect_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
package httpproxy

import (
"context"
"fmt"
"io"
"net"
"net/http"
"strings"

"github.com/Jigsaw-Code/outline-sdk/transport"
)
Expand Down Expand Up @@ -124,5 +127,11 @@ func (h *handler) handleConnect(proxyResp http.ResponseWriter, proxyReq *http.Re
// The resulting handler is currently vulnerable to probing attacks. It's ok as a localhost proxy
// but it may be vulnerable if used as a public proxy.
func NewConnectHandler(dialer transport.StreamDialer) http.Handler {
return &handler{dialer, *http.DefaultClient}
dialContext := func(ctx context.Context, network, addr string) (net.Conn, error) {
if !strings.HasPrefix(network, "tcp") {
return nil, fmt.Errorf("protocol not supported: %v", network)
}
return dialer.Dial(ctx, addr)
}
return &handler{dialer, http.Client{Transport: &http.Transport{DialContext: dialContext}}}
}

0 comments on commit 4c63acf

Please sign in to comment.