   msg.reply "2fa required.  Use `auth 2fa` to validate identity."
   return false
 
+
 expirationWorker = ->
-  bl = fwdata.blacklist
+  expireEntriesFromList 'blacklist'
+  expireEntriesFromList 'whitelist'
+  setTimeout expirationWorker, svcQueueIntervalMs
+
+
+expireEntriesFromList = (list_name) ->
+  list = fwdata[list_name]
   removequeue = []
   deleted = [
     sprintf displayfmt, 'Type', 'Value', 'Expiration', 'Creator'
   ]
-  for obj in fwdata.blacklist when moment(obj.expires).valueOf() < Date.now()
+  for obj in fwdata[list_name] when moment(obj.expires).valueOf() < Date.now()
     deleted.push sprintf displayfmt, obj.type, obj.val,
       moment(obj.expires).fromNow(), obj.creator
     removequeue.push obj

  if removequeue.length > 0
    while removequeue.length > 0
      obj = removequeue.shift()
      bl.splice(bl.indexOf(obj), 1)
    msg = "fw: blacklist entries expired and have been removed. " +
      "Change will be applied in < 5 minutes. Removed: " +
      "```"+ deleted.join("\n") + "```"
    notifySubscribers msg
    fs.writeFileSync blacklistfile, JSON.stringify(fwdata), 'utf-8'

  setTimeout expirationWorker, svcQueueIntervalMs

notifySubscribers = (msg, current_un = false) ->
  console.error 'bad robotRef' unless robotRef
  for un in fwdata.notify
    robotRef.send { room: un }, msg unless current_un && un == current_un


module.exports = (robot) ->


    console.log('Unable to read file', error) unless error.code is 'ENOENT'

  robot.router.get "/#{robot.name}/#{modulename}/blacklist/url", (req, res) ->
    return httpGetList robot, req, res, 'blacklist', 'url'

  robot.router.get "/#{robot.name}/#{modulename}/blacklist/cidr", (req, res) ->
    return httpGetList robot, req, res, 'blacklist', 'cidr'

  robot.router.get "/#{robot.name}/#{modulename}/whitelist/url", (req, res) ->
    return httpGetList robot, req, res, 'whitelist', 'url'

  robot.router.get "/#{robot.name}/#{modulename}/whitelist/cidr", (req, res) ->
    return httpGetList robot, req, res, 'whitelist', 'cidr'

  robot.respond /(?:firewall|fw)(?: help| h|)$/, (msg) ->
    cmds = ['```']
    arr = [
      modulename + " show (white|black)list [(cidr|url) [searchterm]]"
      modulename + " add (white|black)list (url|cidr) <weburl.tld/etc|x.x.x.x>"
      modulename + " del (white|black)list (url|cidr) <weburl.tld/etc|x.x.x.x>"
      modulename + " subscribe [username] - subscribe to change notifications"
      modulename + " unsubscribe [username]"
      modulename + " show subscribers"
    ]

    for str in arr
