feat: add validation for localhost routes to prevent usage of godoxy port causing self recursion

This commit is contained in:
yusing
2025-03-29 02:53:41 +08:00
parent a9e4f82e30
commit c8935102c3
3 changed files with 19 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package middleware
import (
"net"
"net/http"
"strconv"
"strings"
"github.com/yusing/go-proxy/internal/common"
@@ -38,8 +39,8 @@ func (m *redirectHTTP) before(w http.ResponseWriter, r *http.Request) (proceed b
host = r.Host
}
if common.ProxyHTTPSPort != "443" {
r.URL.Host = host + ":" + common.ProxyHTTPSPort
if common.ProxyHTTPSPort != 443 {
r.URL.Host = host + ":" + strconv.Itoa(common.ProxyHTTPSPort)
} else {
r.URL.Host = host
}