<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div>Hi Michael,<div class=""><br class=""></div><div class="">I did something similar to this several years back using inline C:</div><div class=""><span class="Apple-tab-span" style="white-space:pre">   </span><a href="https://varnish-cache.org/docs/5.1/users-guide/vcl-inline-c.html" class="">https://varnish-cache.org/docs/5.1/users-guide/vcl-inline-c.html</a></div><div class=""><br class=""></div><div class="">I’m super-rusty on my C, so ask better minds, but I’d start by doing the if check in C and leaving the rest of the logic in VCL. I.e.</div><div class="">strtol() with a base of 16 (see <a href="http://pubs.opengroup.org/onlinepubs/7908799/xsh/strtol.html" class="">http://pubs.opengroup.org/onlinepubs/7908799/xsh/strtol.html</a>) and then a direct check of that against gmtime() - delta (hopefully your unix hex timestamps in UTC?). Double-check the input to strtol is safe — this approach has untrusted inputs getting run through into C.</div><div class=""><br class=""></div><div class="">-Jeff</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Apr 13, 2018, at 11:42 AM, Michael Kennedy <<a href="mailto:michael@kennedy.ie" class="">michael@kennedy.ie</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="divtagdefaultwrapper" dir="ltr" style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class="">Hi,</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div style="margin-top: 0px; margin-bottom: 0px;" class="">I have a URL that contains a Unix hex timestamp (something like <span class="">5ace8c5d)</span>. The timestamp should be within X minutes of now, and is used as part of an access control mechanism. I want to do something like this:</div><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div class="line" style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 16px; text-align: justify;">if (std.time(req.http.x-hextime, now) < now - 1w) {</div><div class="line-block" style="margin-top: 0px; margin-bottom: 0px; margin-left: 1.5em; color: rgb(34, 34, 34); font-family: sans-serif; font-size: 16px; text-align: justify;"><div class="line">...</div></div><div class="line" style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 16px; text-align: justify;">}</div><div class="line" style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 16px; text-align: justify;"><br class=""></div><div class="line" style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 16px; text-align: justify;">Is there an efficient way in VCL to either convert Hex to Dec so that this comparison can be done, or some other solution that does not involve changing the data in the URL.</div><div class="line" style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 16px; text-align: justify;"><br class=""></div><div class="line" style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 16px; text-align: justify;">Thanks,</div><div class="line" style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 16px; text-align: justify;"><br class=""></div><div class="line" style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 16px; text-align: justify;">Michael</div><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p></div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">varnish-misc mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="mailto:varnish-misc@varnish-cache.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">varnish-misc@varnish-cache.org</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a></div></blockquote></div><br class=""></div></body></html>