Better function for getting reverse proxies

This commit is contained in:
lwcrosier 2025-12-08 21:32:12 -05:00
parent 46ce2f55d1
commit b3b505c3e0
1 changed files with 22 additions and 24 deletions

View File

@ -60,16 +60,7 @@ import ButtonTest from '../views/ButtonTest.vue';
const apps = this.caddyConfig.apps; const apps = this.caddyConfig.apps;
const routes = apps.http.servers.srv0.routes; const routes = apps.http.servers.srv0.routes;
//let reverse_proxy_array = [];
/*
for (let key in routes) {
}
*/
//console.log(routes);
//console.log("Filtering Caddy Config");
//findRps(routes);
let rp_dict = searchBaseRoutes(routes); let rp_dict = searchBaseRoutes(routes);
console.log(rp_dict); console.log(rp_dict);
} }
@ -87,14 +78,14 @@ import ButtonTest from '../views/ButtonTest.vue';
// So what we should do: break apart the routes into handlers and matches. First search the handlers to see if you find subroute or rp. // So what we should do: break apart the routes into handlers and matches. First search the handlers to see if you find subroute or rp.
// Then match the array of those upstreams with the match value // Then match the array of those upstreams with the match value
function findReverseProxies(routes) { function findReverseProxies(routes) {
let rpArray = []; let rpArray = [];
for(r_key in routes) { for(let r_key in routes) {
for (let h_key in routes[r_key].handles) { for (let h_key in routes[r_key].handle) {
if (routes[r_key].handles[h_key].handler === 'reverse_proxy') { if (routes[r_key].handle[h_key].handler === 'reverse_proxy') {
for (let u_key in routes[r_key].handles[h_key].upstreams) {
rpArray.push(routes[r_key].handles[h_key].upstreams[u_key].dial); for (let u_key in routes[r_key].handle[h_key].upstreams) {
rpArray.push(routes[r_key].handle[h_key].upstreams[u_key].dial);
} }
} }
} }
@ -104,19 +95,26 @@ import ButtonTest from '../views/ButtonTest.vue';
} }
function searchBaseRoutes(baseRoutes) { function searchBaseRoutes(baseRoutes) {
let handles = routes.handle;
let matches = routes.match; let rp_dict = {};
for (let r_key in baseRoutes) {
let handles = baseRoutes[r_key].handle;
let matches = baseRoutes[r_key].match;
let rp_servers = [];
for (let h_key in handles) { for (let h_key in handles) {
console.log(h_key); if (handles[h_key].handler === 'subroute') {
if (handles[h_key] === 'subroute') { rp_servers = findReverseProxies(handles[h_key].routes);
let rp_servers = findReverseProxies(handles[h_key].routes); }
} }
rp_dict[ matches[0].host ] = rp_servers;
} }
return handles; return rp_dict;
} }
</script> </script>