File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
caddytest/integration/caddyfile_adapt Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 21
21
ipv4 24
22
22
ipv6 32
23
23
}
24
+ request>client_ip ip_mask 16 32
24
25
request>headers>Regexp regexp secret REDACTED
25
26
request>headers>Hash hash
26
27
}
41
42
},
42
43
"encoder": {
43
44
"fields": {
45
+ "request\u003eclient_ip": {
46
+ "filter": "ip_mask",
47
+ "ipv4_cidr": 16,
48
+ "ipv6_cidr": 32
49
+ },
44
50
"request\u003eheaders\u003eAuthorization": {
45
51
"filter": "replace",
46
52
"value": "REDACTED"
Original file line number Diff line number Diff line change @@ -169,6 +169,27 @@ func (IPMaskFilter) CaddyModule() caddy.ModuleInfo {
169
169
// UnmarshalCaddyfile sets up the module from Caddyfile tokens.
170
170
func (m * IPMaskFilter ) UnmarshalCaddyfile (d * caddyfile.Dispenser ) error {
171
171
d .Next () // consume filter name
172
+
173
+ args := d .RemainingArgs ()
174
+ if len (args ) > 2 {
175
+ return d .Errf ("too many arguments" )
176
+ }
177
+ if len (args ) > 0 {
178
+ val , err := strconv .Atoi (args [0 ])
179
+ if err != nil {
180
+ return d .Errf ("error parsing %s: %v" , args [0 ], err )
181
+ }
182
+ m .IPv4MaskRaw = val
183
+
184
+ if len (args ) > 1 {
185
+ val , err := strconv .Atoi (args [1 ])
186
+ if err != nil {
187
+ return d .Errf ("error parsing %s: %v" , args [1 ], err )
188
+ }
189
+ m .IPv6MaskRaw = val
190
+ }
191
+ }
192
+
172
193
for d .NextBlock (0 ) {
173
194
switch d .Val () {
174
195
case "ipv4" :
You can’t perform that action at this time.
0 commit comments