Return-Path: X-Original-To: apmail-trafficserver-users-archive@www.apache.org Delivered-To: apmail-trafficserver-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A5D4F178CF for ; Mon, 12 Jan 2015 03:41:56 +0000 (UTC) Received: (qmail 24638 invoked by uid 500); 12 Jan 2015 03:41:58 -0000 Delivered-To: apmail-trafficserver-users-archive@trafficserver.apache.org Received: (qmail 24579 invoked by uid 500); 12 Jan 2015 03:41:57 -0000 Mailing-List: contact users-help@trafficserver.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@trafficserver.apache.org Delivered-To: mailing list users@trafficserver.apache.org Received: (qmail 24569 invoked by uid 99); 12 Jan 2015 03:41:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jan 2015 03:41:57 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of moseleymark@gmail.com designates 209.85.223.175 as permitted sender) Received: from [209.85.223.175] (HELO mail-ie0-f175.google.com) (209.85.223.175) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jan 2015 03:41:52 +0000 Received: by mail-ie0-f175.google.com with SMTP id x19so23410784ier.6 for ; Sun, 11 Jan 2015 19:40:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=hJAMvqwkGtcTXSsh4MS+Ds9aEmJ/xgkXZBp4a7ah6Rg=; b=P1p3QuA3j9H4RNA8buZMBLAiPk6/YLxOiNtayNtah+VKW51WBAiMUjC/T67boh6v/F UcwkB5i2K2caR585EBI2mEa9ApKQLzlJ//OkZTmmFTjVNSO+qUZwegOKvZePVop1JF4K jlDQHLqVLD+/i72P2AgXcKuIO/AB5Ef04/OiHkGRBJbwUaK+Wx5Ap+4bfyswMrBG5RGm bRWmvuwbAXm37tRA8vKk1TkE0Kl//1LU188BY1fN4G3m+BV2tlgE57r1r81G9cwNh9kr It5Z54rRFx5E+X4eDQl/D7+w4pm1/kKt5q8fCcvM4czr2NSI1PpS0GUfcDGll7tdtB3U 9XVQ== MIME-Version: 1.0 X-Received: by 10.107.131.133 with SMTP id n5mr25571755ioi.30.1421034046721; Sun, 11 Jan 2015 19:40:46 -0800 (PST) Received: by 10.50.91.226 with HTTP; Sun, 11 Jan 2015 19:40:46 -0800 (PST) Date: Sun, 11 Jan 2015 19:40:46 -0800 Message-ID: Subject: Get Origin IP in Lua From: Mark Moseley To: users@trafficserver.apache.org Content-Type: multipart/alternative; boundary=001a113ebbf8919534050c6c45d0 X-Virus-Checked: Checked by ClamAV on apache.org --001a113ebbf8919534050c6c45d0 Content-Type: text/plain; charset=UTF-8 Hi. I'm looking at the TS_LUA_HOOK_OS_DNS hook or TS_LUA_HOOK_SEND_REQUEST_HDR as a way to do a fail-safe way of filtering *origin* IPs. Obviously this could be done at the onboard firewall level, but I thought it'd be neat to be able to do something a bit more in-line (and it's fun to play with Lua). But despite the aforementioned hooks, there doesn't seem to be anywhere in the 'ts' table that holds what the origin's DNS hostname was resolved to. Does that get stored anywhere that ts_lua has access to? ts.server_request seemed most promising but none of the functions in there seem to return anything like the origin IP. If there were something accessible with the origin IP, then I could do a sanity check like, pseudo-code-wise: for ip in goodips, does origin IP match ip, and if none match, then return a 403 or 400 or something. I'm coming up blank looking through the API and source code, but I may be missing something obvious (or more likely, just looking for the wrong thing). Even better (and I've had no luck finding this either) would be something built-in that contains a list of permitted origin IP blocks, like ip_allow.config but for the backend request (and again, there might be but I'm grepping+googling for the wrong thing). Thanks! --001a113ebbf8919534050c6c45d0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi. I'm looking at the TS_LUA_HOOK_OS_DNS hook or TS_L= UA_HOOK_SEND_REQUEST_HDR as a way to do a fail-safe way of=C2=A0filtering *= origin* IPs. Obviously this could be done at the onboard firewall level, bu= t I thought it'd be neat to be able to do something a bit more in-line = (and it's fun to play with Lua).

But despite the afo= rementioned hooks, there doesn't seem to be anywhere in the 'ts'= ; table that holds what the origin's DNS hostname was resolved to. Does= that get stored anywhere that ts_lua has access to? ts.server_request seem= ed most promising but none of the functions in there seem to return anythin= g like the origin IP.

If there were something acce= ssible with the origin IP, then I could do a sanity check like, pseudo-code= -wise: for ip in goodips, does origin IP match ip, and if none match, then = return a 403 or 400 or something.

I'm coming up blank = looking through the API and source code, but I may be missing something obv= ious (or more likely, just looking for the wrong thing).
<= div>
Even better (and I've had no luck finding this eithe= r) would be something built-in that contains a list of permitted origin IP = blocks, like ip_allow.config but for the backend request (and again, there = might be but I'm grepping+googling for the wrong thing).

=
Thanks!
--001a113ebbf8919534050c6c45d0--