4月 132012
How do ACL match to req.http.X-Forwarded-For? (this is string!!)
I tried to make a vmod.
inet_pton(BOOL ipv6 , STRING str , STRING defaultstr)
example 1
import campur_xcir; set resp.http.v6 = campur_xcir.inet_pton(true,"2001:0db8:bd05:01d2:288a:1fc0:0001:10ee","1982:db8:20:3:1000:100:20:3"); set resp.http.v4 = campur_xcir.inet_pton(false,"1.1.1.1","2.2.2.2"); set resp.http.v6ng = campur_xcir.inet_pton(true,"2001:0db8:bd05:01d2:288a:1fc0:0001:10eeHOGE","1982:db8:20:3:1000:100:20:3");//NG pattern set resp.http.v4ng = campur_xcir.inet_pton(false,"1.1.1.1HOGE","2.2.2.2");//NG pattern //result v6: 2001:db8:bd05:1d2:288a:1fc0:1:10ee v4: 1.1.1.1 v6ng: 1982:db8:20:3:1000:100:20:3 v4ng: 2.2.2.2
example 2
import campur_xcir; //acl acl local { "192.168.1.0"/24; !"0.0.0.0"; } sub vcl_recv{ if(campur_xcir.inet_pton(false , req.http.X-Forwarded-For , "0.0.0.0") ~ local){ //acl ok ... } }
I hope that this code is of help to you.
libvmod-campur_xcir
this module is my motley function.
Others, get varnish generated hash etc…
this vmod’s function is increase at times. 🙂