From a402c4f3269daf2f9baed5a2226b9716dd513db8 Mon Sep 17 00:00:00 2001 From: adoolaard Date: Thu, 30 Jan 2025 22:22:42 +0100 Subject: [PATCH] Tags are working, just not yet editable --- src/mod/dynamicproxy/typedef.go | 1 + src/reverseproxy.go | 15 +++++++++++++++ src/web/components/httprp.html | 4 ++++ src/web/components/rules.html | 7 +++++++ 4 files changed, 27 insertions(+) diff --git a/src/mod/dynamicproxy/typedef.go b/src/mod/dynamicproxy/typedef.go index c7a060d..2919a7e 100644 --- a/src/mod/dynamicproxy/typedef.go +++ b/src/mod/dynamicproxy/typedef.go @@ -194,6 +194,7 @@ type ProxyEndpoint struct { //Internal Logic Elements parent *Router `json:"-"` + Tags []string // Tags for the proxy endpoint } /* diff --git a/src/reverseproxy.go b/src/reverseproxy.go index c55b6db..ced72f5 100644 --- a/src/reverseproxy.go +++ b/src/reverseproxy.go @@ -287,6 +287,12 @@ func ReverseProxyHandleAddEndpoint(w http.ResponseWriter, r *http.Request) { } } + tagsStr, _ := utils.PostPara(r, "tags") + tags := strings.Split(tagsStr, ",") + for i := range tags { + tags[i] = strings.TrimSpace(tags[i]) + } + var proxyEndpointCreated *dynamicproxy.ProxyEndpoint if eptype == "host" { rootOrMatchingDomain, err := utils.PostPara(r, "rootname") @@ -357,6 +363,8 @@ func ReverseProxyHandleAddEndpoint(w http.ResponseWriter, r *http.Request) { // Rate Limit RequireRateLimit: requireRateLimit, RateLimit: int64(proxyRateLimit), + + Tags: tags, } preparedEndpoint, err := dynamicProxyRouter.PrepareProxyRoute(&thisProxyEndpoint) @@ -515,6 +523,12 @@ func ReverseProxyHandleEditEndpoint(w http.ResponseWriter, r *http.Request) { return } + tagsStr, _ := utils.PostPara(r, "tags") + tags := strings.Split(tagsStr, ",") + for i := range tags { + tags[i] = strings.TrimSpace(tags[i]) + } + //Generate a new proxyEndpoint from the new config newProxyEndpoint := dynamicproxy.CopyEndpoint(targetProxyEntry) newProxyEndpoint.BypassGlobalTLS = bypassGlobalTLS @@ -539,6 +553,7 @@ func ReverseProxyHandleEditEndpoint(w http.ResponseWriter, r *http.Request) { newProxyEndpoint.RateLimit = proxyRateLimit newProxyEndpoint.UseStickySession = useStickySession newProxyEndpoint.DisableUptimeMonitor = disbleUtm + newProxyEndpoint.Tags = tags //Prepare to replace the current routing rule readyRoutingRule, err := dynamicProxyRouter.PrepareProxyRoute(newProxyEndpoint) diff --git a/src/web/components/httprp.html b/src/web/components/httprp.html index 8ecd402..1464e38 100644 --- a/src/web/components/httprp.html +++ b/src/web/components/httprp.html @@ -19,6 +19,7 @@ Host Destination Virtual Directory + Tags Advanced Settings Actions @@ -124,6 +125,7 @@ ${vdList} + ${subd.Tags.join(", ")} ${subd.AuthenticationProvider.AuthMethod == 0x1?` Basic Auth`:``} ${subd.AuthenticationProvider.AuthMethod == 0x2?` Authelia`:``} @@ -457,6 +459,7 @@ let requireRateLimit = $(row).find(".RequireRateLimit")[0].checked; let rateLimit = $(row).find(".RateLimit").val(); let bypassGlobalTLS = $(row).find(".BypassGlobalTLS")[0].checked; + let tags = $("#proxyTags").val().trim(); $.cjax({ url: "/api/proxy/edit", @@ -470,6 +473,7 @@ "authprovider" :authProviderType, "rate" :requireRateLimit, "ratenum" :rateLimit, + "tags": tags, }, success: function(data){ if (data.error !== undefined){ diff --git a/src/web/components/rules.html b/src/web/components/rules.html index f6df6ce..dd37efd 100644 --- a/src/web/components/rules.html +++ b/src/web/components/rules.html @@ -63,6 +63,11 @@ +
+ + + Comma-separated list of tags for this proxy host. +
Security @@ -198,6 +203,7 @@ let skipWebSocketOriginCheck = $("#skipWebsocketOriginCheck")[0].checked; let accessRuleToUse = $("#newProxyRuleAccessFilter").val(); let useStickySessionLB = $("#useStickySessionLB")[0].checked; + let tags = $("#proxyTags").val().trim(); if (rootname.trim() == ""){ $("#rootname").parent().addClass("error"); @@ -231,6 +237,7 @@ cred: JSON.stringify(credentials), access: accessRuleToUse, stickysess: useStickySessionLB, + tags: tags, }, success: function(data){ if (data.error != undefined){