Commit 84b98dc4 authored by Geoff Simmons's avatar Geoff Simmons

ACL X-Forwarded-For "2nd-to-last" also works with IPv6 addresses.

parent 02a2a5c9
...@@ -51,7 +51,7 @@ sub vcl_recv { ...@@ -51,7 +51,7 @@ sub vcl_recv {
return(synth(403)); return(synth(403));
} }
if ( if (
std.ip(regsub(req.http.X-Forwarded-For,"^.*?([\d.]+)\s*,[^,]*$","\1"), "0.0.0.0") !~ vk8s_local_acl std.ip(regsub(req.http.X-Forwarded-For,"^.*?([[:xdigit:]:.]+)\s*,[^,]*$","\1"), "0.0.0.0") !~ vk8s_local_acl
) { ) {
return(synth(403)); return(synth(403));
} }
......
...@@ -533,7 +533,7 @@ func aclMask(bits uint8) string { ...@@ -533,7 +533,7 @@ func aclMask(bits uint8) string {
const ( const (
xffFirst = `regsub(req.http.X-Forwarded-For,"^([^,\s]+).*","\1")` xffFirst = `regsub(req.http.X-Forwarded-For,"^([^,\s]+).*","\1")`
xff2ndLast = `regsub(req.http.X-Forwarded-For,"^.*?([\d.]+)\s*,[^,]*$","\1")` xff2ndLast = `regsub(req.http.X-Forwarded-For,"^.*?([[:xdigit:]:.]+)\s*,[^,]*$","\1")`
) )
func aclCmp(comparand string) string { func aclCmp(comparand string) string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment