Skip to content

Commit

Permalink
fix proxy when http
Browse files Browse the repository at this point in the history
  • Loading branch information
lqqyt2423 committed May 27, 2024
1 parent 5f4ec97 commit 8f97773
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions proxy/attacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ func (a *attacker) ServeHTTP(res http.ResponseWriter, req *http.Request) {
func (a *attacker) initHttpDialFn(req *http.Request) {
connCtx := req.Context().Value(connContextKey).(*ConnContext)
connCtx.dialFn = func(ctx context.Context) error {
// todo: proxy
addr := helper.CanonicalAddr(req.URL)
c, err := (&net.Dialer{}).DialContext(ctx, "tcp", addr)
c, err := a.proxy.getUpstreamConn(ctx, req)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ func (proxy *Proxy) getUpstreamConn(ctx context.Context, req *http.Request) (net
return nil, err
}
var conn net.Conn
address := helper.CanonicalAddr(req.URL)
if proxyUrl != nil {
conn, err = helper.GetProxyConn(ctx, proxyUrl, req.Host, proxy.Opts.SslInsecure)
conn, err = helper.GetProxyConn(ctx, proxyUrl, address, proxy.Opts.SslInsecure)
} else {
conn, err = (&net.Dialer{}).DialContext(ctx, "tcp", req.Host)
conn, err = (&net.Dialer{}).DialContext(ctx, "tcp", address)
}
return conn, err
}

0 comments on commit 8f97773

Please sign in to comment.