telize

High performance JSON IP and GeoIP REST API (IP Geolocation)
Log | Files | Refs | README | LICENSE

commit 276faffd07a7e0378f331780766e9263c914cdfa
parent 6496a284671fdeed2732fa5338e88ecfd0f83c72
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Mon, 26 Oct 2015 15:24:34 +0100

Check for invalid IP addresses before attempting to validate arguments

Diffstat:
Mtelize | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/telize b/telize @@ -84,7 +84,11 @@ server { local iconv = require("iconv") local cd = iconv.new("utf-8","iso-8859-15") - local callback = ngx.var.arg_callback + if ngx.var.arg_ip == "127.0.0.1" then + ngx.status = ngx.HTTP_BAD_REQUEST + ngx.say(cjson.encode({code = 401, message = "Input string is not a valid IP address"})) + ngx.exit(ngx.HTTP_OK) + end local args = { ip = ngx.var.arg_ip, @@ -106,6 +110,8 @@ server { isp = ngx.var.isp } + local callback = ngx.var.arg_callback + -- Validate args for item, value in pairs(args) do if args[item] == "" then @@ -130,12 +136,6 @@ server { args.isp = cd:iconv(args.isp) end - if args.ip == "127.0.0.1" then - ngx.status = ngx.HTTP_BAD_REQUEST - ngx.say(cjson.encode({code = 401, message = "Input string is not a valid IP address"})) - ngx.exit(ngx.HTTP_OK) - end - local json = cjson.encode(args) if callback ~= "" then