Simple API that gives a π or π to hostnames based on a stored obfuscated list.
Hosts are looked up from a SQLite database at hosts.db
. This database must be
populate and shipped with the deployment of this application. To populate it,
you need two things:
-
A URL contain a list of hostnames you want to block (ideally one formatted like this).
-
(Optionally) A key that will be used to hash the values as they are written to the database. This key will need to be shared with any clients of the service.
export HASH_KEY="your-key-value"
prior to running the populate task.
Install Go and then run make popc h=<your-hosts-url>
On make start
, a server will be available that responds to one API request:
curl 'localhost:8080/allow?url=<your-hashed-and-encoded-hostname>' -i
Clients need to do the following:
-
Strip urls down to just their hosts, e.g. google.com, not https://google.com?s=foo.
-
Hash the hostname using HMAC SHA256, passing the same key as used above.
-
Base64 encode that value, and include it as the
url
parameter in aGET
request to the/allow
endpoint.
The response will be JSON of either {"allow":true}
or `{"allow":false}.
make build
and make push
will build and push a container (including the
hosts.db file) to a repository of your choice.
For Heroku deployment:
-
Populate your hosts file locally or on CI with
export HASH_KEY="your-hash-key" && make popc h="your-hosts-url"
-
heroku container:login
-
heroku container:push web
-
heroku container:release web
MIT