aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/logging
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2024-02-12 12:15:35 -0500
committerGitHub <[email protected]>2024-02-12 17:15:35 +0000
commit91ec75441ab5b95deec4ee6794f00b3880ec6336 (patch)
treee3a645ddf24dafa79a9270ecb46ab572f64bda96 /modules/logging
parente7a534d0a311d9fa75b5981879c755281c4c9fba (diff)
downloadcaddy-91ec75441ab5b95deec4ee6794f00b3880ec6336.tar.gz
caddy-91ec75441ab5b95deec4ee6794f00b3880ec6336.zip
logging: Inline Caddyfile syntax for `ip_mask` filter (#6094)
Diffstat (limited to 'modules/logging')
-rw-r--r--modules/logging/filters.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/logging/filters.go b/modules/logging/filters.go
index f38f8c185..79d908fca 100644
--- a/modules/logging/filters.go
+++ b/modules/logging/filters.go
@@ -169,6 +169,27 @@ func (IPMaskFilter) CaddyModule() caddy.ModuleInfo {
// UnmarshalCaddyfile sets up the module from Caddyfile tokens.
func (m *IPMaskFilter) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
d.Next() // consume filter name
+
+ args := d.RemainingArgs()
+ if len(args) > 2 {
+ return d.Errf("too many arguments")
+ }
+ if len(args) > 0 {
+ val, err := strconv.Atoi(args[0])
+ if err != nil {
+ return d.Errf("error parsing %s: %v", args[0], err)
+ }
+ m.IPv4MaskRaw = val
+
+ if len(args) > 1 {
+ val, err := strconv.Atoi(args[1])
+ if err != nil {
+ return d.Errf("error parsing %s: %v", args[1], err)
+ }
+ m.IPv6MaskRaw = val
+ }
+ }
+
for d.NextBlock(0) {
switch d.Val() {
case "ipv4":