diff --git a/resources/tokenisation/minter/token_gen.lua b/resources/tokenisation/minter/token_gen.lua
--- a/resources/tokenisation/minter/token_gen.lua
+++ b/resources/tokenisation/minter/token_gen.lua
#
@@ -27,12 +27,24 @@ local excluded_ips = {"127.0.0.1"}
#
local permitted_referrers = {"*.bentasker.co.uk"}
#
-local blacklisted_ips = {}
#
+local blacklisted_ips = {'127.0.1.1'}
#
+function table.contains(table, element)
#
+ -- From https://stackoverflow.com/questions/2282444/how-to-check-if-a-table-contains-an-element-in-lua
#
+ for _, value in pairs(table) do
#
+ if value == element then
#
local function sendSuccessful(tok,expires,debug)
#
-- response format should be
#
-- {"status": true, "token": "OqBvCvqg49QJgGKDHFbdNccB", "exp": 0}
#
@@ -49,11 +61,16 @@ local function mint_token(path,expires,ip,secret)
#
-local function sendFailed()
#
- -- response format should be
#
- -- {"status": true, "token": "OqBvCvqg49QJgGKDHFbdNccB", "exp": 0}
#
- local r = {status = false, token = 'failed', exp = '-1'}
#
- return json.encode(r)
#
+local function sendFailed(reason)
#
+ local r = {status = false, token = 'failed', exp = '-1', msg = reason}
#
+ -- ngx.say(json.encode(r))
#
+ print(json.encode(r))
#
@@ -69,7 +86,7 @@ local vidpath = '2019/08/16.m3u8' -- for offline testing only
#
-- local ip = ngx.var.remote_addr
#
-local ip = '127.0.0.1' -- for offline testing only
#
+local ip = '127.0.1.1' -- for offline testing only
#
-- Grab the HTTP referrer header if present
#
@@ -89,6 +106,12 @@ local httpref = 'https://snippets.bentasker.co.uk/foobar'
#
-- If the above passes, or the ip is in excluded_ips, then we should mint the token
#
-- otherwise, call sendFailed()
#
+if table.contains(blacklisted_ips,ip)
#
+ sendFailed("Users IP is blacklisted")
#
-- Calculate when the token should expire