From 46ce2f55d114135a55ab45eefea8d3dc41b58d55 Mon Sep 17 00:00:00 2001 From: lwcrosier Date: Mon, 8 Dec 2025 21:15:23 -0500 Subject: [PATCH] Still working to update finding reverse proxies --- src/views/HomeView.vue | 94 ++---------------------------------------- 1 file changed, 3 insertions(+), 91 deletions(-) diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 32aeca2..48fa1ef 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -70,7 +70,7 @@ import ButtonTest from '../views/ButtonTest.vue'; //console.log(routes); //console.log("Filtering Caddy Config"); //findRps(routes); - let rp_dict = findRPRecursively(routes); + let rp_dict = searchBaseRoutes(routes); console.log(rp_dict); } @@ -80,97 +80,8 @@ import ButtonTest from '../views/ButtonTest.vue'; } } - function findRps(routes) { - console.log ("Searching for reverse_proxy"); - // We're interested in routes and handlers. We specifically want subroutes and reverse_proxy handler - // routes are lists of handles - // handles are lists of routes - // subroute handler will have a routes list of more handles - - let rpDictionary = {}; - - for(let r_key in routes) { - // In each route, we'll look at the first layer of handles - // Actually, we need to find subroute, since subroute is what holds the reverse_proxy! - - // Then in each route, search for the match list to get the hosts (only if first layer reverse_proxy is found) - //let rp_found = false; - // Loop over handle list - var caddy_rp = null; - var caddy_hn = null; - - for(let h_key in routes[r_key].handle){ - // Check if the route.handle.handler == "subroute" - let rp_found = false; - if( routes[r_key].handle[h_key].handler === "subroute" ) { - console.log(routes[r_key].handle[h_key]); - for(let r2_key in routes[r_key].handle[h_key].routes) { - for(let h2_key in routes[r_key].handle[h_key].routes[r_key].handler){ - if ( routes[r_key].handle[h_key].routes[r_key].handle[h2_key].handler === "reverse_proxy") { - //let x = routes[r_key].handle[h_key].routes[r2_key].handle[h2_key].upstreams[0].dial; - caddy_rp = routes[r_key].handle[h_key].routes[r2_key].handle[h2_key].upstreams[0].dial; - //console.log("reverse proxy found. Address is: " + x); - rp_found = true; - } - if(rp_found === true){ - break; - } - } - if(rp_found === true){ - break; - } - } - } - - caddy_hn = routes[r_key].match[0].host[0]; - rpDictionary[caddy_hn] = caddy_rp; - console.log(`Hostname ${caddy_hn} will be proxied to ${caddy_rp}`); - //if(rp_found === true){ - // break; - //} - } - //console.log("rp hostname is " + routes[r_key].match[0].host[0]); - - //if (rp_found === true) { - // break; - //} - - } - - // We need to find the handle in all of these (most likely the base route at this point in time) - - // Search through the K-V pairs. Look for the 'Handle' key. This is a list - // Search this List for handler 'subroute' - // If it exists, look at the routes list it contains - // Search handle list - } - - // Look to expand and use recursion by searching routes and handles. Can have two separate functions - - function findRPRecursively(routes) { - console.log("Searching recursively!"); - console.log(routes); - let rpDictionary = {}; - for (let r_key in routes) { - for (let h_key in routes[r_key].handle){ - - let handle = routes[r_key].handle[h_key]; - - if (handle.handler === "subroute"){ - console.log("Found subroute!"); - findRPRecursively(routes[r_key].handle[h_key].routes) - } - if (handle.handler === 'reverse_proxy'){ - console.log("Found reverse proxy!"); - console.log(routes) - let host = routes[r_key].match.host; - rpDictionary[host] = handle.upstreams[0].dial; - } - } - } - return rpDictionary - } + // 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. @@ -204,6 +115,7 @@ import ButtonTest from '../views/ButtonTest.vue'; } + return handles; }