Skip to content

Instantly share code, notes, and snippets.

View ixqbar's full-sized avatar
💭
I may be slow to respond.

Well ixqbar

💭
I may be slow to respond.
View GitHub Profile
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip:
@ixqbar
ixqbar / Makefile
Created December 24, 2016 03:16 — forked from jettero/Makefile
C blowfish demo
SHELL=/bin/bash
key=my key
go: clean
@ make --no-print-directory `git ls-files | sed 's/$$/.ubf/'`
@ for i in *.ubf; do x=`basename $$i .ubf`; ./my_diff.pl $$x $$i; done
words.bf: enc
./enc "$(key)" $(words) $@
@ixqbar
ixqbar / curltest.c
Created May 27, 2016 03:44 — forked from aaronhurt/curltest.c
example code using libcurl and json-c to post and parse a return from http://jsonplaceholder.typicode.com
/**
* example C code using libcurl and json-c
* to post and return a payload using
* http://jsonplaceholder.typicode.com
*
* Requirements:
*
* json-c - https://github.com/json-c/json-c
* libcurl - http://curl.haxx.se/libcurl/c
*
local client_ip = ngx.req.get_headers()["X-Forwarded-For"]
client_ip = string.match((client_ip or ngx.var.remote_addr), '[%d%.]+')
local passed = false
for allowed_ip in string.gmatch(ngx.var.allowed_ips, '([%d%.]+)') do
if client_ip == allowed_ip then
passed = true
end
end
@ixqbar
ixqbar / AES.c
Last active August 29, 2015 14:24 — forked from bricef/AES.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* MCrypt API available online:
* http://linux.die.net/man/3/mcrypt
*/
#include <mcrypt.h>