Skip to content

Instantly share code, notes, and snippets.

@tomac
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save tomac/bfae1eb72b633002f218 to your computer and use it in GitHub Desktop.

Select an option

Save tomac/bfae1eb72b633002f218 to your computer and use it in GitHub Desktop.
import nfqueue
import socket
import latch
q = None
def cb(dummy, payload):
response = api.status("ACCOUNT_ID_HERE").get_data()
if response["operations"][appId]["status"] == 'on'
payload.set_verdict(nfqueue.NF_DROP)
else
payload.set_verdict(nfqueue.NF_ACCEPT)
api = latch.Latch("APP_ID_HERE", "SECRET_KEY_HERE")
q = nfqueue.queue()
q.open()
q.bind(socket.AF_INET)
q.set_callback(cb)
q.create_queue(0)
try:
q.try_run()
except KeyboardInterrupt:
print "Exiting..."
q.unbind(socket.AF_INET)
q.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment