Conflate default ports

This commit is contained in:
Viktor Liu
2026-02-09 00:57:08 +08:00
parent 3630ebb3ae
commit 2f390e1794
3 changed files with 150 additions and 2 deletions

View File

@@ -213,7 +213,7 @@ func (r *ReverseProxy) ToProtoMapping(operation Operation, authToken string, oid
Host: target.Host,
Path: path,
}
if target.Port > 0 {
if target.Port > 0 && !isDefaultPort(target.Protocol, target.Port) {
targetURL.Host = net.JoinHostPort(targetURL.Host, strconv.Itoa(target.Port))
}
@@ -267,6 +267,12 @@ func operationToProtoType(op Operation) proto.ProxyMappingUpdateType {
}
}
// isDefaultPort reports whether port is the standard default for the given scheme
// (443 for https, 80 for http).
func isDefaultPort(scheme string, port int) bool {
return (scheme == "https" && port == 443) || (scheme == "http" && port == 80)
}
func (r *ReverseProxy) FromAPIRequest(req *api.ReverseProxyRequest, accountID string) {
r.Name = req.Name
r.Domain = req.Domain