Commit: baa59da859763c5eaa6752a275fbd8e4545ec8d6 Parent: ce901ceea247c02c6081df6f642110fa75caf6ed Author: Vi Grey Date: 2024-06-19 02:36 UTC Summary: Add hosts key in config, rm host input in config CHANGELOG.txt | 9 +++++++++ src/augelmir.go | 2 +- src/config.go | 1 + src/http.go | 14 ++++++++++++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 9200550..d872b34 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. +## [0.0.4] - 2024-06-19 + +### Added +- hosts key in matches in config + +### Removed +- "host" value of input in matches in config + + ## [0.0.3] - 2024-06-18 ### Fixed diff --git a/src/augelmir.go b/src/augelmir.go index 51001df..bb6e777 100644 --- a/src/augelmir.go +++ b/src/augelmir.go @@ -6,7 +6,7 @@ import ( ) const ( - VERSION = "0.0.3" + VERSION = "0.0.4" ) func init() { diff --git a/src/config.go b/src/config.go index 7f166ba..f3cbcaf 100644 --- a/src/config.go +++ b/src/config.go @@ -27,6 +27,7 @@ type Config struct { } type Match struct { + Hosts []string `json:"hosts"` Input string `json:"input"` Expression string `json:"expression"` Index bool `json:"index"` diff --git a/src/http.go b/src/http.go index b97086c..478d29b 100644 --- a/src/http.go +++ b/src/http.go @@ -99,8 +99,6 @@ func httpHandler(w http.ResponseWriter, r *http.Request) { input = r.Referer() case "user-agent": input = r.UserAgent() - case "host": - input = r.Host case "path": input = r.URL.Path } @@ -108,6 +106,18 @@ func httpHandler(w http.ResponseWriter, r *http.Request) { if !expressionMatches { continue } + if len(match.Hosts) > 0 { + var hostMatches bool + for _, host := range match.Hosts { + if strings.ToLower(r.Host) == strings.ToLower(host) { + hostMatches = true + break + } + } + if !hostMatches { + continue + } + } webRoots = append(webRoots, match.WebRoots...) headers = append(headers, match.SetHeaders...) status = match.SetStatus