feat: implement port forwarding

This commit is contained in:
2024-11-28 19:17:37 +00:00
parent 6e6fb06351
commit cacf66067e
18 changed files with 553 additions and 101 deletions

View File

@@ -48,6 +48,10 @@ func (p *ReverseProxy) AddEntry(subdomain string, url *url.URL) {
p.httpProxies[subdomain] = proxy
}
func (p *ReverseProxy) RemoveEntry(subdomain string) {
delete(p.httpProxies, subdomain)
}
func (p *ReverseProxy) shouldHandleRequest(c echo.Context) bool {
h := strings.Replace(p.hostName, ".", "\\.", -1)
reg, err := regexp.Compile(".*\\." + h)
@@ -83,7 +87,8 @@ func (p *ReverseProxy) handleRequest(c echo.Context) error {
return echo.NewHTTPError(http.StatusNotFound)
}
proxy, ok := p.httpProxies[subdomain]
first := strings.Split(subdomain, ".")[0]
proxy, ok := p.httpProxies[first]
if !ok {
return echo.NewHTTPError(http.StatusNotFound)
}