chore: bump Go dependencies

This commit is contained in:
lzap 2025-08-03 15:24:15 +00:00 committed by Simon de Vlieger
parent b3d1e4cf13
commit e118df5dfd
1119 changed files with 126580 additions and 8706 deletions

View file

@ -5,6 +5,7 @@ package middleware
import (
"context"
"crypto/tls"
"fmt"
"io"
"math/rand"
@ -130,7 +131,21 @@ var DefaultProxyConfig = ProxyConfig{
ContextKey: "target",
}
func proxyRaw(t *ProxyTarget, c echo.Context) http.Handler {
func proxyRaw(t *ProxyTarget, c echo.Context, config ProxyConfig) http.Handler {
var dialFunc func(ctx context.Context, network, addr string) (net.Conn, error)
if transport, ok := config.Transport.(*http.Transport); ok {
if transport.TLSClientConfig != nil {
d := tls.Dialer{
Config: transport.TLSClientConfig,
}
dialFunc = d.DialContext
}
}
if dialFunc == nil {
var d net.Dialer
dialFunc = d.DialContext
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
in, _, err := c.Response().Hijack()
if err != nil {
@ -138,13 +153,11 @@ func proxyRaw(t *ProxyTarget, c echo.Context) http.Handler {
return
}
defer in.Close()
out, err := net.Dial("tcp", t.URL.Host)
out, err := dialFunc(c.Request().Context(), "tcp", t.URL.Host)
if err != nil {
c.Set("_error", echo.NewHTTPError(http.StatusBadGateway, fmt.Sprintf("proxy raw, dial error=%v, url=%s", err, t.URL)))
return
}
defer out.Close()
// Write header
err = r.Write(out)
@ -365,7 +378,7 @@ func ProxyWithConfig(config ProxyConfig) echo.MiddlewareFunc {
// Proxy
switch {
case c.IsWebSocket():
proxyRaw(tgt, c).ServeHTTP(res, req)
proxyRaw(tgt, c, config).ServeHTTP(res, req)
default: // even SSE requests
proxyHTTP(tgt, c, config).ServeHTTP(res, req)
}