Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
KEYDIR=/etc/bind/external/keys
DSDIR=/etc/bind/external/ds
ZONES="miek.nl atoom.net dnssex.nl dnsex.nl"
cd "$1"
for z in $ZONES; do
if [ -e $z.nsec3 ]; then
# sign with NSEC3
/usr/sbin/dnssec-signzone -P $(grep -v '^\#' $z.nsec3) -N \
unixtime -K $KEYDIR -d $DSDIR -o $z -S $z >/dev/null 2>&1
@miekg
miekg / gist:6255503
Last active December 21, 2015 05:18
Fish like shell path in zsh.
# shorten path -> /home/miekg/bla -> /h/m/bla
function shorten() {
full=$(print -P "$1")
a=(${(s:/:)full})
if [[ $#a -eq 0 || $#a -eq 1 ]]; then
print $1; return
fi
last=$a[$#a]
a[$#a]= # clear last element
for i in $a; do
# In earlier versions of this makefile, the other two directories were
# subdirectories of $(TZDIR). However, this led to configuration errors.
# For example, with posix_right under the earlier scheme,
# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
# but gmtime without leap seconds, which led to problems with applications
# like sendmail that subtract gmtime from localtime.
# Therefore, the other two directories are now siblings of $(TZDIR).
# You must replace all of $(TZDIR) to switch from not using leap seconds
# to using them, or vice versa.
@miekg
miekg / zsh make function for golang
Created August 12, 2013 05:12
When doing cgo I get confused when to type make (to compile C code) or when to type go build (to compile Go code). Also in Vim you use :make, so to stop any confusing I'm using the following function. This allows me to always use 'make'.
make() {
if [[ -f Makefile || -f GNUMakefile ]]; then
command make "$@"
return
fi
go build
# if go build failed with exit code 1, the build env wasn't
# correct, in that case, try make again
if [[ $? -eq 1 ]]; then
command make "$@"
@miekg
miekg / gist:6032733
Created July 18, 2013 20:22
Table output after fixing
Fruit Price Advantages
----- ----- ----------
Bananas $1.34 built-in wrapper
Apples $0.10 cures   scurvy
Bananas $0.73 scurvy
Oranges $2.10 cures scurvy
@miekg
miekg / gist:6032720
Created July 18, 2013 20:21
Table output before fixing
Fruit | Price | Advantages |
---------------------------------------
Bananas | $1.34 | built-in wrapper |
Apples | $0.10 | cures   scurvy |
Bananas | $0.73 | scurvy |
Oranges | $2.10 | cures scurvy |
@miekg
miekg / zbundle
Last active December 18, 2015 22:18
zbundle
#!/bin/bash
set -e
getopts "s" show && shift
if [[ $show == "s" ]]; then
while read line; do
hex="$(echo $line | od -N4 -x | head -1)"
byte=(${hex})
if [[ ${byte[1]} == "4b50" && ${byte[2]} == "0403" ]]; then
break
fi
#
# See /usr/share/doc/unbound/examples/unbound.conf for a commented
# reference config file.
server:
# The following line will configure unbound to perform cryptographic
# DNSSEC validation using the root trust anchor.
auto-trust-anchor-file: "/var/lib/unbound/root.key"
do-not-query-localhost: no
local-zone: "168.192.in-addr.arpa" transparent
@miekg
miekg / x
Created February 6, 2013 09:21
tld-dnssec-check
for tld in $(awk ' { print $1 }' root-zone | egrep '^[a-z0-9-]+\.$' | sort -u); do
echo -n $tld:
if dig +dnssec DNSKEY $tld | grep -q RRSIG; then
echo -n DNSSEC:
else
echo -n dnssec:
fi
echo $(dig +noall +answer ${tld}cc.jpmens.net txt | awk ' { print $5" "$6" "$7" "$
package main
import (
"encoding/json"
"github.com/miekg/bitradix"
"log"
"net"
"os"
"reflect"
)