On Wed, Jul 31, 2013 at 2:46 PM, Lasse Karstensen <span dir="ltr"><<a href="mailto:lkarsten@varnish-software.com" target="_blank">lkarsten@varnish-software.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello all.<br>
<br>
I've extended the std vmod to include an ip() method, which<br>
converts a string into VCL IP. The result can be used for<br>
matching against a VCL ACL.<br>
<br>
Attached is a patch against current master. Documentation and<br>
test case included.<br>
<br>
Please consider this for merging into the 4.0 release.<br></blockquote><div><br></div><div>A few comments:<br><br></div><div>- rp leaks if WS_Reserve() fails.</div><div><br></div><div>- WS_Reserve() is cheaper that getaddrinfo(), so I'd check first if there is space and then do the getaddrinfo() call. That'd simplify the error path too.</div>
<div><br></div><div>- Missing CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC).</div><div><br></div><div>- You could just check for getaddrinfo() != 0 instead of using s = .. since it's not used anywhere else.</div><div><br></div>
<div>- Using VCL_IP for the fallback parameter restricts what you can use to client.ip or server.ip. This might or might not be a problem. </div><div>I wrote a similar function a while ago that was using a STRING parameter as suggested by Tollef. Not sure if this is still required.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>f.-</div></div>