dot

packages and services management
Log | Files | Refs | README

commit 06441ddb5713439ba298fd8bfe4d66c8e3686007
parent 9981e89cf68bb5e9cd9c85ae13f91420914bc57f
Author: Josuah Demangeon <mail@josuah.net>
Date:   Wed, 20 Jun 2018 11:18:23 +0200

merge all confs to conf

Diffstat:
Apack/9base/build | 7+++++++
Apack/9base/git | 1+
Apack/9base/rcmain | 45+++++++++++++++++++++++++++++++++++++++++++++
Apack/9pfs/build | 6++++++
Apack/9pfs/git | 1+
Apack/9port/build | 7+++++++
Apack/9port/git | 1+
Apack/abduco/build | 5+++++
Apack/abduco/config.mk | 19+++++++++++++++++++
Apack/abduco/tar | 1+
Apack/bcftools/tar | 1+
Apack/blind/git | 1+
Apack/catpoint/git | 1+
Apack/cherrymusic/git | 1+
Apack/collectd/build | 9+++++++++
Apack/collectd/git | 1+
Apack/collectd/tar | 1+
Apack/curl/tar | 1+
Apack/dash/tar | 1+
Apack/djbdns-man/build | 8++++++++
Apack/djbdns-man/tar | 1+
Apack/djbdns/build | 8++++++++
Apack/djbdns/conf-cc | 1+
Apack/djbdns/djbdns-1.05-ipv6.diff | 4117+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apack/djbdns/tar | 1+
Apack/dmenu/tar | 1+
Apack/dq/build | 7+++++++
Apack/dq/tar | 1+
Apack/drawterm/build | 14++++++++++++++
Apack/drawterm/tar | 1+
Apack/dvtm/build | 2++
Apack/dvtm/config.h | 222+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apack/dvtm/config.mk | 14++++++++++++++
Apack/dvtm/git | 1+
Apack/dwm/build | 5+++++
Apack/dwm/config.h | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apack/dwm/config.mk | 37+++++++++++++++++++++++++++++++++++++
Apack/dwm/git | 1+
Apack/ed/git | 1+
Apack/eel/git | 1+
Apack/enchive/tar | 1+
Apack/entr/build | 3+++
Apack/entr/tar | 1+
Apack/execline/build | 9+++++++++
Apack/execline/tar | 1+
Apack/ezmlm/tar | 1+
Apack/farbfeld-resize/git | 1+
Apack/farbfeld/build | 2++
Apack/farbfeld/config.mk | 18++++++++++++++++++
Apack/farbfeld/tar | 1+
Apack/ff2txt/git | 1+
Apack/fluxcapacitor/git | 1+
Apack/geomyidae/tar | 1+
Apack/ghostscript/tar | 1+
Apack/git/build | 4++++
Apack/git/tar | 1+
Apack/gmake/build | 4++++
Apack/gmake/tar | 1+
Apack/gophermap/git | 1+
Apack/icecast/tar | 1+
Apack/ics2txt/git | 1+
Apack/ii/build | 5+++++
Apack/ii/git | 1+
Apack/ii/ii-1.8-ucspi.diff | 335+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apack/ii/tar | 1+
Apack/iomenu/build | 3+++
Apack/iomenu/git | 1+
Apack/ired/tar | 1+
Apack/irssi/build | 13+++++++++++++
Apack/irssi/git | 1+
Apack/jq/tar | 1+
Apack/lel/git | 1+
Apack/less/tar | 1+
Apack/libalsa/tar | 1+
Apack/libav/tar | 1+
Apack/libbearssl/build | 6++++++
Apack/libbearssl/tar | 1+
Apack/libbzip2/tar | 1+
Apack/libc9/git | 1+
Apack/libcurses/git | 1+
Apack/libedit/tar | 1+
Apack/libevent/tar | 1+
Apack/libflac/tar | 1+
Apack/libgit2/build | 14++++++++++++++
Apack/libgit2/features.h | 36++++++++++++++++++++++++++++++++++++
Apack/libgit2/tar | 1+
Apack/libhts/tar | 1+
Apack/libixp/tar | 1+
Apack/libjpeg/tar | 1+
Apack/liblz4/git | 1+
Apack/liblzma/tar | 1+
Apack/libmpg123/tar | 1+
Apack/libmusl/tar | 1+
Apack/libogg/tar | 1+
Apack/libopus/tar | 1+
Apack/libotr/tar | 1+
Apack/libowfat/tar | 1+
Apack/libpcap/tar | 1+
Apack/libpng/tar | 1+
Apack/libressl/tar | 1+
Apack/libskarnet/build | 4++++
Apack/libskarnet/tar | 1+
Apack/libsodium/tar | 1+
Apack/libtermkey/tar | 1+
Apack/libtool/tar | 1+
Apack/libtox/tar | 1+
Apack/libutf/git | 1+
Apack/libvorbis/tar | 1+
Apack/libvpx/tar | 1+
Apack/libx11/tar | 1+
Apack/libz/tar | 1+
Apack/links2/build | 5+++++
Apack/links2/git | 1+
Apack/man-freebsd/tar | 1+
Apack/man-linux/tar | 1+
Apack/man-plan9/tar | 1+
Apack/man-posix/build | 3+++
Apack/man-posix/tar | 1+
Apack/mandoc/tar | 1+
Apack/mblaze/build | 3+++
Apack/mblaze/tar | 1+
Apack/ministat/git | 1+
Apack/miniwi/git | 1+
Apack/mpop/build | 8++++++++
Apack/mpop/tar | 1+
Apack/msmtp/build | 7+++++++
Apack/msmtp/tar | 1+
Apack/mujs/tar | 1+
Apack/mupdf/tar | 1+
Apack/netpgp/tar | 1+
Apack/ngircd/build | 2++
Apack/ngircd/tar | 1+
Apack/oksh/tar | 1+
Apack/openssh/build.nero | 37+++++++++++++++++++++++++++++++++++++
Apack/openssh/openssh-sys_param.patch | 10++++++++++
Apack/openssh/tar | 1+
Apack/opentracker/git | 1+
Apack/opus-tools/tar | 1+
Apack/ploot/git | 1+
Apack/plstree/build | 3+++
Apack/plstree/git | 1+
Apack/qemu/build | 2++
Apack/qemu/tar | 1+
Apack/qmail/build | 16++++++++++++++++
Apack/qmail/tar | 1+
Apack/quark/build | 5+++++
Apack/quark/config.h | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apack/quark/git | 1+
Apack/radare2/build | 2++
Apack/radare2/git | 1+
Apack/ratox/config.mk | 27+++++++++++++++++++++++++++
Apack/ratox/git | 1+
Apack/redis/tar | 1+
Apack/reflex/build | 2++
Apack/reflex/tar | 1+
Apack/rlwrap/tar | 1+
Apack/rsync/rsync-fix-proto.h-tstamp-target.patch | 12++++++++++++
Apack/rsync/tar | 1+
Apack/runit/build | 9+++++++++
Apack/runit/tar | 1+
Apack/s6-dns/build | 9+++++++++
Apack/s6-dns/tar | 1+
Apack/s6-networking/build | 14++++++++++++++
Apack/s6-networking/tar | 1+
Apack/s6-rc/build | 11+++++++++++
Apack/s6-rc/tar | 1+
Apack/s6/build | 10++++++++++
Apack/s6/tar | 1+
Apack/sacc/git | 1+
Apack/sacc/tar | 1+
Apack/samtools/tar | 1+
Apack/sbase/git | 1+
Apack/scc/git | 1+
Apack/scron/git | 1+
Apack/scrypt/tar | 1+
Apack/sct/build | 5+++++
Apack/sct/sct.c | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apack/sent/config.h | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apack/sent/config.mk | 28++++++++++++++++++++++++++++
Apack/sent/git | 1+
Apack/sfeed/build | 5+++++
Apack/sfeed/git | 1+
Apack/sfeed/sfeed_twtxt.c | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apack/shntool/tar | 1+
Apack/snooze/build | 3+++
Apack/snooze/git | 1+
Apack/spoon/build | 7+++++++
Apack/spoon/config.h | 17+++++++++++++++++
Apack/spoon/git | 1+
Apack/sqlite/tar | 1+
Apack/sselp/git | 1+
Apack/st/build | 6++++++
Apack/st/colors.h | 27+++++++++++++++++++++++++++
Apack/st/config.h | 416+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apack/st/config.mk | 28++++++++++++++++++++++++++++
Apack/st/helios_dark.h | 27+++++++++++++++++++++++++++
Apack/st/solarized_dark.h | 27+++++++++++++++++++++++++++
Apack/st/solarized_light.h | 27+++++++++++++++++++++++++++
Apack/st/tar | 1+
Apack/stagit-gopher/config.mk | 29+++++++++++++++++++++++++++++
Apack/stagit-gopher/git | 1+
Apack/stagit/config.mk | 29+++++++++++++++++++++++++++++
Apack/stagit/git | 1+
Apack/supervise/death_tally | 0
Apack/supervise/lock | 0
Apack/supervise/status | 0
Apack/tabbed/build | 5+++++
Apack/tabbed/config.mk | 33+++++++++++++++++++++++++++++++++
Apack/tabbed/git | 1+
Apack/tarsnap/tar | 1+
Apack/tcpdump/tar | 1+
Apack/tinc/tar | 1+
Apack/tinyssh/build | 5+++++
Apack/tinyssh/git | 1+
Apack/tinyssh/tar | 1+
Apack/tmux/tar | 1+
Apack/tnftp/tar | 1+
Apack/tor/build | 5+++++
Apack/tor/tar | 1+
Apack/transmission/build | 4++++
Apack/transmission/tar | 1+
Apack/tttml/git | 1+
Apack/u9fs/build | 8++++++++
Apack/u9fs/git | 1+
Apack/vis/build | 11+++++++++++
Apack/vis/git | 1+
Apack/vorbis-tools/tar | 1+
Apack/yacc/build | 3+++
Apack/yacc/tar | 1+
Apack/yasm/tar | 1+
As6/backup/log/run | 2++
As6/backup/run | 9+++++++++
As6/btpd/log/run | 2++
As6/btpd/run | 6++++++
As6/cherrymusic/log/run | 2++
As6/cherrymusic/run | 9+++++++++
As6/collectd/data/conf | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
As6/collectd/log/run | 2++
As6/collectd/run | 6++++++
As6/djbdns-axfrdns/env/ROOT | 1+
As6/djbdns-axfrdns/log/run | 2++
As6/djbdns-axfrdns/run | 11+++++++++++
As6/djbdns-dnscache/data/ip/127.0.0.1 | 0
As6/djbdns-dnscache/data/servers/@ | 0
As6/djbdns-dnscache/env/CACHESIZE | 1+
As6/djbdns-dnscache/env/DATALIMIT | 1+
As6/djbdns-dnscache/env/IP | 1+
As6/djbdns-dnscache/env/IPSEND | 1+
As6/djbdns-dnscache/env/ROOT | 1+
As6/djbdns-dnscache/log/run | 2++
As6/djbdns-dnscache/run | 13+++++++++++++
As6/djbdns-tinydns/data/add-alias | 2++
As6/djbdns-tinydns/data/add-childns | 2++
As6/djbdns-tinydns/data/add-host | 2++
As6/djbdns-tinydns/data/add-mx | 2++
As6/djbdns-tinydns/data/add-ns | 2++
As6/djbdns-tinydns/data/data | 0
As6/djbdns-tinydns/data/mkfile | 2++
As6/djbdns-tinydns/env/IP | 1+
As6/djbdns-tinydns/env/ROOT | 1+
As6/djbdns-tinydns/log/run | 2++
As6/djbdns-tinydns/run | 9+++++++++
As6/djbdns-walldns/env/IP | 1+
As6/djbdns-walldns/env/ROOT | 1+
As6/djbdns-walldns/log/run | 2++
As6/djbdns-walldns/run | 8++++++++
As6/fossil/log/run | 2++
As6/fossil/run | 11+++++++++++
As6/geomyidae/log/run | 2++
As6/geomyidae/run | 9+++++++++
As6/git-daemon/log/run | 2++
As6/git-daemon/run | 10++++++++++
As6/git-mirror/data/mirror | 0
As6/git-mirror/log/run | 2++
As6/git-mirror/run | 6++++++
As6/gproxy/data/gproxy | 110+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
As6/gproxy/log/run | 2++
As6/gproxy/run | 6++++++
As6/ii-tail/log/run | 2++
As6/ii-tail/run | 13+++++++++++++
As6/ii-tcp/env/HOST | 1+
As6/ii-tcp/env/NAME | 0
As6/ii-tcp/env/NICK | 1+
As6/ii-tcp/env/PASS | 0
As6/ii-tcp/env/PORT | 1+
As6/ii-tcp/env/USER | 1+
As6/ii-tcp/log/run | 2++
As6/ii-tcp/run | 29+++++++++++++++++++++++++++++
As6/ii-tls/data/.empty | 0
As6/ii-tls/env/CAFILE | 1+
As6/ii-tls/env/HOST | 1+
As6/ii-tls/env/NAME | 0
As6/ii-tls/env/NICK | 1+
As6/ii-tls/env/PASS | 0
As6/ii-tls/env/PORT | 1+
As6/ii-tls/env/USER | 1+
As6/ii-tls/log/run | 2++
As6/ii-tls/run | 30++++++++++++++++++++++++++++++
As6/mpop/data/mpoprc | 15+++++++++++++++
As6/mpop/env/USER | 1+
As6/mpop/log/run | 2++
As6/mpop/run | 16++++++++++++++++
As6/ngircd/data/conf | 45+++++++++++++++++++++++++++++++++++++++++++++
As6/ngircd/data/motd | 37+++++++++++++++++++++++++++++++++++++
As6/ngircd/data/tls | 8++++++++
As6/ngircd/log/run | 2++
As6/ngircd/run | 6++++++
As6/opentracker/log/run | 2++
As6/opentracker/run | 6++++++
As6/plot/data/plot | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
As6/plot/log/run | 2++
As6/plot/run | 6++++++
As6/qemu-tap/log/run | 2++
As6/qemu-tap/run | 23+++++++++++++++++++++++
As6/qemu-user/log/run | 2++
As6/qemu-user/run | 21+++++++++++++++++++++
As6/qmail-smtpd/log/run | 2++
As6/qmail-smtpd/run | 9+++++++++
As6/qmail-start/log/run | 2++
As6/qmail-start/run | 8++++++++
As6/quark-tor/log/run | 2++
As6/quark-tor/run | 17+++++++++++++++++
As6/quark/log/run | 2++
As6/quark/run | 14++++++++++++++
As6/ratox/log/run | 2++
As6/ratox/run | 11+++++++++++
As6/ssh-fwd/log/run | 2++
As6/ssh-fwd/run | 7+++++++
As6/tinc/data/conf.d/common.conf | 2++
As6/tinc/data/hosts/kroa | 13+++++++++++++
As6/tinc/data/hosts/nas | 13+++++++++++++
As6/tinc/data/hosts/pdmg | 12++++++++++++
As6/tinc/data/hosts/rpi | 13+++++++++++++
As6/tinc/data/hosts/t470s | 12++++++++++++
As6/tinc/data/tinc-up | 11+++++++++++
As6/tinc/log/run | 2++
As6/tinc/run | 9+++++++++
As6/tinysshd/log/run | 2++
As6/tinysshd/run | 11+++++++++++
As6/tls/log/run | 2++
As6/tls/run | 12++++++++++++
As6/tor/data/conf | 26++++++++++++++++++++++++++
As6/tor/log/run | 2++
As6/tor/run | 6++++++
As6/u9fs-mount/down | 4++++
As6/u9fs-mount/log/run | 2++
As6/u9fs-mount/up | 5+++++
As6/u9fs/log/run | 2++
As6/u9fs/run | 8++++++++
As6/venti/data/conf | 8++++++++
As6/venti/data/fmt | 9+++++++++
As6/venti/log/run | 2++
As6/venti/run | 11+++++++++++
353 files changed, 7455 insertions(+), 0 deletions(-)

diff --git a/pack/9base/build b/pack/9base/build @@ -0,0 +1,7 @@ +#!/bin/sh -ex +# install minimal base system: mk(1) rc(1) + +mkdir -p /9/etc +cp -f "$PACK/9base/rcmain" /9/etc/rcmain +cd /9/base +make PLAN9=/9 PREFIX=/9 install diff --git a/pack/9base/git b/pack/9base/git @@ -0,0 +1 @@ +git://git.suckless.org/9base diff --git a/pack/9base/rcmain b/pack/9base/rcmain @@ -0,0 +1,45 @@ +# rcmain: Plan 9 on Unix version +if(~ $#HOME 1) home=$HOME +if(~ $#home 0) home=/ +if(~ $#ifs 0) ifs=' + ' +switch($#prompt){ +case 0 + prompt=('; ' ' ') +case 1 + prompt=($prompt ' ') +} +if(~ $rcname ?.out ?.rc */?.rc */?.out) prompt=('broken! ' ' ') +if(flag p) path=(/bin /usr/bin) +if not{ + finit + # should be taken care of by rc now, but leave just in case +} +fn sigexit +if(! ~ $#cflag 0){ + if(flag l && test -r $home/lib/profile) . $home/lib/profile + status='' + eval $cflag + exit $status +} +if(flag i){ + if(flag l && test -r $home/lib/profile) . $home/lib/profile + status='' + if(! ~ $#* 0) . $* + . -i '/dev/stdin' + exit $status +} +if(flag l && test -r $home/lib/profile) . $home/lib/profile +if(~ $#* 0){ + . /dev/stdin + exit $status +} +status='' +if(! ~ $1 /*){ + first=$1 + shift + *=(./$first $*) + first='' +} +. $* +exit $status diff --git a/pack/9pfs/build b/pack/9pfs/build @@ -0,0 +1,6 @@ +#!/bin/sh -ex + +make +mkdir -p "$PREFIX/bin" "$PREFIX/share/man/man1" +cp 9pfs "$PREFIX/bin" +cp 9pfs.1 "$PREFIX/share/man/man1" diff --git a/pack/9pfs/git b/pack/9pfs/git @@ -0,0 +1 @@ +git://github.com/mischief/9pfs diff --git a/pack/9port/build b/pack/9port/build @@ -0,0 +1,7 @@ +#!/bin/sh -ex + +./INSTALL +mkdir -p /9/port +cp -R acid bin dict dist face font include lib lp mac mail man \ + ndb news plumb postscript proto sky tmac troff lib tmac \ + /9/port diff --git a/pack/9port/git b/pack/9port/git @@ -0,0 +1 @@ +https://github.com/9fans/plan9port diff --git a/pack/abduco/build b/pack/abduco/build @@ -0,0 +1,5 @@ +#!/bin/sh -ex + +cp "$PACK/config.mk" . + +make PREFIX="$PREFIX" install diff --git a/pack/abduco/config.mk b/pack/abduco/config.mk @@ -0,0 +1,19 @@ +# abduco version +VERSION = 0.6 + +# Customize below to fit your system + +PREFIX ?= /usr/local +MANPREFIX = ${PREFIX}/share/man + +INCS = -I. +LIBS = -lc -lutil + +CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE=1 +CFLAGS += -std=c99 -pedantic -Wall ${INCS} -DVERSION=\"${VERSION}\" -DNDEBUG ${CPPFLAGS} +LDFLAGS += ${LIBS} + +DEBUG_CFLAGS = ${CFLAGS} -UNDEBUG -O0 -g -ggdb + +CC ?= cc +STRIP ?= strip diff --git a/pack/abduco/tar b/pack/abduco/tar @@ -0,0 +1 @@ +http://www.brain-dump.org/projects/abduco/abduco-0.6.tar.gz diff --git a/pack/bcftools/tar b/pack/bcftools/tar @@ -0,0 +1 @@ +https://github.com/samtools/bcftools/releases/download/1.8/bcftools-1.8.tar.bz2 diff --git a/pack/blind/git b/pack/blind/git @@ -0,0 +1 @@ +git://git.suckless.org/blind diff --git a/pack/catpoint/git b/pack/catpoint/git @@ -0,0 +1 @@ +git://git.2f30.org/catpoint.git diff --git a/pack/cherrymusic/git b/pack/cherrymusic/git @@ -0,0 +1 @@ +git://github.com/devsnd/cherrymusic diff --git a/pack/collectd/build b/pack/collectd/build @@ -0,0 +1,9 @@ +#!/bin/sh -ex + +./configure --prefix="$PREFIX" \ + --sbindir="$PREFIX/bin" \ + --localstatedir=/var \ + --disable-perl \ + --disable-python \ + --disable-lua \ + --enable-csv diff --git a/pack/collectd/git b/pack/collectd/git @@ -0,0 +1 @@ +git://github.com/collectd/collectdr diff --git a/pack/collectd/tar b/pack/collectd/tar @@ -0,0 +1 @@ +https://storage.googleapis.com/collectd-tarballs/collectd-5.8.0.tar.bz2 diff --git a/pack/curl/tar b/pack/curl/tar @@ -0,0 +1 @@ +https://curl.haxx.se/download/curl-7.56.0.tar.xz diff --git a/pack/dash/tar b/pack/dash/tar @@ -0,0 +1 @@ +http://gondor.apana.org.au/~herbert/dash/files/dash-0.5.9.tar.gz diff --git a/pack/djbdns-man/build b/pack/djbdns-man/build @@ -0,0 +1,8 @@ +#!/bin/sh -ex + cd $SOURCE + mkdir -p $PREFIX//share/man/man1 + cp *.1 $PREFIX//share/man/man1 + mkdir -p $PREFIX//share/man/man5 + cp *.5 $PREFIX//share/man/man5 + mkdir -p $PREFIX//share/man/man8 + cp *.8 $PREFIX//share/man/man8 diff --git a/pack/djbdns-man/tar b/pack/djbdns-man/tar @@ -0,0 +1 @@ +http://smarden.org/pape/djb/manpages/djbdns-1.05-man.tar.gz diff --git a/pack/djbdns/build b/pack/djbdns/build @@ -0,0 +1,8 @@ +#!/bin/sh -ex + +! patch -N -p1 <$PACK/djbdns-1.05-ipv6.diff +echo gcc -O2 -include /usr/include/errno.h >conf-cc +echo "$PREFIX" >conf-home + +make +make setup diff --git a/pack/djbdns/conf-cc b/pack/djbdns/conf-cc @@ -0,0 +1 @@ +gcc -O2 -include /usr/include/errno.h diff --git a/pack/djbdns/djbdns-1.05-ipv6.diff b/pack/djbdns/djbdns-1.05-ipv6.diff @@ -0,0 +1,4117 @@ +diff -uNr djbdns-1.05/FILES djbdns-1.05-ipv6/FILES +--- djbdns-1.05/FILES 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/FILES 2017-01-07 13:34:48.960745102 +0100 +@@ -135,6 +135,7 @@ + exit.h + fmt.h + fmt_ulong.c ++fmt_xlong.c + gen_alloc.h + gen_allocdefs.h + getln.c +@@ -151,6 +152,9 @@ + ip4.h + ip4_fmt.c + ip4_scan.c ++ip6.h ++ip6_fmt.c ++ip6_scan.c + ndelay.h + ndelay_off.c + ndelay_on.c +@@ -164,6 +168,7 @@ + readclose.c + readclose.h + scan.h ++scan_0x.c + scan_ulong.c + seek.h + seek_set.c +@@ -241,3 +246,9 @@ + warn-shsgr + buffer_read.c + buffer_write.c ++dns_nd6.c ++socket_udp6.c ++socket_getifidx.c ++tryn2i.c ++haven2i.h1 ++haven2i.h2 +diff -uNr djbdns-1.05/Makefile djbdns-1.05-ipv6/Makefile +--- djbdns-1.05/Makefile 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/Makefile 2017-01-07 13:34:48.960745102 +0100 +@@ -52,10 +52,10 @@ + + axfrdns: \ + load axfrdns.o iopause.o droproot.o tdlookup.o response.o qlog.o \ +-prot.o timeoutread.o timeoutwrite.o dns.a libtai.a alloc.a env.a \ ++prot.o timeoutread.o timeoutwrite.o clientloc.o dns.a libtai.a alloc.a env.a \ + cdb.a buffer.a unix.a byte.a + ./load axfrdns iopause.o droproot.o tdlookup.o response.o \ +- qlog.o prot.o timeoutread.o timeoutwrite.o dns.a libtai.a \ ++ qlog.o prot.o timeoutread.o timeoutwrite.o clientloc.o dns.a libtai.a \ + alloc.a env.a cdb.a buffer.a unix.a byte.a + + axfrdns-conf: \ +@@ -73,7 +73,7 @@ + tai.h uint64.h buffer.h timeoutread.h timeoutwrite.h open.h seek.h \ + cdb.h uint32.h stralloc.h gen_alloc.h strerr.h str.h byte.h case.h \ + dns.h stralloc.h iopause.h taia.h tai.h taia.h scan.h qlog.h uint16.h \ +-response.h uint32.h ++response.h uint32.h clientloc.h + ./compile axfrdns.c + + buffer.a: \ +@@ -120,12 +120,14 @@ + case_diffb.o case_diffs.o case_lowerb.o fmt_ulong.o ip4_fmt.o \ + ip4_scan.o scan_ulong.o str_chr.o str_diff.o str_len.o str_rchr.o \ + str_start.o uint16_pack.o uint16_unpack.o uint32_pack.o \ +-uint32_unpack.o ++uint32_unpack.o ip6_fmt.o ip6_scan.o fmt_xlong.o \ ++scan_xlong.o + ./makelib byte.a byte_chr.o byte_copy.o byte_cr.o \ + byte_diff.o byte_zero.o case_diffb.o case_diffs.o \ + case_lowerb.o fmt_ulong.o ip4_fmt.o ip4_scan.o scan_ulong.o \ + str_chr.o str_diff.o str_len.o str_rchr.o str_start.o \ +- uint16_pack.o uint16_unpack.o uint32_pack.o uint32_unpack.o ++ uint16_pack.o uint16_unpack.o uint32_pack.o uint32_unpack.o \ ++ ip6_fmt.o ip6_scan.o fmt_xlong.o scan_xlong.o + + byte_chr.o: \ + compile byte_chr.c byte.h +@@ -209,6 +211,10 @@ + > choose + chmod 755 choose + ++clientloc.o: \ ++compile clientloc.c open.h byte.h cdb.h ip6.h ++ ./compile clientloc.c ++ + compile: \ + warn-auto.sh conf-cc + ( cat warn-auto.sh; \ +@@ -228,11 +234,13 @@ + dns.a: \ + makelib dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o dns_ipq.o dns_mx.o \ + dns_name.o dns_nd.o dns_packet.o dns_random.o dns_rcip.o dns_rcrw.o \ +-dns_resolve.o dns_sortip.o dns_transmit.o dns_txt.o ++dns_resolve.o dns_sortip.o dns_transmit.o dns_txt.o dns_ip6.o \ ++dns_sortip6.o dns_nd6.o dns_ipq6.o + ./makelib dns.a dns_dfd.o dns_domain.o dns_dtda.o dns_ip.o \ + dns_ipq.o dns_mx.o dns_name.o dns_nd.o dns_packet.o \ + dns_random.o dns_rcip.o dns_rcrw.o dns_resolve.o \ +- dns_sortip.o dns_transmit.o dns_txt.o ++ dns_sortip.o dns_transmit.o dns_txt.o dns_ip6.o dns_sortip6.o \ ++ dns_nd6.o dns_ipq6.o + + dns_dfd.o: \ + compile dns_dfd.c error.h alloc.h byte.h dns.h stralloc.h gen_alloc.h \ +@@ -254,11 +262,21 @@ + stralloc.h iopause.h taia.h tai.h uint64.h taia.h + ./compile dns_ip.c + ++dns_ip6.o: \ ++compile dns_ip6.c stralloc.h gen_alloc.h uint16.h byte.h dns.h \ ++stralloc.h iopause.h taia.h tai.h uint64.h taia.h ++ ./compile dns_ip6.c ++ + dns_ipq.o: \ + compile dns_ipq.c stralloc.h gen_alloc.h case.h byte.h str.h dns.h \ + stralloc.h iopause.h taia.h tai.h uint64.h taia.h + ./compile dns_ipq.c + ++dns_ipq6.o: \ ++compile dns_ipq6.c stralloc.h gen_alloc.h case.h byte.h str.h dns.h \ ++stralloc.h iopause.h taia.h tai.h uint64.h taia.h ++ ./compile dns_ipq6.c ++ + dns_mx.o: \ + compile dns_mx.c stralloc.h gen_alloc.h byte.h uint16.h dns.h \ + stralloc.h iopause.h taia.h tai.h uint64.h taia.h +@@ -274,6 +292,11 @@ + taia.h tai.h uint64.h taia.h + ./compile dns_nd.c + ++dns_nd6.o: \ ++compile dns_nd6.c byte.h fmt.h dns.h stralloc.h gen_alloc.h iopause.h \ ++taia.h tai.h uint64.h taia.h ++ ./compile dns_nd6.c ++ + dns_packet.o: \ + compile dns_packet.c error.h dns.h stralloc.h gen_alloc.h iopause.h \ + taia.h tai.h uint64.h taia.h +@@ -306,6 +329,11 @@ + taia.h tai.h uint64.h taia.h + ./compile dns_sortip.c + ++dns_sortip6.o: \ ++compile dns_sortip6.c byte.h dns.h stralloc.h gen_alloc.h iopause.h \ ++taia.h tai.h uint64.h taia.h ++ ./compile dns_sortip6.c ++ + dns_transmit.o: \ + compile dns_transmit.c socket.h uint16.h alloc.h error.h byte.h \ + uint16.h dns.h stralloc.h gen_alloc.h iopause.h taia.h tai.h uint64.h \ +@@ -369,6 +397,17 @@ + gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h + ./compile dnsip.c + ++dnsip6: \ ++load dnsip6.o iopause.o dns.a env.a libtai.a alloc.a buffer.a unix.a \ ++byte.a socket.lib ++ ./load dnsip6 iopause.o dns.a env.a libtai.a alloc.a \ ++ buffer.a unix.a byte.a `cat socket.lib` ++ ++dnsip6.o: \ ++compile dnsip6.c buffer.h exit.h strerr.h ip6.h dns.h stralloc.h \ ++gen_alloc.h iopause.h taia.h tai.h uint64.h ++ ./compile dnsip6.c ++ + dnsipq: \ + load dnsipq.o iopause.o dns.a env.a libtai.a alloc.a buffer.a unix.a \ + byte.a socket.lib +@@ -380,6 +419,17 @@ + gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h + ./compile dnsipq.c + ++dnsip6q: \ ++load dnsip6q.o iopause.o dns.a env.a libtai.a alloc.a buffer.a unix.a \ ++byte.a socket.lib ++ ./load dnsip6q iopause.o dns.a env.a libtai.a alloc.a \ ++ buffer.a unix.a byte.a `cat socket.lib` ++ ++dnsip6q.o: \ ++compile dnsip6q.c buffer.h exit.h strerr.h ip4.h dns.h stralloc.h \ ++gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h ++ ./compile dnsip6q.c ++ + dnsmx: \ + load dnsmx.o iopause.o dns.a env.a libtai.a alloc.a buffer.a unix.a \ + byte.a socket.lib +@@ -399,7 +449,7 @@ + + dnsname.o: \ + compile dnsname.c buffer.h exit.h strerr.h ip4.h dns.h stralloc.h \ +-gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h ++gen_alloc.h iopause.h taia.h tai.h uint64.h taia.h ip6.h + ./compile dnsname.c + + dnsq: \ +@@ -484,6 +534,10 @@ + compile fmt_ulong.c fmt.h + ./compile fmt_ulong.c + ++fmt_xlong.o: \ ++compile fmt_xlong.c scan.h ++ ./compile fmt_xlong.c ++ + generic-conf.o: \ + compile generic-conf.c strerr.h buffer.h open.h generic-conf.h \ + buffer.h +@@ -546,10 +600,18 @@ + compile ip4_fmt.c fmt.h ip4.h + ./compile ip4_fmt.c + ++ip6_fmt.o: \ ++compile ip6_fmt.c fmt.h ip6.h ++ ./compile ip6_fmt.c ++ + ip4_scan.o: \ + compile ip4_scan.c scan.h ip4.h + ./compile ip4_scan.c + ++ip6_scan.o: \ ++compile ip6_scan.c scan.h ip6.h ++ ./compile ip6_scan.c ++ + it: \ + prog install instcheck + +@@ -626,9 +688,9 @@ + ./compile parsetype.c + + pickdns: \ +-load pickdns.o server.o response.o droproot.o qlog.o prot.o dns.a \ ++load pickdns.o server.o iopause.o response.o droproot.o qlog.o prot.o dns.a \ + env.a libtai.a cdb.a alloc.a buffer.a unix.a byte.a socket.lib +- ./load pickdns server.o response.o droproot.o qlog.o \ ++ ./load pickdns server.o iopause.o response.o droproot.o qlog.o \ + prot.o dns.a env.a libtai.a cdb.a alloc.a buffer.a unix.a \ + byte.a `cat socket.lib` + +@@ -677,7 +739,7 @@ + rbldns-data pickdns-conf pickdns pickdns-data tinydns-conf tinydns \ + tinydns-data tinydns-get tinydns-edit axfr-get axfrdns-conf axfrdns \ + dnsip dnsipq dnsname dnstxt dnsmx dnsfilter random-ip dnsqr dnsq \ +-dnstrace dnstracesort cachetest utime rts ++dnstrace dnstracesort cachetest utime rts dnsip6 dnsip6q + + prot.o: \ + compile prot.c hasshsgr.h prot.h +@@ -704,9 +766,9 @@ + ./compile random-ip.c + + rbldns: \ +-load rbldns.o server.o response.o dd.o droproot.o qlog.o prot.o dns.a \ ++load rbldns.o server.o iopause.o response.o dd.o droproot.o qlog.o prot.o dns.a \ + env.a libtai.a cdb.a alloc.a buffer.a unix.a byte.a socket.lib +- ./load rbldns server.o response.o dd.o droproot.o qlog.o \ ++ ./load rbldns server.o iopause.o response.o dd.o droproot.o qlog.o \ + prot.o dns.a env.a libtai.a cdb.a alloc.a buffer.a unix.a \ + byte.a `cat socket.lib` + +@@ -762,6 +824,10 @@ + compile scan_ulong.c scan.h + ./compile scan_ulong.c + ++scan_xlong.o: \ ++compile scan_xlong.c scan.h ++ ./compile scan_xlong.c ++ + seek_set.o: \ + compile seek_set.c seek.h + ./compile seek_set.c +@@ -774,7 +840,7 @@ + compile server.c byte.h case.h env.h buffer.h strerr.h ip4.h uint16.h \ + ndelay.h socket.h uint16.h droproot.h qlog.h uint16.h response.h \ + uint32.h dns.h stralloc.h gen_alloc.h iopause.h taia.h tai.h uint64.h \ +-taia.h ++taia.h iopause.h alloc.h str.h + ./compile server.c + + setup: \ +@@ -796,14 +862,26 @@ + compile socket_accept.c byte.h socket.h uint16.h + ./compile socket_accept.c + ++socket_accept6.o: \ ++compile socket_accept6.c byte.h socket.h uint16.h ++ ./compile socket_accept6.c ++ + socket_bind.o: \ + compile socket_bind.c byte.h socket.h uint16.h + ./compile socket_bind.c + ++socket_bind6.o: \ ++compile socket_bind6.c sockaddr_in6.h haveip6.h byte.h socket.h uint16.h uint32.h ip6.h error.h ++ ./compile socket_bind6.c ++ + socket_conn.o: \ + compile socket_conn.c byte.h socket.h uint16.h + ./compile socket_conn.c + ++socket_connect6.o: \ ++compile socket_connect6.c byte.h socket.h uint16.h uint32.h ++ ./compile socket_connect6.c ++ + socket_listen.o: \ + compile socket_listen.c socket.h uint16.h + ./compile socket_listen.c +@@ -812,18 +890,47 @@ + compile socket_recv.c byte.h socket.h uint16.h + ./compile socket_recv.c + ++socket_recv6.o: \ ++compile socket_recv6.c sockaddr_in6.h haveip6.h byte.h socket.h uint16.h uint32.h ip6.h error.h ++ ./compile socket_recv6.c ++ + socket_send.o: \ + compile socket_send.c byte.h socket.h uint16.h + ./compile socket_send.c + ++socket_send6.o: \ ++compile socket_send6.c byte.h socket.h uint16.h uint32.h ip6.h haveip6.h error.h ++ ./compile socket_send6.c ++ + socket_tcp.o: \ + compile socket_tcp.c ndelay.h socket.h uint16.h + ./compile socket_tcp.c + ++socket_tcp6.o: \ ++compile socket_tcp6.c ndelay.h socket.h uint16.h uint32.h haveip6.h ++ ./compile socket_tcp6.c ++ + socket_udp.o: \ + compile socket_udp.c ndelay.h socket.h uint16.h + ./compile socket_udp.c + ++socket_udp6.o: \ ++compile socket_udp6.c ndelay.h socket.h uint16.h uint32.h haveip6.h ++ ./compile socket_udp6.c ++ ++socket_noipv6.o: \ ++compile socket_noipv6.c haveip6.h ++ ./compile socket_noipv6.c ++ ++socket_getifidx.o: \ ++compile socket_getifidx.c socket.h uint16.h uint32.h haven2i.h ++ ./compile socket_getifidx.c ++ ++haven2i.h: \ ++tryn2i.c choose compile load socket.lib haven2i.h1 haven2i.h2 ++ cp /dev/null haven2i.h ++ ./choose cL tryn2i haven2i.h1 haven2i.h2 socket > haven2i.h ++ + str_chr.o: \ + compile str_chr.c str.h + ./compile str_chr.c +@@ -965,7 +1072,7 @@ + tdlookup.o: \ + compile tdlookup.c uint16.h open.h tai.h uint64.h cdb.h uint32.h \ + byte.h case.h dns.h stralloc.h gen_alloc.h iopause.h taia.h tai.h \ +-taia.h seek.h response.h uint32.h ++taia.h seek.h response.h uint32.h ip6.h clientloc.h + ./compile tdlookup.c + + timeoutread.o: \ +@@ -979,11 +1086,11 @@ + ./compile timeoutwrite.c + + tinydns: \ +-load tinydns.o server.o droproot.o tdlookup.o response.o qlog.o \ +-prot.o dns.a libtai.a env.a cdb.a alloc.a buffer.a unix.a byte.a \ ++load tinydns.o server.o iopause.o droproot.o tdlookup.o response.o qlog.o \ ++prot.o clientloc.o dns.a libtai.a env.a cdb.a alloc.a buffer.a unix.a byte.a \ + socket.lib +- ./load tinydns server.o droproot.o tdlookup.o response.o \ +- qlog.o prot.o dns.a libtai.a env.a cdb.a alloc.a buffer.a \ ++ ./load tinydns server.o iopause.o droproot.o tdlookup.o response.o \ ++ qlog.o prot.o clientloc.o dns.a libtai.a env.a cdb.a alloc.a buffer.a \ + unix.a byte.a `cat socket.lib` + + tinydns-conf: \ +@@ -1005,7 +1112,7 @@ + compile tinydns-data.c uint16.h uint32.h str.h byte.h fmt.h ip4.h \ + exit.h case.h scan.h buffer.h strerr.h getln.h buffer.h stralloc.h \ + gen_alloc.h cdb_make.h buffer.h uint32.h stralloc.h open.h dns.h \ +-stralloc.h iopause.h taia.h tai.h uint64.h taia.h ++stralloc.h iopause.h taia.h tai.h uint64.h taia.h ip6.h + ./compile tinydns-data.c + + tinydns-edit: \ +@@ -1020,9 +1127,9 @@ + + tinydns-get: \ + load tinydns-get.o tdlookup.o response.o printpacket.o printrecord.o \ +-parsetype.o dns.a libtai.a cdb.a buffer.a alloc.a unix.a byte.a ++parsetype.o clientloc.o dns.a libtai.a cdb.a buffer.a alloc.a unix.a byte.a + ./load tinydns-get tdlookup.o response.o printpacket.o \ +- printrecord.o parsetype.o dns.a libtai.a cdb.a buffer.a \ ++ printrecord.o parsetype.o clientloc.o dns.a libtai.a cdb.a buffer.a \ + alloc.a unix.a byte.a + + tinydns-get.o: \ +@@ -1068,12 +1175,18 @@ + makelib buffer_read.o buffer_write.o error.o error_str.o ndelay_off.o \ + ndelay_on.o open_read.o open_trunc.o openreadclose.o readclose.o \ + seek_set.o socket_accept.o socket_bind.o socket_conn.o \ +-socket_listen.o socket_recv.o socket_send.o socket_tcp.o socket_udp.o ++socket_listen.o socket_recv.o socket_send.o socket_tcp.o socket_udp.o \ ++socket_udp6.o socket_getifidx.o socket_recv6.o socket_send6.o \ ++socket_bind6.o socket_noipv6.o socket_tcp6.o socket_connect6.o \ ++socket_accept6.o + ./makelib unix.a buffer_read.o buffer_write.o error.o \ + error_str.o ndelay_off.o ndelay_on.o open_read.o \ + open_trunc.o openreadclose.o readclose.o seek_set.o \ + socket_accept.o socket_bind.o socket_conn.o socket_listen.o \ +- socket_recv.o socket_send.o socket_tcp.o socket_udp.o ++ socket_recv.o socket_send.o socket_tcp.o socket_udp.o \ ++ socket_udp6.o socket_getifidx.o socket_recv6.o socket_send6.o \ ++ socket_bind6.o socket_noipv6.o socket_tcp6.o socket_connect6.o \ ++ socket_accept6.o + + utime: \ + load utime.o byte.a +@@ -1084,10 +1197,10 @@ + ./compile utime.c + + walldns: \ +-load walldns.o server.o response.o droproot.o qlog.o prot.o dd.o \ ++load walldns.o server.o iopause.o response.o droproot.o qlog.o prot.o dd.o \ + dns.a env.a cdb.a alloc.a buffer.a unix.a byte.a socket.lib +- ./load walldns server.o response.o droproot.o qlog.o \ +- prot.o dd.o dns.a env.a cdb.a alloc.a buffer.a unix.a \ ++ ./load walldns server.o iopause.o response.o droproot.o qlog.o \ ++ prot.o dd.o dns.a libtai.a env.a cdb.a alloc.a buffer.a unix.a \ + byte.a `cat socket.lib` + + walldns-conf: \ +@@ -1104,3 +1217,14 @@ + compile walldns.c byte.h dns.h stralloc.h gen_alloc.h iopause.h \ + taia.h tai.h uint64.h taia.h dd.h response.h uint32.h + ./compile walldns.c ++ ++haveip6.h: \ ++tryip6.c choose compile haveip6.h1 haveip6.h2 ++ ./choose c tryip6 haveip6.h1 haveip6.h2 > haveip6.h ++ ++sockaddr_in6.h: \ ++trysa6.c choose compile sockaddr_in6.h1 sockaddr_in6.h2 haveip6.h ++ ./choose c trysa6 sockaddr_in6.h1 sockaddr_in6.h2 > sockaddr_in6.h ++ ++clean: ++ rm -f `cat TARGETS` +diff -uNr djbdns-1.05/README.ipv6 djbdns-1.05-ipv6/README.ipv6 +--- djbdns-1.05/README.ipv6 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/README.ipv6 2017-01-07 13:34:48.960745102 +0100 +@@ -0,0 +1,23 @@ ++The patch adds ipv6 transport support for djbdns. It would work for ++tinydns and dnscache. It requires IPv4 mapped addresses support enabled ++in the operating system (which is true for Linux and can be enabled for ++the BSDs except OpenBSD). ++ ++The log format changes to log the full IPv6 addresses in a non-standard, ++"flat" form, for example 00000000000000000000ffffc7fe1f01 (this is ++analogous to ::ffff:199.254.31.1). ++ ++The localization format of dnscache-data was amended to support IPv6. ++Instead of ++ ++ %in:192.168 ++ ++you need to use the above flat form with a prepended s for IPv6. The ++IPv4 form should still work unchanged. Note that the "data.cdb" file ++format changes for this and is not compatible. If you run an unpatched ++tinydns on it, it will not recognize any of the localization data. ++ ++dnscache will only try to lookup AAAA records for finding nameservers if ++the A record lookup failed. So IPv4 is default and stays like that, to ++not slow down DNS lookups by looking up all name servers as IPv6 and ++failing for all of them. +diff -uNr djbdns-1.05/TARGETS djbdns-1.05-ipv6/TARGETS +--- djbdns-1.05/TARGETS 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/TARGETS 2017-01-07 13:34:48.961745102 +0100 +@@ -20,6 +20,7 @@ + buffer.a + buffer_read.o + buffer_write.o ++clientloc.o + error.o + error_str.o + ndelay_off.o +@@ -102,6 +103,7 @@ + dns_dtda.o + dns_ip.o + dns_ipq.o ++dns_ipq6.o + dns_mx.o + dns_name.o + dns_nd.o +@@ -180,6 +182,8 @@ + dnsip + dnsipq.o + dnsipq ++dnsip6q.o ++dnsip6q + dnsname.o + dnsname + dnstxt.o +@@ -214,3 +218,25 @@ + it + setup + check ++scan_0x.o ++fmt_xlong.o ++ip6_scan.o ++ip6_fmt.o ++dnsip6.o ++dns_ip6.o ++dns_sortip6.o ++dnsip6 ++dns_nd6.o ++socket_udp6.o ++socket_getifidx.o ++socket_bind6.o ++socket_noipv6.o ++socket_recv6.o ++socket_send6.o ++haveip6.h ++haven2i.h ++sockaddr_in6.h ++scan_xlong.o ++socket_accept6.o ++socket_connect6.o ++socket_tcp6.o +diff -uNr djbdns-1.05/auto-str.c djbdns-1.05-ipv6/auto-str.c +--- djbdns-1.05/auto-str.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/auto-str.c 2017-01-07 13:54:25.159690277 +0100 +@@ -4,9 +4,10 @@ + char bspace[256]; + buffer b = BUFFER_INIT(buffer_unixwrite,1,bspace,sizeof bspace); + +-void puts(const char *s) ++int puts(const char *s) + { + if (buffer_puts(&b,s) == -1) _exit(111); ++ return 0; + } + + int main(int argc,char **argv) +diff -uNr djbdns-1.05/axfr-get.c djbdns-1.05-ipv6/axfr-get.c +--- djbdns-1.05/axfr-get.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/axfr-get.c 2017-01-07 13:34:48.961745102 +0100 +@@ -13,6 +13,7 @@ + #include "byte.h" + #include "str.h" + #include "ip4.h" ++#include "ip6.h" + #include "timeoutread.h" + #include "timeoutwrite.h" + #include "dns.h" +@@ -217,6 +218,14 @@ + x_copy(buf,len,pos,data,4); + if (!stralloc_catb(&line,ipstr,ip4_fmt(ipstr,data))) return 0; + } ++ else if (byte_equal(data,2,DNS_T_AAAA)) { ++ char ipstr[IP6_FMT]; ++ if (!stralloc_copys(&line,"3")) return 0; ++ if (!dns_domain_todot_cat(&line,d1)) return 0; ++ if (!stralloc_cats(&line,":")) return 0; ++ x_copy(buf,len,pos,data,16); ++ if (!stralloc_catb(&line,ipstr,ip6_fmt_flat(ipstr,data))) return 0; ++ } + else { + unsigned char ch; + unsigned char ch2; +diff -uNr djbdns-1.05/axfrdns.c djbdns-1.05-ipv6/axfrdns.c +--- djbdns-1.05/axfrdns.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/axfrdns.c 2017-01-07 13:34:48.961745102 +0100 +@@ -21,6 +21,8 @@ + #include "scan.h" + #include "qlog.h" + #include "response.h" ++#include "ip6.h" ++#include "clientloc.h" + + extern int respond(char *,char *,char *); + +@@ -123,7 +125,7 @@ + } + } + +-char ip[4]; ++char ip[16]; + unsigned long port; + char clientloc[2]; + +@@ -231,22 +233,11 @@ + + axfrcheck(zone); + ++ find_client_loc(clientloc, ip); ++ + tai_now(&now); + cdb_init(&c,fdcdb); + +- byte_zero(clientloc,2); +- key[0] = 0; +- key[1] = '%'; +- byte_copy(key + 2,4,ip); +- r = cdb_find(&c,key,6); +- if (!r) r = cdb_find(&c,key,5); +- if (!r) r = cdb_find(&c,key,4); +- if (!r) r = cdb_find(&c,key,3); +- if (!r) r = cdb_find(&c,key,2); +- if (r == -1) die_cdbread(); +- if (r && (cdb_datalen(&c) == 2)) +- if (cdb_read(&c,clientloc,2,cdb_datapos(&c)) == -1) die_cdbread(); +- + cdb_findstart(&c); + for (;;) { + r = cdb_findnext(&c,zone,zonelen); +@@ -328,10 +319,10 @@ + axfr = env_get("AXFR"); + + x = env_get("TCPREMOTEIP"); +- if (x && ip4_scan(x,ip)) ++ if (x && ip6_scan(x,ip)) + ; + else +- byte_zero(ip,4); ++ byte_zero(ip,16); + + x = env_get("TCPREMOTEPORT"); + if (!x) x = "0"; +diff -uNr djbdns-1.05/chkshsgr.c djbdns-1.05-ipv6/chkshsgr.c +--- djbdns-1.05/chkshsgr.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/chkshsgr.c 2017-01-07 13:55:13.391688029 +0100 +@@ -1,8 +1,11 @@ ++#include <sys/types.h> ++#include <unistd.h> ++#include <grp.h> + #include "exit.h" + + int main() + { +- short x[4]; ++ gid_t x[4]; + + x[0] = x[1] = 0; + if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1); +diff -uNr djbdns-1.05/clientloc.c djbdns-1.05-ipv6/clientloc.c +--- djbdns-1.05/clientloc.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/clientloc.c 2017-01-07 13:43:11.150721694 +0100 +@@ -0,0 +1,49 @@ ++#include "open.h" ++#include "byte.h" ++#include "cdb.h" ++#include "ip6.h" ++ ++#include <sys/types.h> ++#include <unistd.h> ++ ++int find_client_loc(char loc[2],const char ip[16]) ++{ ++ int r, fd; ++ char key[32+3]; ++ static struct cdb c; ++ ++ fd = open_read("data.cdb"); ++ if (fd == -1) return 0; ++ cdb_init(&c,fd); ++ ++ byte_zero(loc,2); ++ key[0] = 0; ++ key[1] = '%'; ++ if (byte_equal(ip,12,V4mappedprefix)) { ++ key[2] = 'f'; ++ byte_copy(key + 3,4,ip+12); ++ r = cdb_find(&c,key,7); ++ if (!r) r = cdb_find(&c,key,6); ++ if (!r) r = cdb_find(&c,key,5); ++ if (!r) r = cdb_find(&c,key,4); ++ if (!r) r = cdb_find(&c,key,3); ++ if (r == -1) return 0; ++ if (r && (cdb_datalen(&c) == 2)) ++ if (cdb_read(&c,loc,2,cdb_datapos(&c)) == -1) return 0; ++ } else { ++ unsigned int n; ++ key[2] = 's'; ++ ip6_fmt_flat(key+3,ip); ++ for (n=19; n>3; --n) { ++ r = cdb_find(&c,key,n); ++ if (r) break; ++ } ++ if (r == -1) return 0; ++ if (r && (cdb_datalen(&c) == 2)) ++ if (cdb_read(&c,loc,2,cdb_datapos(&c)) == -1) return 0; ++ } ++ ++ cdb_free(&c); ++ close(fd); ++ return r; ++} +diff -uNr djbdns-1.05/clientloc.h djbdns-1.05-ipv6/clientloc.h +--- djbdns-1.05/clientloc.h 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/clientloc.h 2017-01-07 13:34:48.961745102 +0100 +@@ -0,0 +1,6 @@ ++#ifndef CLIENTLOC_H ++#define CLIENTLOC_H ++ ++extern int find_client_loc(char loc[2],const char ip[16]); ++ ++#endif +diff -uNr djbdns-1.05/dns.h djbdns-1.05-ipv6/dns.h +--- djbdns-1.05/dns.h 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dns.h 2017-01-07 13:34:48.961745102 +0100 +@@ -35,7 +35,8 @@ + struct taia deadline; + unsigned int pos; + const char *servers; +- char localip[4]; ++ char localip[16]; ++ unsigned int scope_id; + char qtype[2]; + } ; + +@@ -43,6 +44,7 @@ + extern unsigned int dns_random(unsigned int); + + extern void dns_sortip(char *,unsigned int); ++extern void dns_sortip6(char *,unsigned int); + + extern void dns_domain_free(char **); + extern int dns_domain_copy(char **,const char *); +@@ -68,10 +70,13 @@ + + extern int dns_ip4_packet(stralloc *,const char *,unsigned int); + extern int dns_ip4(stralloc *,const stralloc *); ++extern int dns_ip6_packet(stralloc *,char *,unsigned int); ++extern int dns_ip6(stralloc *,stralloc *); + extern int dns_name_packet(stralloc *,const char *,unsigned int); + extern void dns_name4_domain(char *,const char *); + #define DNS_NAME4_DOMAIN 31 + extern int dns_name4(stralloc *,const char *); ++extern int dns_name6(stralloc *,const char *); + extern int dns_txt_packet(stralloc *,const char *,unsigned int); + extern int dns_txt(stralloc *,const stralloc *); + extern int dns_mx_packet(stralloc *,const char *,unsigned int); +@@ -80,5 +85,13 @@ + extern int dns_resolvconfrewrite(stralloc *); + extern int dns_ip4_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *); + extern int dns_ip4_qualify(stralloc *,stralloc *,const stralloc *); ++extern int dns_ip6_qualify_rules(stralloc *,stralloc *,const stralloc *,const stralloc *); ++extern int dns_ip6_qualify(stralloc *,stralloc *,const stralloc *); ++ ++#define DNS_IP6_INT 0 ++#define DNS_IP6_ARPA 1 ++ ++extern int dns_name6_domain(char *,const char *,int); ++#define DNS_NAME6_DOMAIN (4*16+11) + + #endif +diff -uNr djbdns-1.05/dns_ip6.c djbdns-1.05-ipv6/dns_ip6.c +--- djbdns-1.05/dns_ip6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/dns_ip6.c 2017-01-07 13:34:48.961745102 +0100 +@@ -0,0 +1,103 @@ ++#include "stralloc.h" ++#include "uint16.h" ++#include "byte.h" ++#include "dns.h" ++#include "ip4.h" ++#include "ip6.h" ++ ++static int dns_ip6_packet_add(stralloc *out,char *buf,unsigned int len) ++{ ++ unsigned int pos; ++ char header[16]; ++ uint16 numanswers; ++ uint16 datalen; ++ ++ pos = dns_packet_copy(buf,len,0,header,12); if (!pos) return -1; ++ uint16_unpack_big(header + 6,&numanswers); ++ pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; ++ pos += 4; ++ ++ while (numanswers--) { ++ pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; ++ pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) return -1; ++ uint16_unpack_big(header + 8,&datalen); ++ if (byte_equal(header,2,DNS_T_AAAA)) { ++ if (byte_equal(header + 2,2,DNS_C_IN)) ++ if (datalen == 16) { ++ if (!dns_packet_copy(buf,len,pos,header,16)) return -1; ++ if (!stralloc_catb(out,header,16)) return -1; ++ } ++ } else if (byte_equal(header,2,DNS_T_A)) ++ if (byte_equal(header + 2,2,DNS_C_IN)) ++ if (datalen == 4) { ++ byte_copy(header,12,V4mappedprefix); ++ if (!dns_packet_copy(buf,len,pos,header+12,4)) return -1; ++ if (!stralloc_catb(out,header,16)) return -1; ++ } ++ pos += datalen; ++ } ++ ++ dns_sortip6(out->s,out->len); ++ return 0; ++} ++ ++int dns_ip6_packet(stralloc *out,char *buf,unsigned int len) { ++ if (!stralloc_copys(out,"")) return -1; ++ return dns_ip6_packet_add(out,buf,len); ++} ++ ++static char *q = 0; ++ ++int dns_ip6(stralloc *out,stralloc *fqdn) ++{ ++ unsigned int i; ++ char code; ++ char ch; ++ char ip[16]; ++ ++ if (!stralloc_copys(out,"")) return -1; ++ if (!stralloc_readyplus(fqdn,1)) return -1; ++ fqdn->s[fqdn->len]=0; ++ if ((i=ip6_scan(fqdn->s,ip))) { ++ if (fqdn->s[i]) return -1; ++ stralloc_copyb(out,ip,16); ++ return 0; ++ } ++ code = 0; ++ for (i = 0;i <= fqdn->len;++i) { ++ if (i < fqdn->len) ++ ch = fqdn->s[i]; ++ else ++ ch = '.'; ++ ++ if ((ch == '[') || (ch == ']')) continue; ++ if (ch == '.') { ++ if (!stralloc_append(out,&code)) return -1; ++ code = 0; ++ continue; ++ } ++ if ((ch >= '0') && (ch <= '9')) { ++ code *= 10; ++ code += ch - '0'; ++ continue; ++ } ++ ++ if (!dns_domain_fromdot(&q,fqdn->s,fqdn->len)) return -1; ++ if (!stralloc_copys(out,"")) return -1; ++ if (dns_resolve(q,DNS_T_AAAA) != -1) ++ if (dns_ip6_packet_add(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) != -1) { ++ dns_transmit_free(&dns_resolve_tx); ++ dns_domain_free(&q); ++ } ++ if (!dns_domain_fromdot(&q,fqdn->s,fqdn->len)) return -1; ++ if (dns_resolve(q,DNS_T_A) != -1) ++ if (dns_ip6_packet_add(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) != -1) { ++ dns_transmit_free(&dns_resolve_tx); ++ dns_domain_free(&q); ++ } ++ return out->a>0?0:-1; ++ } ++ ++ out->len &= ~3; ++ return 0; ++} +diff -uNr djbdns-1.05/dns_ipq6.c djbdns-1.05-ipv6/dns_ipq6.c +--- djbdns-1.05/dns_ipq6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/dns_ipq6.c 2017-01-07 13:34:48.961745102 +0100 +@@ -0,0 +1,72 @@ ++#include "stralloc.h" ++#include "case.h" ++#include "byte.h" ++#include "str.h" ++#include "dns.h" ++ ++static int doit(stralloc *work,const char *rule) ++{ ++ char ch; ++ unsigned int colon; ++ unsigned int prefixlen; ++ ++ ch = *rule++; ++ if ((ch != '?') && (ch != '=') && (ch != '*') && (ch != '-')) return 1; ++ colon = str_chr(rule,':'); ++ if (!rule[colon]) return 1; ++ ++ if (work->len < colon) return 1; ++ prefixlen = work->len - colon; ++ if ((ch == '=') && prefixlen) return 1; ++ if (case_diffb(rule,colon,work->s + prefixlen)) return 1; ++ if (ch == '?') { ++ if (byte_chr(work->s,prefixlen,'.') < prefixlen) return 1; ++ if (byte_chr(work->s,prefixlen,':') < prefixlen) return 1; ++ if (byte_chr(work->s,prefixlen,'[') < prefixlen) return 1; ++ if (byte_chr(work->s,prefixlen,']') < prefixlen) return 1; ++ } ++ ++ work->len = prefixlen; ++ if (ch == '-') work->len = 0; ++ return stralloc_cats(work,rule + colon + 1); ++} ++ ++int dns_ip6_qualify_rules(stralloc *out,stralloc *fqdn,const stralloc *in,const stralloc *rules) ++{ ++ unsigned int i; ++ unsigned int j; ++ unsigned int plus; ++ unsigned int fqdnlen; ++ ++ if (!stralloc_copy(fqdn,in)) return -1; ++ ++ for (j = i = 0;j < rules->len;++j) ++ if (!rules->s[j]) { ++ if (!doit(fqdn,rules->s + i)) return -1; ++ i = j + 1; ++ } ++ ++ fqdnlen = fqdn->len; ++ plus = byte_chr(fqdn->s,fqdnlen,'+'); ++ if (plus >= fqdnlen) ++ return dns_ip6(out,fqdn); ++ ++ i = plus + 1; ++ for (;;) { ++ j = byte_chr(fqdn->s + i,fqdnlen - i,'+'); ++ byte_copy(fqdn->s + plus,j,fqdn->s + i); ++ fqdn->len = plus + j; ++ if (dns_ip6(out,fqdn) == -1) return -1; ++ if (out->len) return 0; ++ i += j; ++ if (i >= fqdnlen) return 0; ++ ++i; ++ } ++} ++ ++int dns_ip6_qualify(stralloc *out,stralloc *fqdn,const stralloc *in) ++{ ++ static stralloc rules; ++ if (dns_resolvconfrewrite(&rules) == -1) return -1; ++ return dns_ip6_qualify_rules(out,fqdn,in,&rules); ++} +diff -uNr djbdns-1.05/dns_name.c djbdns-1.05-ipv6/dns_name.c +--- djbdns-1.05/dns_name.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dns_name.c 2017-01-07 13:34:48.961745102 +0100 +@@ -2,6 +2,7 @@ + #include "uint16.h" + #include "byte.h" + #include "dns.h" ++#include "ip6.h" + + static char *q = 0; + +@@ -46,3 +47,24 @@ + dns_domain_free(&q); + return 0; + } ++ ++int dns_name6_inner(stralloc *out,const char ip[16],int t) ++{ ++ char name[DNS_NAME6_DOMAIN]; ++ ++ dns_name6_domain(name,ip,t); ++ if (dns_resolve(name,DNS_T_PTR) == -1) return -1; ++ if (dns_name_packet(out,dns_resolve_tx.packet,dns_resolve_tx.packetlen) == -1) return -1; ++ dns_transmit_free(&dns_resolve_tx); ++ dns_domain_free(&q); ++ return 0; ++} ++ ++int dns_name6(stralloc *out,const char ip[16]) ++{ ++ if (ip6_isv4mapped(ip)) ++ return dns_name4(out,ip+12); ++ if (dns_name6_inner(out,ip,DNS_IP6_ARPA)) return -1; ++ if (!out->len) return dns_name6_inner(out,ip,DNS_IP6_INT); ++ return 0; ++} +diff -uNr djbdns-1.05/dns_nd6.c djbdns-1.05-ipv6/dns_nd6.c +--- djbdns-1.05/dns_nd6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/dns_nd6.c 2017-01-07 13:34:48.961745102 +0100 +@@ -0,0 +1,35 @@ ++#include "byte.h" ++#include "fmt.h" ++#include "dns.h" ++ ++/* RFC1886: ++ * 4321:0:1:2:3:4:567:89ab ++ * -> ++ * b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.INT. ++ * b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.ARPA. ++ */ ++ ++extern char tohex(char num); ++ ++unsigned int mkint(unsigned char a,unsigned char b) { ++ return ((unsigned int)a << 8) + (unsigned int)b; ++} ++ ++int dns_name6_domain(char name[DNS_NAME6_DOMAIN],const char ip[16],int t) ++{ ++ unsigned int j; ++ ++ for (j=0; j<16; j++) { ++ name[j*4]=1; ++ name[j*4+1]=tohex(ip[15-j] & 15); ++ name[j*4+2]=1; ++ name[j*4+3]=tohex((unsigned char)ip[15-j] >> 4); ++ } ++ if (t==DNS_IP6_INT) ++ byte_copy(name + 4*16,9,"\3ip6\3int\0"); ++ else if (t==DNS_IP6_ARPA) ++ byte_copy(name + 4*16,10,"\3ip6\4arpa\0"); ++ else return 0; ++ return 4*16+9+t; ++} ++ +diff -uNr djbdns-1.05/dns_rcip.c djbdns-1.05-ipv6/dns_rcip.c +--- djbdns-1.05/dns_rcip.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dns_rcip.c 2017-01-07 13:34:48.961745102 +0100 +@@ -2,12 +2,13 @@ + #include "openreadclose.h" + #include "byte.h" + #include "ip4.h" ++#include "ip6.h" + #include "env.h" + #include "dns.h" + + static stralloc data = {0}; + +-static int init(char ip[64]) ++static int init(char ip[256]) + { + int i; + int j; +@@ -20,10 +21,10 @@ + if (*x == '.') + ++x; + else { +- i = ip4_scan(x,ip + iplen); ++ i = ip6_scan(x,ip + iplen); + if (!i) break; + x += i; +- iplen += 4; ++ iplen += 16; + } + } + +@@ -40,10 +41,8 @@ + while ((data.s[i] == ' ') || (data.s[i] == '\t')) + ++i; + if (iplen <= 60) +- if (ip4_scan(data.s + i,ip + iplen)) { +- if (byte_equal(ip + iplen,4,"\0\0\0\0")) +- byte_copy(ip + iplen,4,"\177\0\0\1"); +- iplen += 4; ++ if (ip6_scan(data.s + i,ip + iplen)) { ++ iplen += 16; + } + } + i = j + 1; +@@ -52,19 +51,19 @@ + } + + if (!iplen) { +- byte_copy(ip,4,"\177\0\0\1"); +- iplen = 4; ++ byte_copy(ip,16,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1"); ++ iplen = 16; + } +- byte_zero(ip + iplen,64 - iplen); ++ byte_zero(ip + iplen,256 - iplen); + return 0; + } + + static int ok = 0; + static unsigned int uses; + static struct taia deadline; +-static char ip[64]; /* defined if ok */ ++static char ip[256]; /* defined if ok */ + +-int dns_resolvconfip(char s[64]) ++int dns_resolvconfip(char s[256]) + { + struct taia now; + +@@ -81,6 +80,6 @@ + } + + --uses; +- byte_copy(s,64,ip); ++ byte_copy(s,256,ip); + return 0; + } +diff -uNr djbdns-1.05/dns_resolve.c djbdns-1.05-ipv6/dns_resolve.c +--- djbdns-1.05/dns_resolve.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dns_resolve.c 2017-01-07 13:34:48.961745102 +0100 +@@ -2,6 +2,7 @@ + #include "taia.h" + #include "byte.h" + #include "dns.h" ++#include "ip6.h" + + struct dns_transmit dns_resolve_tx = {0}; + +@@ -9,12 +10,12 @@ + { + struct taia stamp; + struct taia deadline; +- char servers[64]; ++ char servers[256]; + iopause_fd x[1]; + int r; + + if (dns_resolvconfip(servers) == -1) return -1; +- if (dns_transmit_start(&dns_resolve_tx,servers,1,q,qtype,"\0\0\0\0") == -1) return -1; ++ if (dns_transmit_start(&dns_resolve_tx,servers,1,q,qtype,V6any) == -1) return -1; + + for (;;) { + taia_now(&stamp); +diff -uNr djbdns-1.05/dns_sortip6.c djbdns-1.05-ipv6/dns_sortip6.c +--- djbdns-1.05/dns_sortip6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/dns_sortip6.c 2017-01-07 13:34:48.961745102 +0100 +@@ -0,0 +1,20 @@ ++#include "byte.h" ++#include "dns.h" ++ ++/* XXX: sort servers by configurable notion of closeness? */ ++/* XXX: pay attention to competence of each server? */ ++ ++void dns_sortip6(char *s,unsigned int n) ++{ ++ unsigned int i; ++ char tmp[16]; ++ ++ n >>= 4; ++ while (n > 1) { ++ i = dns_random(n); ++ --n; ++ byte_copy(tmp,16,s + (i << 4)); ++ byte_copy(s + (i << 4),16,s + (n << 4)); ++ byte_copy(s + (n << 4),16,tmp); ++ } ++} +diff -uNr djbdns-1.05/dns_transmit.c djbdns-1.05-ipv6/dns_transmit.c +--- djbdns-1.05/dns_transmit.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dns_transmit.c 2017-01-07 13:34:48.961745102 +0100 +@@ -7,6 +7,7 @@ + #include "byte.h" + #include "uint16.h" + #include "dns.h" ++#include "ip6.h" + + static int serverwantstcp(const char *buf,unsigned int len) + { +@@ -85,9 +86,9 @@ + int j; + + for (j = 0;j < 10;++j) +- if (socket_bind4(d->s1 - 1,d->localip,1025 + dns_random(64510)) == 0) ++ if (socket_bind6(d->s1 - 1,d->localip,1025 + dns_random(64510),d->scope_id) == 0) + return 0; +- if (socket_bind4(d->s1 - 1,d->localip,0) == 0) ++ if (socket_bind6(d->s1 - 1,d->localip,0,d->scope_id) == 0) + return 0; + return -1; + } +@@ -102,16 +103,16 @@ + + while (d->udploop < 4) { + for (;d->curserver < 16;++d->curserver) { +- ip = d->servers + 4 * d->curserver; +- if (byte_diff(ip,4,"\0\0\0\0")) { ++ ip = d->servers + 16 * d->curserver; ++ if (byte_diff(ip,16,V6any)) { + d->query[2] = dns_random(256); + d->query[3] = dns_random(256); + +- d->s1 = 1 + socket_udp(); ++ d->s1 = 1 + socket_udp6(); + if (!d->s1) { dns_transmit_free(d); return -1; } + if (randombind(d) == -1) { dns_transmit_free(d); return -1; } + +- if (socket_connect4(d->s1 - 1,ip,53) == 0) ++ if (socket_connect6(d->s1 - 1,ip,53,d->scope_id) == 0) + if (send(d->s1 - 1,d->query + 2,d->querylen - 2,0) == d->querylen - 2) { + struct taia now; + taia_now(&now); +@@ -153,19 +154,19 @@ + packetfree(d); + + for (;d->curserver < 16;++d->curserver) { +- ip = d->servers + 4 * d->curserver; +- if (byte_diff(ip,4,"\0\0\0\0")) { ++ ip = d->servers + 16 * d->curserver; ++ if (byte_diff(ip,16,V6any)) { + d->query[2] = dns_random(256); + d->query[3] = dns_random(256); + +- d->s1 = 1 + socket_tcp(); ++ d->s1 = 1 + socket_tcp6(); + if (!d->s1) { dns_transmit_free(d); return -1; } + if (randombind(d) == -1) { dns_transmit_free(d); return -1; } + + taia_now(&now); + taia_uint(&d->deadline,10); + taia_add(&d->deadline,&d->deadline,&now); +- if (socket_connect4(d->s1 - 1,ip,53) == 0) { ++ if (socket_connect6(d->s1 - 1,ip,53,d->scope_id) == 0) { + d->tcpstate = 2; + return 0; + } +@@ -193,7 +194,7 @@ + return thistcp(d); + } + +-int dns_transmit_start(struct dns_transmit *d,const char servers[64],int flagrecursive,const char *q,const char qtype[2],const char localip[4]) ++int dns_transmit_start(struct dns_transmit *d,const char servers[256],int flagrecursive,const char *q,const char qtype[2],const char localip[16]) + { + unsigned int len; + +@@ -213,7 +214,7 @@ + + byte_copy(d->qtype,2,qtype); + d->servers = servers; +- byte_copy(d->localip,4,localip); ++ byte_copy(d->localip,16,localip); + + d->udploop = flagrecursive ? 1 : 0; + +diff -uNr djbdns-1.05/dnscache.c djbdns-1.05-ipv6/dnscache.c +--- djbdns-1.05/dnscache.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dnscache.c 2017-01-07 13:41:19.342726906 +0100 +@@ -5,6 +5,7 @@ + #include "strerr.h" + #include "error.h" + #include "ip4.h" ++#include "ip6.h" + #include "uint16.h" + #include "uint64.h" + #include "socket.h" +@@ -22,6 +23,11 @@ + #include "log.h" + #include "okclient.h" + #include "droproot.h" ++#include "openreadclose.h" ++ ++long interface; ++ ++stralloc ignoreip = {0}; + + static int packetquery(char *buf,unsigned int len,char **q,char qtype[2],char qclass[2],char id[2]) + { +@@ -46,8 +52,8 @@ + } + + +-static char myipoutgoing[4]; +-static char myipincoming[4]; ++static char myipoutgoing[16]; ++static char myipincoming[16]; + static char buf[1024]; + uint64 numqueries = 0; + +@@ -60,9 +66,10 @@ + struct taia start; + uint64 active; /* query number, if active; otherwise 0 */ + iopause_fd *io; +- char ip[4]; ++ char ip[16]; + uint16 port; + char id[2]; ++ uint32 scope_id; + } u[MAXUDP]; + int uactive = 0; + +@@ -78,7 +85,7 @@ + if (!u[j].active) return; + response_id(u[j].id); + if (response_len > 512) response_tc(); +- socket_send4(udp53,response,response_len,u[j].ip,u[j].port); ++ socket_send6(udp53,response,response_len,u[j].ip,u[j].port,u[j].scope_id); + log_querydone(&u[j].active,response_len); + u[j].active = 0; --uactive; + } +@@ -109,7 +116,7 @@ + x = u + j; + taia_now(&x->start); + +- len = socket_recv4(udp53,buf,sizeof buf,x->ip,&x->port); ++ len = socket_recv6(udp53,buf,sizeof buf,x->ip,&x->port,&x->scope_id); + if (len == -1) return; + if (len >= sizeof buf) return; + if (x->port < 1024) if (x->port != 53) return; +@@ -119,7 +126,7 @@ + + x->active = ++numqueries; ++uactive; + log_query(&x->active,x->ip,x->port,x->id,q,qtype); +- switch(query_start(&x->q,q,qtype,qclass,myipoutgoing)) { ++ switch(query_start(&x->q,q,qtype,qclass,myipoutgoing,interface)) { + case -1: + u_drop(j); + return; +@@ -128,7 +135,6 @@ + } + } + +- + static int tcp53; + + #define MAXTCP 20 +@@ -138,7 +144,7 @@ + struct taia timeout; + uint64 active; /* query number or 1, if active; otherwise 0 */ + iopause_fd *io; +- char ip[4]; /* send response to this address */ ++ char ip[16]; /* send response to this address */ + uint16 port; /* send response to this port */ + char id[2]; + int tcp; /* open TCP socket, if active */ +@@ -146,6 +152,7 @@ + char *buf; /* 0, or dynamically allocated of length len */ + unsigned int len; + unsigned int pos; ++ uint32 scope_id; + } t[MAXTCP]; + int tactive = 0; + +@@ -254,7 +261,7 @@ + + x->active = ++numqueries; + log_query(&x->active,x->ip,x->port,x->id,q,qtype); +- switch(query_start(&x->q,q,qtype,qclass,myipoutgoing)) { ++ switch(query_start(&x->q,q,qtype,qclass,myipoutgoing,interface)) { + case -1: + t_drop(j); + return; +@@ -291,7 +298,7 @@ + x = t + j; + taia_now(&x->start); + +- x->tcp = socket_accept4(tcp53,x->ip,&x->port); ++ x->tcp = socket_accept6(tcp53,x->ip,&x->port,&x->scope_id); + if (x->tcp == -1) return; + if (x->port < 1024) if (x->port != 53) { close(x->tcp); return; } + if (!okclient(x->ip)) { close(x->tcp); return; } +@@ -389,24 +396,36 @@ + int main() + { + char *x; ++ unsigned int i, j, k; + unsigned long cachesize; ++ static stralloc sa = {0}; ++ ++ x = env_get("INTERFACE"); ++ if (x) scan_ulong(x,&interface); + + x = env_get("IP"); + if (!x) + strerr_die2x(111,FATAL,"$IP not set"); +- if (!ip4_scan(x,myipincoming)) ++ if (!ip6_scan(x,myipincoming)) + strerr_die3x(111,FATAL,"unable to parse IP address ",x); + +- udp53 = socket_udp(); ++#if 0 ++ /* if if IP is a mapped-IPv4 address, disable IPv6 functionality */ ++ /* this is actually a bad idea */ ++ if (ip6_isv4mapped(myipincoming)) ++ noipv6 = 1; ++#endif ++ ++ udp53 = socket_udp6(); + if (udp53 == -1) + strerr_die2sys(111,FATAL,"unable to create UDP socket: "); +- if (socket_bind4_reuse(udp53,myipincoming,53) == -1) ++ if (socket_bind6_reuse(udp53,myipincoming,53,interface) == -1) + strerr_die2sys(111,FATAL,"unable to bind UDP socket: "); + +- tcp53 = socket_tcp(); ++ tcp53 = socket_tcp6(); + if (tcp53 == -1) + strerr_die2sys(111,FATAL,"unable to create TCP socket: "); +- if (socket_bind4_reuse(tcp53,myipincoming,53) == -1) ++ if (socket_bind6_reuse(tcp53,myipincoming,53,interface) == -1) + strerr_die2sys(111,FATAL,"unable to bind TCP socket: "); + + droproot(FATAL); +@@ -421,7 +440,7 @@ + x = env_get("IPSEND"); + if (!x) + strerr_die2x(111,FATAL,"$IPSEND not set"); +- if (!ip4_scan(x,myipoutgoing)) ++ if (!ip6_scan(x,myipoutgoing)) + strerr_die3x(111,FATAL,"unable to parse IP address ",x); + + x = env_get("CACHESIZE"); +@@ -431,6 +450,20 @@ + if (!cache_init(cachesize)) + strerr_die3x(111,FATAL,"not enough memory for cache of size ",x); + ++ if (openreadclose("ignoreip",&sa,64) < 0) ++ strerr_die2x(111,FATAL,"trouble reading ignoreip"); ++ for(j = k = i = 0; i < sa.len; i++) ++ if (sa.s[i] == '\n') { ++ sa.s[i] = '\0'; ++ if (!stralloc_readyplus(&ignoreip,16)) ++ strerr_die2x(111,FATAL,"out of memory parsing ignoreip"); ++ if (!ip6_scan(sa.s+k,ignoreip.s+j)) ++ strerr_die3x(111,FATAL,"unable to parse address in ignoreip ",ignoreip.s+k); ++ j += 16; ++ k = i + 1; ++ } ++ ignoreip.len = j; ++ + if (env_get("HIDETTL")) + response_hidettl(); + if (env_get("FORWARDONLY")) +diff -uNr djbdns-1.05/dnsfilter.c djbdns-1.05-ipv6/dnsfilter.c +--- djbdns-1.05/dnsfilter.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dnsfilter.c 2017-01-07 13:34:48.962745102 +0100 +@@ -12,6 +12,7 @@ + #include "iopause.h" + #include "error.h" + #include "exit.h" ++#include "ip6.h" + + #define FATAL "dnsfilter: fatal: " + +@@ -44,7 +45,7 @@ + iopause_fd *io; + int iolen; + +-char servers[64]; ++char servers[256]; + char ip[4]; + char name[DNS_NAME4_DOMAIN]; + +@@ -191,7 +192,7 @@ + dns_name4_domain(name,ip); + if (dns_resolvconfip(servers) == -1) + strerr_die2sys(111,FATAL,"unable to read /etc/resolv.conf: "); +- if (dns_transmit_start(&x[xnum].dt,servers,1,name,DNS_T_PTR,"\0\0\0\0") == -1) ++ if (dns_transmit_start(&x[xnum].dt,servers,1,name,DNS_T_PTR,V6any) == -1) + errout(xnum); + else { + x[xnum].flagactive = 1; +diff -uNr djbdns-1.05/dnsip6.c djbdns-1.05-ipv6/dnsip6.c +--- djbdns-1.05/dnsip6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/dnsip6.c 2017-01-07 13:50:46.831700454 +0100 +@@ -0,0 +1,40 @@ ++#include "buffer.h" ++#include "exit.h" ++#include "strerr.h" ++#include "ip6.h" ++#include "dns.h" ++ ++#define FATAL "dnsip: fatal: " ++ ++static char seed[128]; ++ ++static stralloc fqdn; ++static stralloc out; ++char str[IP6_FMT]; ++ ++int main(int argc,char **argv) ++{ ++ int i; ++ ++ dns_random_init(seed); ++ ++ if (*argv) ++argv; ++ ++ while (*argv) { ++ if (!stralloc_copys(&fqdn,*argv)) ++ strerr_die2x(111,FATAL,"out of memory"); ++ if (dns_ip6(&out,&fqdn) == -1) ++ strerr_die4sys(111,FATAL,"unable to find IPv6 address for ",*argv,": "); ++ ++ for (i = 0;i + 16 <= out.len;i += 16) { ++ buffer_put(buffer_1,str,ip6_fmt(str,out.s + i)); ++ buffer_puts(buffer_1," "); ++ } ++ buffer_puts(buffer_1,"\n"); ++ ++ ++argv; ++ } ++ ++ buffer_flush(buffer_1); ++ _exit(0); ++} +diff -uNr djbdns-1.05/dnsip6q.c djbdns-1.05-ipv6/dnsip6q.c +--- djbdns-1.05/dnsip6q.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/dnsip6q.c 2017-01-07 13:34:48.962745102 +0100 +@@ -0,0 +1,43 @@ ++#include "buffer.h" ++#include "exit.h" ++#include "strerr.h" ++#include "ip6.h" ++#include "dns.h" ++ ++#define FATAL "dnsipq: fatal: " ++ ++static char seed[128]; ++ ++static stralloc in; ++static stralloc fqdn; ++static stralloc out; ++char str[IP6_FMT]; ++ ++int main(int argc,char **argv) ++{ ++ int i; ++ ++ dns_random_init(seed); ++ ++ if (*argv) ++argv; ++ ++ while (*argv) { ++ if (!stralloc_copys(&in,*argv)) ++ strerr_die2x(111,FATAL,"out of memory"); ++ if (dns_ip6_qualify(&out,&fqdn,&in) == -1) ++ strerr_die4sys(111,FATAL,"unable to find IP6 address for ",*argv,": "); ++ ++ buffer_put(buffer_1,fqdn.s,fqdn.len); ++ buffer_puts(buffer_1," "); ++ for (i = 0;i + 16 <= out.len;i += 16) { ++ buffer_put(buffer_1,str,ip6_fmt(str,out.s + i)); ++ buffer_puts(buffer_1," "); ++ } ++ buffer_puts(buffer_1,"\n"); ++ ++ ++argv; ++ } ++ ++ buffer_flush(buffer_1); ++ _exit(0); ++} +diff -uNr djbdns-1.05/dnsname.c djbdns-1.05-ipv6/dnsname.c +--- djbdns-1.05/dnsname.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dnsname.c 2017-01-07 13:34:48.962745102 +0100 +@@ -2,6 +2,7 @@ + #include "exit.h" + #include "strerr.h" + #include "ip4.h" ++#include "ip6.h" + #include "dns.h" + + #define FATAL "dnsname: fatal: " +@@ -9,6 +10,7 @@ + static char seed[128]; + + char ip[4]; ++char ip6[16]; + static stralloc out; + + int main(int argc,char **argv) +@@ -18,10 +20,15 @@ + if (*argv) ++argv; + + while (*argv) { +- if (!ip4_scan(*argv,ip)) +- strerr_die3x(111,FATAL,"unable to parse IP address ",*argv); +- if (dns_name4(&out,ip) == -1) +- strerr_die4sys(111,FATAL,"unable to find host name for ",*argv,": "); ++ if (ip6_scan(*argv,ip6)) { ++ if (dns_name6(&out,ip6) == -1) ++ strerr_die4sys(111,FATAL,"unable to find host name for ",*argv,": "); ++ } else { ++ if (!ip4_scan(*argv,ip)) ++ strerr_die3x(111,FATAL,"unable to parse IP address ",*argv); ++ if (dns_name4(&out,ip) == -1) ++ strerr_die4sys(111,FATAL,"unable to find host name for ",*argv,": "); ++ } + + buffer_put(buffer_1,out.s,out.len); + buffer_puts(buffer_1,"\n"); +diff -uNr djbdns-1.05/dnsq.c djbdns-1.05-ipv6/dnsq.c +--- djbdns-1.05/dnsq.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dnsq.c 2017-01-07 13:56:39.399684020 +0100 +@@ -10,6 +10,8 @@ + #include "printpacket.h" + #include "parsetype.h" + #include "dns.h" ++#include "ip6.h" ++#include "exit.h" + + #define FATAL "dnsq: fatal: " + +@@ -24,14 +26,14 @@ + + static struct dns_transmit tx; + +-int resolve(char *q,char qtype[2],char servers[64]) ++int resolve(char *q,char qtype[2],char servers[256]) + { + struct taia stamp; + struct taia deadline; + iopause_fd x[1]; + int r; + +- if (dns_transmit_start(&tx,servers,0,q,qtype,"\0\0\0\0") == -1) return -1; ++ if (dns_transmit_start(&tx,servers,0,q,qtype,V6any) == -1) return -1; + + for (;;) { + taia_now(&stamp); +@@ -47,7 +49,7 @@ + return 0; + } + +-char servers[64]; ++char servers[256]; + static stralloc ip; + static stralloc fqdn; + +@@ -73,9 +75,9 @@ + + if (!*++argv) usage(); + if (!stralloc_copys(&out,*argv)) oops(); +- if (dns_ip4_qualify(&ip,&fqdn,&out) == -1) oops(); +- if (ip.len >= 64) ip.len = 64; +- byte_zero(servers,64); ++ if (dns_ip6_qualify(&ip,&fqdn,&out) == -1) oops(); ++ if (ip.len >= 256) ip.len = 256; ++ byte_zero(servers,256); + byte_copy(servers,ip.len,ip.s); + + if (!stralloc_copys(&out,"")) oops(); +diff -uNr djbdns-1.05/dnsqr.c djbdns-1.05-ipv6/dnsqr.c +--- djbdns-1.05/dnsqr.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dnsqr.c 2017-01-07 13:56:33.511684294 +0100 +@@ -9,6 +9,7 @@ + #include "printpacket.h" + #include "parsetype.h" + #include "dns.h" ++#include "exit.h" + + #define FATAL "dnsqr: fatal: " + +diff -uNr djbdns-1.05/dnstrace.c djbdns-1.05-ipv6/dnstrace.c +--- djbdns-1.05/dnstrace.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/dnstrace.c 2017-01-07 13:50:02.183702535 +0100 +@@ -4,6 +4,7 @@ + #include "str.h" + #include "byte.h" + #include "ip4.h" ++#include "ip6.h" + #include "gen_alloc.h" + #include "gen_allocdefs.h" + #include "exit.h" +@@ -30,7 +31,7 @@ + } + + static stralloc querystr; +-char ipstr[IP4_FMT]; ++char ipstr[IP6_FMT]; + static stralloc tmp; + + void printdomain(const char *d) +@@ -42,21 +43,21 @@ + + static struct dns_transmit tx; + +-int resolve(char *q,char qtype[2],char ip[4]) ++int resolve(char *q,char qtype[2],char ip[16]) + { + struct taia start; + struct taia stamp; + struct taia deadline; +- char servers[64]; ++ char servers[256]; + iopause_fd x[1]; + int r; + + taia_now(&start); + +- byte_zero(servers,64); +- byte_copy(servers,4,ip); ++ byte_zero(servers,256); ++ byte_copy(servers,16,ip); + +- if (dns_transmit_start(&tx,servers,0,q,qtype,"\0\0\0\0") == -1) return -1; ++ if (dns_transmit_start(&tx,servers,0,q,qtype,V6any) == -1) return -1; + + for (;;) { + taia_now(&stamp); +@@ -82,7 +83,7 @@ + + struct address { + char *owner; +- char ip[4]; ++ char ip[16]; + } ; + + GEN_ALLOC_typedef(address_alloc,struct address,s,len,a) +@@ -117,7 +118,7 @@ + char *owner; + char type[2]; + char *control; +- char ip[4]; ++ char ip[16]; + } ; + + GEN_ALLOC_typedef(qt_alloc,struct qt,s,len,a) +@@ -126,7 +127,7 @@ + + static qt_alloc qt; + +-void qt_add(const char *q,const char type[2],const char *control,const char ip[4]) ++void qt_add(const char *q,const char type[2],const char *control,const char ip[16]) + { + struct qt x; + int i; +@@ -137,14 +138,14 @@ + if (dns_domain_equal(qt.s[i].owner,q)) + if (dns_domain_equal(qt.s[i].control,control)) + if (byte_equal(qt.s[i].type,2,type)) +- if (byte_equal(qt.s[i].ip,4,ip)) ++ if (byte_equal(qt.s[i].ip,16,ip)) + return; + + byte_zero(&x,sizeof x); + if (!dns_domain_copy(&x.owner,q)) nomem(); + if (!dns_domain_copy(&x.control,control)) nomem(); + byte_copy(x.type,2,type); +- byte_copy(x.ip,4,ip); ++ byte_copy(x.ip,16,ip); + if (!qt_alloc_append(&qt,&x)) nomem(); + } + +@@ -203,7 +204,7 @@ + qt_add(query.s[i].owner,query.s[i].type,owner,address.s[j].ip); + } + +-void address_add(const char *owner,const char ip[4]) ++void address_add(const char *owner,const char ip[16]) + { + struct address x; + int i; +@@ -213,17 +214,20 @@ + buffer_puts(buffer_1,"A:"); + printdomain(owner); + buffer_puts(buffer_1,":"); +- buffer_put(buffer_1,ipstr,ip4_fmt(ipstr,ip)); ++ if (ip6_isv4mapped(ip)) ++ buffer_put(buffer_1,ipstr,ip4_fmt(ipstr,ip+12)); ++ else ++ buffer_put(buffer_1,ipstr,ip6_fmt(ipstr,ip)); + buffer_puts(buffer_1,"\n"); + + for (i = 0;i < address.len;++i) + if (dns_domain_equal(address.s[i].owner,owner)) +- if (byte_equal(address.s[i].ip,4,ip)) ++ if (byte_equal(address.s[i].ip,16,ip)) + return; + + byte_zero(&x,sizeof x); + if (!dns_domain_copy(&x.owner,owner)) nomem(); +- byte_copy(x.ip,4,ip); ++ byte_copy(x.ip,16,ip); + if (!address_alloc_append(&address,&x)) nomem(); + + for (i = 0;i < ns.len;++i) +@@ -253,9 +257,7 @@ + uint16 numanswers; + unsigned int posanswers; + uint16 numauthority; +- unsigned int posauthority; + uint16 numglue; +- unsigned int posglue; + uint16 datalen; + unsigned int rcode; + int flagout; +@@ -295,7 +297,6 @@ + uint16_unpack_big(header + 8,&datalen); + pos += datalen; + } +- posauthority = pos; + for (j = 0;j < numauthority;++j) { + pos = dns_packet_getname(buf,len,pos,&t1); if (!pos) goto DIE; + pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) goto DIE; +@@ -308,7 +309,6 @@ + uint16_unpack_big(header + 8,&datalen); + pos += datalen; + } +- posglue = pos; + + if (!flagcname && !rcode && !flagout && flagreferral && !flagsoa) + if (dns_domain_equal(referral,control) || !dns_domain_suffix(referral,control)) { +@@ -331,7 +331,12 @@ + ns_add(t1,t2); + } + else if (typematch(header,DNS_T_A) && datalen == 4) { +- if (!dns_packet_copy(buf,len,pos,misc,4)) goto DIE; ++ if (!dns_packet_copy(buf,len,pos,misc+12,4)) goto DIE; ++ byte_copy(misc,12,V4mappedprefix); ++ address_add(t1,misc); ++ } ++ else if (typematch(header,DNS_T_AAAA) && datalen == 16) { ++ if (!dns_packet_copy(buf,len,pos,misc,16)) goto DIE; + address_add(t1,misc); + } + } +@@ -419,8 +424,8 @@ + + while (*++argv) { + if (!stralloc_copys(&udn,*argv)) nomem(); +- if (dns_ip4_qualify(&out,&fqdn,&udn) == -1) nomem(); /* XXX */ +- for (i = 0;i + 4 <= out.len;i += 4) ++ if (dns_ip6_qualify(&out,&fqdn,&udn) == -1) nomem(); /* XXX */ ++ for (i = 0;i + 16 <= out.len;i += 16) + address_add("",out.s + i); + } + +@@ -429,7 +434,7 @@ + control = qt.s[i].control; + if (!dns_domain_suffix(q,control)) continue; + byte_copy(type,2,qt.s[i].type); +- byte_copy(ip,4,qt.s[i].ip); ++ byte_copy(ip,16,qt.s[i].ip); + + if (!stralloc_copys(&querystr,"")) nomem(); + uint16_unpack_big(type,&u16); +@@ -439,7 +444,10 @@ + if (!stralloc_cats(&querystr,":")) nomem(); + if (!dns_domain_todot_cat(&querystr,control)) nomem(); + if (!stralloc_cats(&querystr,":")) nomem(); +- if (!stralloc_catb(&querystr,ipstr,ip4_fmt(ipstr,ip))) nomem(); ++ if (ip6_isv4mapped(ip)) { ++ if (!stralloc_catb(&querystr,ipstr,ip4_fmt(ipstr,ip+12))) nomem(); ++ } else ++ if (!stralloc_catb(&querystr,ipstr,ip6_fmt(ipstr,ip))) nomem(); + if (!stralloc_cats(&querystr,":")) nomem(); + + buffer_put(buffer_1,querystr.s,querystr.len); +diff -uNr djbdns-1.05/error.h djbdns-1.05-ipv6/error.h +--- djbdns-1.05/error.h 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/error.h 2017-01-07 13:34:48.962745102 +0100 +@@ -1,7 +1,7 @@ + #ifndef ERROR_H + #define ERROR_H + +-extern int errno; ++#include <errno.h> + + extern int error_intr; + extern int error_nomem; +diff -uNr djbdns-1.05/exit.h djbdns-1.05-ipv6/exit.h +--- djbdns-1.05/exit.h 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/exit.h 2017-01-07 13:49:44.471703361 +0100 +@@ -1,6 +1,6 @@ + #ifndef EXIT_H + #define EXIT_H + +-extern void _exit(); ++extern void _exit(int status); + + #endif +diff -uNr djbdns-1.05/fmt_xlong.c djbdns-1.05-ipv6/fmt_xlong.c +--- djbdns-1.05/fmt_xlong.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/fmt_xlong.c 2017-01-07 13:34:48.962745102 +0100 +@@ -0,0 +1,22 @@ ++#include "fmt.h" ++ ++char tohex(char num) { ++ if (num<10) ++ return num+'0'; ++ else if (num<16) ++ return num-10+'a'; ++ else ++ return -1; ++} ++ ++unsigned int fmt_xlong(register char *s,register unsigned long u) ++{ ++ register unsigned int len; register unsigned long q; ++ len = 1; q = u; ++ while (q > 15) { ++len; q /= 16; } ++ if (s) { ++ s += len; ++ do { *--s = tohex(u % 16); u /= 16; } while(u); /* handles u == 0 */ ++ } ++ return len; ++} +diff -uNr djbdns-1.05/haveip6.h1 djbdns-1.05-ipv6/haveip6.h1 +--- djbdns-1.05/haveip6.h1 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/haveip6.h1 2017-01-07 13:34:48.962745102 +0100 +@@ -0,0 +1 @@ ++ +diff -uNr djbdns-1.05/haveip6.h2 djbdns-1.05-ipv6/haveip6.h2 +--- djbdns-1.05/haveip6.h2 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/haveip6.h2 2017-01-07 13:34:48.962745102 +0100 +@@ -0,0 +1 @@ ++#define LIBC_HAS_IP6 1 +diff -uNr djbdns-1.05/haven2i.h1 djbdns-1.05-ipv6/haven2i.h1 +--- djbdns-1.05/haven2i.h1 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/haven2i.h1 2017-01-07 13:34:48.962745102 +0100 +@@ -0,0 +1 @@ ++#undef HAVE_N2I +diff -uNr djbdns-1.05/haven2i.h2 djbdns-1.05-ipv6/haven2i.h2 +--- djbdns-1.05/haven2i.h2 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/haven2i.h2 2017-01-07 13:34:48.962745102 +0100 +@@ -0,0 +1 @@ ++#define HAVE_N2I +diff -uNr djbdns-1.05/hier.c djbdns-1.05-ipv6/hier.c +--- djbdns-1.05/hier.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/hier.c 2017-01-07 13:53:17.559693428 +0100 +@@ -1,5 +1,9 @@ + #include "auto_home.h" + ++extern void h(const char* home,int uid,int gid,int mode); ++extern void d(const char* home,const char* subdir,int uid,int gid,int mode); ++extern void c(const char* home,const char* subdir,const char* file,int uid,int gid,int mode); ++ + void hier() + { + c("/","etc","dnsroots.global",-1,-1,0644); +@@ -29,7 +33,9 @@ + c(auto_home,"bin","axfr-get",-1,-1,0755); + + c(auto_home,"bin","dnsip",-1,-1,0755); ++ c(auto_home,"bin","dnsip6",-1,-1,0755); + c(auto_home,"bin","dnsipq",-1,-1,0755); ++ c(auto_home,"bin","dnsip6q",-1,-1,0755); + c(auto_home,"bin","dnsname",-1,-1,0755); + c(auto_home,"bin","dnstxt",-1,-1,0755); + c(auto_home,"bin","dnsmx",-1,-1,0755); +diff -uNr djbdns-1.05/ip6.h djbdns-1.05-ipv6/ip6.h +--- djbdns-1.05/ip6.h 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/ip6.h 2017-01-07 13:34:48.962745102 +0100 +@@ -0,0 +1,28 @@ ++#ifndef IP6_H ++#define IP6_H ++ ++extern unsigned int ip6_scan(const char *,char *); ++extern unsigned int ip6_fmt(char *,const char *); ++ ++extern unsigned int ip6_scan_flat(const char *,char *); ++extern unsigned int ip6_fmt_flat(char *,const char *); ++ ++/* ++ ip6 address syntax: (h = hex digit), no leading '0' required ++ 1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh ++ 2. any number of 0000 may be abbreviated as "::", but only once ++ flat ip6 address syntax: ++ hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh ++ */ ++ ++#define IP6_FMT 40 ++ ++const static unsigned char V4mappedprefix[12]={0,0,0,0,0,0,0,0,0,0,0xff,0xff}; ++const static unsigned char V6loopback[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; ++const static unsigned char V6any[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; ++ ++#define ip6_isv4mapped(ip) (byte_equal(ip,12,V4mappedprefix)) ++ ++const static char ip4loopback[4] = {127,0,0,1}; ++ ++#endif +diff -uNr djbdns-1.05/ip6_fmt.c djbdns-1.05-ipv6/ip6_fmt.c +--- djbdns-1.05/ip6_fmt.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/ip6_fmt.c 2017-01-07 13:34:48.962745102 +0100 +@@ -0,0 +1,60 @@ ++#include "fmt.h" ++#include "byte.h" ++#include "ip4.h" ++#include "ip6.h" ++#include <stdio.h> ++ ++extern char tohex(char num); ++ ++unsigned int ip6_fmt(char *s,const char ip[16]) ++{ ++ unsigned int len; ++ unsigned int i; ++ unsigned int temp; ++ unsigned int compressing; ++ unsigned int compressed; ++ int j; ++ ++ len = 0; compressing = 0; compressed = 0; ++ for (j=0; j<16; j+=2) { ++ if (j==12 && ip6_isv4mapped(ip)) { ++ temp=ip4_fmt(s,ip+12); ++ len+=temp; ++ break; ++ } ++ temp = ((unsigned long) (unsigned char) ip[j] << 8) + ++ (unsigned long) (unsigned char) ip[j+1]; ++ if (temp == 0 && !compressed) { ++ if (!compressing) { ++ compressing=1; ++ if (j==0) { ++ if (s) *s++=':'; ++len; ++ } ++ } ++ } else { ++ if (compressing) { ++ compressing=0; ++compressed; ++ if (s) *s++=':'; ++len; ++ } ++ i = fmt_xlong(s,temp); len += i; if (s) s += i; ++ if (j<14) { ++ if (s) *s++ = ':'; ++ ++len; ++ } ++ } ++ } ++ if (compressing) { *s++=':'; ++len; } ++ ++/* if (s) *s=0; */ ++ return len; ++} ++ ++unsigned int ip6_fmt_flat(char *s,const char ip[16]) ++{ ++ int i; ++ for (i=0; i<16; i++) { ++ *s++=tohex((unsigned char)ip[i] >> 4); ++ *s++=tohex((unsigned char)ip[i] & 15); ++ } ++ return 32; ++} +diff -uNr djbdns-1.05/ip6_scan.c djbdns-1.05-ipv6/ip6_scan.c +--- djbdns-1.05/ip6_scan.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/ip6_scan.c 2017-01-07 13:34:48.962745102 +0100 +@@ -0,0 +1,115 @@ ++#include "scan.h" ++#include "ip4.h" ++#include "ip6.h" ++#include "byte.h" ++ ++/* ++ * IPv6 addresses are really ugly to parse. ++ * Syntax: (h = hex digit) ++ * 1. hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh ++ * 2. any number of 0000 may be abbreviated as "::", but only once ++ * 3. The last two words may be written as IPv4 address ++ */ ++ ++unsigned int ip6_scan(const char *s,char ip[16]) ++{ ++ unsigned int i; ++ unsigned int len=0; ++ unsigned long u; ++ ++ char suffix[16]; ++ int prefixlen=0; ++ int suffixlen=0; ++ ++ if ((i=ip4_scan(s,ip+12))) { ++ const char *c=V4mappedprefix; ++ if (byte_equal(ip+12,4,V6any)) c=V6any; ++ for (len=0; len<12; ++len) ip[len]=c[len]; ++ return i; ++ } ++ for (i=0; i<16; i++) ip[i]=0; ++ for (;;) { ++ if (*s == ':') { ++ len++; ++ if (s[1] == ':') { /* Found "::", skip to part 2 */ ++ s+=2; ++ len++; ++ break; ++ } ++ s++; ++ } ++ i = scan_xlong(s,&u); ++ if (!i) return 0; ++ if (prefixlen==12 && s[i]=='.') { ++ /* the last 4 bytes may be written as IPv4 address */ ++ i=ip4_scan(s,ip+12); ++ if (i) ++ return i+len; ++ else ++ return 0; ++ } ++ ip[prefixlen++] = (u >> 8); ++ ip[prefixlen++] = (u & 255); ++ s += i; len += i; ++ if (prefixlen==16) ++ return len; ++ } ++ ++/* part 2, after "::" */ ++ for (;;) { ++ if (*s == ':') { ++ if (suffixlen==0) ++ break; ++ s++; ++ len++; ++ } else if (suffixlen!=0) ++ break; ++ i = scan_xlong(s,&u); ++ if (!i) { ++ len--; ++ break; ++ } ++ if (suffixlen+prefixlen<=12 && s[i]=='.') { ++ int j=ip4_scan(s,suffix+suffixlen); ++ if (j) { ++ suffixlen+=4; ++ len+=j; ++ break; ++ } else ++ prefixlen=12-suffixlen; /* make end-of-loop test true */ ++ } ++ suffix[suffixlen++] = (u >> 8); ++ suffix[suffixlen++] = (u & 255); ++ s += i; len += i; ++ if (prefixlen+suffixlen==16) ++ break; ++ } ++ for (i=0; i<suffixlen; i++) ++ ip[16-suffixlen+i] = suffix[i]; ++ return len; ++} ++ ++static long int fromhex(unsigned char c) { ++ if (c>='0' && c<='9') ++ return c-'0'; ++ else if (c>='A' && c<='F') ++ return c-'A'+10; ++ else if (c>='a' && c<='f') ++ return c-'a'+10; ++ return -1; ++} ++ ++unsigned int ip6_scan_flat(const char *s,char ip[16]) ++{ ++ int i; ++ for (i=0; i<16; i++) { ++ int tmp; ++ tmp=fromhex(*s++); ++ if (tmp<0) return 0; ++ ip[i]=tmp << 4; ++ tmp=fromhex(*s++); ++ if (tmp<0) return 0; ++ ip[i]+=tmp; ++ } ++ return 32; ++} +diff -uNr djbdns-1.05/log.c djbdns-1.05-ipv6/log.c +--- djbdns-1.05/log.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/log.c 2017-01-07 13:34:48.962745102 +0100 +@@ -3,6 +3,7 @@ + #include "uint16.h" + #include "error.h" + #include "byte.h" ++#include "ip6.h" + #include "log.h" + + /* work around gcc 2.95.2 bug */ +@@ -45,12 +46,10 @@ + string(" "); + } + +-static void ip(const char i[4]) ++static void ip(const char i[16]) + { +- hex(i[0]); +- hex(i[1]); +- hex(i[2]); +- hex(i[3]); ++ int j; ++ for (j=0; j<16; ++j) hex(i[j]); + } + + static void logid(const char id[2]) +@@ -94,7 +93,7 @@ + line(); + } + +-void log_query(uint64 *qnum,const char client[4],unsigned int port,const char id[2],const char *q,const char qtype[2]) ++void log_query(uint64 *qnum,const char client[16],unsigned int port,const char id[2],const char *q,const char qtype[2]) + { + string("query "); number(*qnum); space(); + ip(client); string(":"); hex(port >> 8); hex(port & 255); +@@ -119,14 +118,14 @@ + line(); + } + +-void log_tcpopen(const char client[4],unsigned int port) ++void log_tcpopen(const char client[16],unsigned int port) + { + string("tcpopen "); + ip(client); string(":"); hex(port >> 8); hex(port & 255); + line(); + } + +-void log_tcpclose(const char client[4],unsigned int port) ++void log_tcpclose(const char client[16],unsigned int port) + { + const char *x = error_str(errno); + string("tcpclose "); +@@ -135,15 +134,15 @@ + line(); + } + +-void log_tx(const char *q,const char qtype[2],const char *control,const char servers[64],unsigned int gluelessness) ++void log_tx(const char *q,const char qtype[2],const char *control,const char servers[256],unsigned int gluelessness) + { + int i; + + string("tx "); number(gluelessness); space(); + logtype(qtype); space(); name(q); space(); + name(control); +- for (i = 0;i < 64;i += 4) +- if (byte_diff(servers + i,4,"\0\0\0\0")) { ++ for (i = 0;i < 256;i += 16) ++ if (byte_diff(servers + i,16,V6any)) { + space(); + ip(servers + i); + } +@@ -175,21 +174,21 @@ + line(); + } + +-void log_nxdomain(const char server[4],const char *q,unsigned int ttl) ++void log_nxdomain(const char server[16],const char *q,unsigned int ttl) + { + string("nxdomain "); ip(server); space(); number(ttl); space(); + name(q); + line(); + } + +-void log_nodata(const char server[4],const char *q,const char qtype[2],unsigned int ttl) ++void log_nodata(const char server[16],const char *q,const char qtype[2],unsigned int ttl) + { + string("nodata "); ip(server); space(); number(ttl); space(); + logtype(qtype); space(); name(q); + line(); + } + +-void log_lame(const char server[4],const char *control,const char *referral) ++void log_lame(const char server[16],const char *control,const char *referral) + { + string("lame "); ip(server); space(); + name(control); space(); name(referral); +@@ -205,7 +204,7 @@ + line(); + } + +-void log_rr(const char server[4],const char *q,const char type[2],const char *buf,unsigned int len,unsigned int ttl) ++void log_rr(const char server[16],const char *q,const char type[2],const char *buf,unsigned int len,unsigned int ttl) + { + int i; + +@@ -222,7 +221,7 @@ + line(); + } + +-void log_rrns(const char server[4],const char *q,const char *data,unsigned int ttl) ++void log_rrns(const char server[16],const char *q,const char *data,unsigned int ttl) + { + string("rr "); ip(server); space(); number(ttl); + string(" ns "); name(q); space(); +@@ -230,7 +229,7 @@ + line(); + } + +-void log_rrcname(const char server[4],const char *q,const char *data,unsigned int ttl) ++void log_rrcname(const char server[16],const char *q,const char *data,unsigned int ttl) + { + string("rr "); ip(server); space(); number(ttl); + string(" cname "); name(q); space(); +@@ -238,7 +237,7 @@ + line(); + } + +-void log_rrptr(const char server[4],const char *q,const char *data,unsigned int ttl) ++void log_rrptr(const char server[16],const char *q,const char *data,unsigned int ttl) + { + string("rr "); ip(server); space(); number(ttl); + string(" ptr "); name(q); space(); +@@ -246,7 +245,7 @@ + line(); + } + +-void log_rrmx(const char server[4],const char *q,const char *mx,const char pref[2],unsigned int ttl) ++void log_rrmx(const char server[16],const char *q,const char *mx,const char pref[2],unsigned int ttl) + { + uint16 u; + +@@ -257,7 +256,7 @@ + line(); + } + +-void log_rrsoa(const char server[4],const char *q,const char *n1,const char *n2,const char misc[20],unsigned int ttl) ++void log_rrsoa(const char server[16],const char *q,const char *n1,const char *n2,const char misc[20],unsigned int ttl) + { + uint32 u; + int i; +diff -uNr djbdns-1.05/okclient.c djbdns-1.05-ipv6/okclient.c +--- djbdns-1.05/okclient.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/okclient.c 2017-01-07 13:34:48.962745102 +0100 +@@ -2,24 +2,34 @@ + #include <sys/stat.h> + #include "str.h" + #include "ip4.h" ++#include "ip6.h" ++#include "byte.h" + #include "okclient.h" + +-static char fn[3 + IP4_FMT]; ++static char fn[3 + IP6_FMT]; + +-int okclient(char ip[4]) ++int okclient(char ip[16]) + { + struct stat st; + int i; ++ char sep; + + fn[0] = 'i'; + fn[1] = 'p'; + fn[2] = '/'; +- fn[3 + ip4_fmt(fn + 3,ip)] = 0; ++ if (byte_equal(ip,12,V4mappedprefix)) { ++ fn[3 + ip4_fmt(fn + 3,ip+12)] = 0; ++ sep='.'; ++ } else { ++ fn[3 + ip6_fmt(fn + 3,ip)] = 0; ++ sep=':'; ++ } + + for (;;) { ++ if (!fn[3]) return 0; + if (stat(fn,&st) == 0) return 1; + /* treat temporary error as rejection */ +- i = str_rchr(fn,'.'); ++ i = str_rchr(fn,sep); + if (!fn[i]) return 0; + fn[i] = 0; + } +diff -uNr djbdns-1.05/pickdns.c djbdns-1.05-ipv6/pickdns.c +--- djbdns-1.05/pickdns.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/pickdns.c 2017-01-07 13:34:48.962745102 +0100 +@@ -20,7 +20,7 @@ + static char key[258]; + static char data[512]; + +-static int doit(char *q,char qtype[2],char ip[4]) ++static int doit(char *q,char qtype[2],char ip[16]) + { + int r; + uint32 dlen; +@@ -37,7 +37,7 @@ + if (!flaga && !flagmx) goto REFUSE; + + key[0] = '%'; +- byte_copy(key + 1,4,ip); ++ byte_copy(key + 1,4,ip+12); + + r = cdb_find(&c,key,5); + if (!r) r = cdb_find(&c,key,4); +@@ -86,7 +86,7 @@ + return 1; + } + +-int respond(char *q,char qtype[2],char ip[4]) ++int respond(char *q,char qtype[2],char ip[16]) + { + int fd; + int result; +diff -uNr djbdns-1.05/printrecord.c djbdns-1.05-ipv6/printrecord.c +--- djbdns-1.05/printrecord.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/printrecord.c 2017-01-07 13:34:48.963745102 +0100 +@@ -4,6 +4,7 @@ + #include "byte.h" + #include "dns.h" + #include "printrecord.h" ++#include "ip6.h" + + static char *d; + +@@ -82,6 +83,15 @@ + if (!stralloc_catulong0(out,ch,0)) return 0; + } + } ++ else if (byte_equal(misc,2,DNS_T_AAAA)) { ++ char ip6str[IP6_FMT]; ++ int stringlen; ++ if (datalen != 16) { errno = error_proto; return 0; } ++ if (!stralloc_cats(out," AAAA ")) return 0; ++ pos = dns_packet_copy(buf,len,pos,misc,16); if (!pos) return 0; ++ stringlen=ip6_fmt(ip6str,misc); ++ if (!stralloc_catb(out,ip6str,stringlen)) return 0; ++ } + else { + if (!stralloc_cats(out," ")) return 0; + uint16_unpack_big(misc,&u16); +diff -uNr djbdns-1.05/prot.c djbdns-1.05-ipv6/prot.c +--- djbdns-1.05/prot.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/prot.c 2017-01-07 13:42:51.526722609 +0100 +@@ -1,6 +1,10 @@ + #include "hasshsgr.h" + #include "prot.h" + ++#include <sys/types.h> ++#include <unistd.h> ++#include <grp.h> ++ + int prot_gid(int gid) + { + #ifdef HASSHORTSETGROUPS +diff -uNr djbdns-1.05/qlog.c djbdns-1.05-ipv6/qlog.c +--- djbdns-1.05/qlog.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/qlog.c 2017-01-07 13:34:48.963745102 +0100 +@@ -20,15 +20,15 @@ + put('0' + (c & 7)); + } + +-void qlog(const char ip[4],uint16 port,const char id[2],const char *q,const char qtype[2],const char *result) ++void qlog(const char ip[16],uint16 port,const char id[2],const char *q,const char qtype[2],const char *result) + { + char ch; + char ch2; + +- hex(ip[0]); +- hex(ip[1]); +- hex(ip[2]); +- hex(ip[3]); ++ { ++ int i; ++ for (i=0; i<16; ++i) hex(ip[i]); ++ } + put(':'); + hex(port >> 8); + hex(port & 255); +diff -uNr djbdns-1.05/query.c djbdns-1.05-ipv6/query.c +--- djbdns-1.05/query.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/query.c 2017-01-07 13:41:37.878726042 +0100 +@@ -12,6 +12,9 @@ + #include "alloc.h" + #include "response.h" + #include "query.h" ++#include "ip6.h" ++ ++extern stralloc ignoreip; + + static int flagforwardonly = 0; + +@@ -110,7 +113,7 @@ + return 1; + } + +-static int globalip(char *d,char ip[4]) ++static int globalip(char *d,char ip[16]) + { + if (dns_domain_equal(d,"\011localhost\0")) { + byte_copy(ip,4,"\177\0\0\1"); +@@ -165,14 +168,13 @@ + char *buf; + unsigned int len; + const char *whichserver; +- char header[12]; ++ char header[24]; + char misc[20]; + unsigned int rcode; + unsigned int posanswers; + uint16 numanswers; + unsigned int posauthority; + uint16 numauthority; +- unsigned int posglue; + uint16 numglue; + unsigned int pos; + unsigned int pos2; +@@ -193,6 +195,7 @@ + int k; + int p; + int q; ++ unsigned int ii; + + errno = error_io; + if (state == 1) goto HAVEPACKET; +@@ -205,14 +208,15 @@ + NEWNAME: + if (++z->loop == 100) goto DIE; + d = z->name[z->level]; +- dtype = z->level ? DNS_T_A : z->type; ++ dtype = z->level ? (z->ipv6[z->level] ? DNS_T_AAAA : DNS_T_A) : z->type; + dlen = dns_domain_length(d); + + if (globalip(d,misc)) { + if (z->level) { +- for (k = 0;k < 64;k += 4) +- if (byte_equal(z->servers[z->level - 1] + k,4,"\0\0\0\0")) { +- byte_copy(z->servers[z->level - 1] + k,4,misc); ++ for (k = 0;k < 256;k += 16) ++ if (byte_equal(z->servers[z->level - 1] + k,16,V6any)) { ++ byte_copy(z->servers[z->level - 1] + k,12,V4mappedprefix); ++ byte_copy(z->servers[z->level - 1] + k + 12,4,misc); + break; + } + goto LOWERLEVEL; +@@ -227,6 +231,158 @@ + return 1; + } + ++ if (dns_domain_equal(d,"\0011\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\003ip6\003int\0")) { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_PTR,dtype)) { ++ if (!response_rstart(d,DNS_T_PTR,655360)) goto DIE; ++ if (!response_addname("\016ipv6-localhost\0")) goto DIE; ++ if (!response_addname("\015ipv6-loopback\0")) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\001e\001f\003ip6\003int\0")) { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_PTR,dtype)) { ++ if (!response_rstart(d,DNS_T_PTR,655360)) goto DIE; ++ if (!response_addname("\015ipv6-localnet\0")) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\001f\001f\003ip6\003int\0")) { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_PTR,dtype)) { ++ if (!response_rstart(d,DNS_T_PTR,655360)) goto DIE; ++ if (!response_addname("\020ipv6-mcastprefix\0")) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\0011\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0012\0010\001f\001f\003ip6\003int\0")) { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_PTR,dtype)) { ++ if (!response_rstart(d,DNS_T_PTR,655360)) goto DIE; ++ if (!response_addname("\015ipv6-allnodes\0")) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\0012\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0012\0010\001f\001f\003ip6\003int\0")) { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_PTR,dtype)) { ++ if (!response_rstart(d,DNS_T_PTR,655360)) goto DIE; ++ if (!response_addname("\017ipv6-allrouters\0")) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\0011\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0012\0010\001f\001f\003ip6\003int\0")) { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_PTR,dtype)) { ++ if (!response_rstart(d,DNS_T_PTR,655360)) goto DIE; ++ if (!response_addname("\015ipv6-allhosts\0")) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\016ipv6-localhost\0") || ++ dns_domain_equal(d,"\015ipv6-loopback\0")) ++ { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_AAAA,dtype)) { ++ if (!response_rstart(d,DNS_T_AAAA,655360)) goto DIE; ++ if (!response_addbytes("\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001",16)) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\015ipv6-localnet\0")) ++ { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_AAAA,dtype)) { ++ if (!response_rstart(d,DNS_T_AAAA,655360)) goto DIE; ++ if (!response_addbytes("\376\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",16)) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\020ipv6-mcastprefix\0")) ++ { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_AAAA,dtype)) { ++ if (!response_rstart(d,DNS_T_AAAA,655360)) goto DIE; ++ if (!response_addbytes("\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",16)) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\15ipv6-allnodes\0")) ++ { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_AAAA,dtype)) { ++ if (!response_rstart(d,DNS_T_AAAA,655360)) goto DIE; ++ if (!response_addbytes("\377\002\000\000\000\000\000\000\000\000\000\000\000\000\000\001",16)) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\17ipv6-allrouters\0")) ++ { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_AAAA,dtype)) { ++ if (!response_rstart(d,DNS_T_AAAA,655360)) goto DIE; ++ if (!response_addbytes("\377\002\000\000\000\000\000\000\000\000\000\000\000\000\000\002",16)) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ ++ if (dns_domain_equal(d,"\15ipv6-allhosts\0")) ++ { ++ if (z->level) goto LOWERLEVEL; ++ if (!rqa(z)) goto DIE; ++ if (typematch(DNS_T_AAAA,dtype)) { ++ if (!response_rstart(d,DNS_T_AAAA,655360)) goto DIE; ++ if (!response_addbytes("\377\002\000\000\000\000\000\000\000\000\000\000\000\000\000\003",16)) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ } ++ cleanup(z); ++ return 1; ++ } ++ + if (dns_domain_equal(d,"\0011\0010\0010\003127\7in-addr\4arpa\0")) { + if (z->level) goto LOWERLEVEL; + if (!rqa(z)) goto DIE; +@@ -322,13 +478,18 @@ + if (typematch(DNS_T_A,dtype)) { + byte_copy(key,2,DNS_T_A); + cached = cache_get(key,dlen + 2,&cachedlen,&ttl); ++ if (cached && !cachedlen && z->level) { /* if we were looking the A record up to find an NS, try IPv6 too */ ++ z->ipv6[z->level]=1; ++ goto NEWNAME; ++ } + if (cached && (cachedlen || byte_diff(dtype,2,DNS_T_ANY))) { + if (z->level) { + log_cachedanswer(d,DNS_T_A); + while (cachedlen >= 4) { +- for (k = 0;k < 64;k += 4) +- if (byte_equal(z->servers[z->level - 1] + k,4,"\0\0\0\0")) { +- byte_copy(z->servers[z->level - 1] + k,4,cached); ++ for (k = 0;k < 256;k += 16) ++ if (byte_equal(z->servers[z->level - 1] + k,16,V6any)) { ++ byte_copy(z->servers[z->level - 1] + k,12,V4mappedprefix); ++ byte_copy(z->servers[z->level - 1] + k + 12,4,cached); + break; + } + cached += 4; +@@ -351,7 +512,39 @@ + } + } + +- if (!typematch(DNS_T_ANY,dtype) && !typematch(DNS_T_AXFR,dtype) && !typematch(DNS_T_CNAME,dtype) && !typematch(DNS_T_NS,dtype) && !typematch(DNS_T_PTR,dtype) && !typematch(DNS_T_A,dtype) && !typematch(DNS_T_MX,dtype)) { ++ if (typematch(DNS_T_AAAA,dtype)) { ++ byte_copy(key,2,DNS_T_AAAA); ++ cached = cache_get(key,dlen + 2,&cachedlen,&ttl); ++ if (cached && (cachedlen || byte_diff(dtype,2,DNS_T_ANY))) { ++ if (z->level) { ++ log_cachedanswer(d,DNS_T_AAAA); ++ while (cachedlen >= 16) { ++ for (k = 0;k < 256;k += 16) ++ if (byte_equal(z->servers[z->level - 1] + k,16,V6any)) { ++ byte_copy(z->servers[z->level - 1] + k,16,cached); ++ break; ++ } ++ cached += 16; ++ cachedlen -= 16; ++ } ++ goto LOWERLEVEL; ++ } ++ ++ log_cachedanswer(d,DNS_T_AAAA); ++ if (!rqa(z)) goto DIE; ++ while (cachedlen >= 16) { ++ if (!response_rstart(d,DNS_T_AAAA,ttl)) goto DIE; ++ if (!response_addbytes(cached,16)) goto DIE; ++ response_rfinish(RESPONSE_ANSWER); ++ cached += 16; ++ cachedlen -= 16; ++ } ++ cleanup(z); ++ return 1; ++ } ++ } ++ ++ if (!typematch(DNS_T_ANY,dtype) && !typematch(DNS_T_AXFR,dtype) && !typematch(DNS_T_CNAME,dtype) && !typematch(DNS_T_NS,dtype) && !typematch(DNS_T_PTR,dtype) && !typematch(DNS_T_A,dtype) && !typematch(DNS_T_MX,dtype) && !typematch(DNS_T_AAAA,dtype)) { + byte_copy(key,2,dtype); + cached = cache_get(key,dlen + 2,&cachedlen,&ttl); + if (cached && (cachedlen || byte_diff(dtype,2,DNS_T_ANY))) { +@@ -390,7 +583,7 @@ + cached = cache_get(key,dlen + 2,&cachedlen,&ttl); + if (cached && cachedlen) { + z->control[z->level] = d; +- byte_zero(z->servers[z->level],64); ++ byte_zero(z->servers[z->level],256); + for (j = 0;j < QUERY_MAXNS;++j) + dns_domain_free(&z->ns[z->level][j]); + pos = 0; +@@ -418,20 +611,22 @@ + if (!dns_domain_copy(&z->name[z->level + 1],z->ns[z->level][j])) goto DIE; + dns_domain_free(&z->ns[z->level][j]); + ++z->level; ++ z->ipv6[z->level]=0; + goto NEWNAME; + } + dns_domain_free(&z->ns[z->level][j]); + } + +- for (j = 0;j < 64;j += 4) +- if (byte_diff(z->servers[z->level] + j,4,"\0\0\0\0")) ++ for (j = 0;j < 256;j += 16) ++ if (byte_diff(z->servers[z->level] + j,16,V6any)) + break; +- if (j == 64) goto SERVFAIL; ++ if (j == 256) goto SERVFAIL; + +- dns_sortip(z->servers[z->level],64); ++ dns_sortip6(z->servers[z->level],256); + if (z->level) { +- log_tx(z->name[z->level],DNS_T_A,z->control[z->level],z->servers[z->level],z->level); +- if (dns_transmit_start(&z->dt,z->servers[z->level],flagforwardonly,z->name[z->level],DNS_T_A,z->localip) == -1) goto DIE; ++ dtype = z->ipv6[z->level] ? DNS_T_AAAA : DNS_T_A; ++ log_tx(z->name[z->level],dtype,z->control[z->level],z->servers[z->level],z->level); ++ if (dns_transmit_start(&z->dt,z->servers[z->level],flagforwardonly,z->name[z->level],dtype,z->localip) == -1) goto DIE; + } + else { + log_tx(z->name[0],z->type,z->control[0],z->servers[0],0); +@@ -453,10 +648,11 @@ + buf = z->dt.packet; + len = z->dt.packetlen; + +- whichserver = z->dt.servers + 4 * z->dt.curserver; ++ whichserver = z->dt.servers + 16 * z->dt.curserver; + control = z->control[z->level]; + d = z->name[z->level]; +- dtype = z->level ? DNS_T_A : z->type; ++/* dtype = z->level ? DNS_T_A : z->type; */ ++ dtype = z->level ? (z->ipv6[z->level] ? DNS_T_AAAA : DNS_T_A) : z->type; + + pos = dns_packet_copy(buf,len,0,header,12); if (!pos) goto DIE; + pos = dns_packet_skipname(buf,len,pos); if (!pos) goto DIE; +@@ -513,13 +709,11 @@ + uint16_unpack_big(header + 8,&datalen); + pos += datalen; + } +- posglue = pos; +- + + if (!flagcname && !rcode && !flagout && flagreferral && !flagsoa) + if (dns_domain_equal(referral,control) || !dns_domain_suffix(referral,control)) { + log_lame(whichserver,control,referral); +- byte_zero(whichserver,4); ++ byte_zero(whichserver,16); + goto HAVENS; + } + +@@ -643,6 +837,11 @@ + pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) goto DIE; + if (byte_equal(header + 8,2,"\0\4")) { + pos = dns_packet_copy(buf,len,pos,header,4); if (!pos) goto DIE; ++ if (ignoreip.len) ++ for(ii = 0; ii < ignoreip.len; ii+= 16) { ++ if (byte_equal(ignoreip.s+ii,12,V4mappedprefix) && ++ byte_equal(header,4,ignoreip.s+ii+12)) goto NXDOMAIN; ++ } + save_data(header,4); + log_rr(whichserver,t1,DNS_T_A,header,4,ttl); + } +@@ -650,6 +849,23 @@ + } + save_finish(DNS_T_A,t1,ttl); + } ++ else if (byte_equal(type,2,DNS_T_AAAA)) { ++ save_start(); ++ while (i < j) { ++ pos = dns_packet_skipname(buf,len,records[i]); if (!pos) goto DIE; ++ pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) goto DIE; ++ if (byte_equal(header + 8,2,"\0\20")) { ++ pos = dns_packet_copy(buf,len,pos,header,16); if (!pos) goto DIE; ++ if (ignoreip.len) ++ for(ii = 0; ii < ignoreip.len; ii+= 16) ++ if (byte_equal(header,16,ignoreip.s+ii)) goto NXDOMAIN; ++ save_data(header,16); ++ log_rr(whichserver,t1,DNS_T_AAAA,header,16,ttl); ++ } ++ ++i; ++ } ++ save_finish(DNS_T_AAAA,t1,ttl); ++ } + else { + save_start(); + while (i < j) { +@@ -707,6 +923,11 @@ + save_start(); + save_finish(dtype,d,soattl); + log_nodata(whichserver,d,dtype,soattl); ++ if (z->level && !byte_diff(DNS_T_A,2,dtype)) { ++ d = z->name[z->level]; ++ z->ipv6[z->level] = 1; ++ goto NEWNAME; /* retry, will ask for AAAA next */ ++ } + } + + log_stats(); +@@ -723,9 +944,18 @@ + if (typematch(header,DNS_T_A)) + if (byte_equal(header + 2,2,DNS_C_IN)) /* should always be true */ + if (datalen == 4) +- for (k = 0;k < 64;k += 4) +- if (byte_equal(z->servers[z->level - 1] + k,4,"\0\0\0\0")) { +- if (!dns_packet_copy(buf,len,pos,z->servers[z->level - 1] + k,4)) goto DIE; ++ for (k = 0;k < 256;k += 16) ++ if (byte_equal(z->servers[z->level - 1] + k,16,V6any)) { ++ byte_copy(z->servers[z->level - 1] + k,12,V4mappedprefix); ++ if (!dns_packet_copy(buf,len,pos,z->servers[z->level - 1] + k + 12,4)) goto DIE; ++ break; ++ } ++ if (typematch(header,DNS_T_AAAA)) ++ if (byte_equal(header + 2,2,DNS_C_IN)) /* should always be true */ ++ if (datalen == 16) ++ for (k = 0;k < 256;k += 16) ++ if (byte_equal(z->servers[z->level - 1] + k,16,V6any)) { ++ if (!dns_packet_copy(buf,len,pos,z->servers[z->level - 1] + k,16)) goto DIE; + break; + } + pos += datalen; +@@ -783,7 +1013,7 @@ + if (!dns_domain_suffix(d,referral)) goto DIE; + control = d + dns_domain_suffixpos(d,referral); + z->control[z->level] = control; +- byte_zero(z->servers[z->level],64); ++ byte_zero(z->servers[z->level],256); + for (j = 0;j < QUERY_MAXNS;++j) + dns_domain_free(&z->ns[z->level][j]); + k = 0; +@@ -818,7 +1048,7 @@ + return -1; + } + +-int query_start(struct query *z,char *dn,char type[2],char class[2],char localip[4]) ++int query_start(struct query *z,char *dn,char type[2],char class[2],char localip[16],unsigned int scope_id) + { + if (byte_equal(type,2,DNS_T_AXFR)) { errno = error_perm; return -1; } + +@@ -829,7 +1059,9 @@ + if (!dns_domain_copy(&z->name[0],dn)) return -1; + byte_copy(z->type,2,type); + byte_copy(z->class,2,class); +- byte_copy(z->localip,4,localip); ++ byte_copy(z->localip,16,localip); ++ z->scope_id=scope_id; ++ z->ipv6[0]=0; + + return doit(z,0); + } +diff -uNr djbdns-1.05/query.h djbdns-1.05-ipv6/query.h +--- djbdns-1.05/query.h 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/query.h 2017-01-07 13:34:48.963745102 +0100 +@@ -14,16 +14,18 @@ + char *name[QUERY_MAXLEVEL]; + char *control[QUERY_MAXLEVEL]; /* pointing inside name */ + char *ns[QUERY_MAXLEVEL][QUERY_MAXNS]; +- char servers[QUERY_MAXLEVEL][64]; ++ char servers[QUERY_MAXLEVEL][256]; + char *alias[QUERY_MAXALIAS]; + uint32 aliasttl[QUERY_MAXALIAS]; +- char localip[4]; ++ char ipv6[QUERY_MAXLEVEL]; ++ char localip[16]; ++ uint32 scope_id; + char type[2]; + char class[2]; + struct dns_transmit dt; + } ; + +-extern int query_start(struct query *,char *,char *,char *,char *); ++extern int query_start(struct query *,char *,char *,char *,char *,unsigned int); + extern void query_io(struct query *,iopause_fd *,struct taia *); + extern int query_get(struct query *,iopause_fd *,struct taia *); + +diff -uNr djbdns-1.05/roots.c djbdns-1.05-ipv6/roots.c +--- djbdns-1.05/roots.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/roots.c 2017-01-07 13:34:48.963745102 +0100 +@@ -6,6 +6,7 @@ + #include "error.h" + #include "direntry.h" + #include "ip4.h" ++#include "ip6.h" + #include "dns.h" + #include "openreadclose.h" + #include "roots.h" +@@ -22,7 +23,7 @@ + j = dns_domain_length(data.s + i); + if (dns_domain_equal(data.s + i,q)) return i + j; + i += j; +- i += 64; ++ i += 256; + } + return -1; + } +@@ -40,12 +41,12 @@ + } + } + +-int roots(char servers[64],char *q) ++int roots(char servers[256],char *q) + { + int r; + r = roots_find(q); + if (r == -1) return 0; +- byte_copy(servers,64,data.s + r); ++ byte_copy(servers,256,data.s + r); + return 1; + } + +@@ -60,7 +61,7 @@ + const char *fqdn; + static char *q; + static stralloc text; +- char servers[64]; ++ char servers[256]; + int serverslen; + int i; + int j; +@@ -86,14 +87,14 @@ + for (i = 0;i < text.len;++i) + if (text.s[i] == '\n') { + if (serverslen <= 60) +- if (ip4_scan(text.s + j,servers + serverslen)) +- serverslen += 4; ++ if (ip6_scan(text.s + j,servers + serverslen)) ++ serverslen += 16; + j = i + 1; + } +- byte_zero(servers + serverslen,64 - serverslen); ++ byte_zero(servers + serverslen,256 - serverslen); + + if (!stralloc_catb(&data,q,dns_domain_length(q))) return 0; +- if (!stralloc_catb(&data,servers,64)) return 0; ++ if (!stralloc_catb(&data,servers,256)) return 0; + } + } + } +diff -uNr djbdns-1.05/scan_xlong.c djbdns-1.05-ipv6/scan_xlong.c +--- djbdns-1.05/scan_xlong.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/scan_xlong.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,23 @@ ++#include "scan.h" ++ ++static inline int fromhex(unsigned char c) { ++ if (c>='0' && c<='9') ++ return c-'0'; ++ else if (c>='A' && c<='F') ++ return c-'A'+10; ++ else if (c>='a' && c<='f') ++ return c-'a'+10; ++ return -1; ++} ++ ++unsigned int scan_xlong(const char *src,unsigned long *dest) { ++ register const char *tmp=src; ++ register int l=0; ++ register unsigned char c; ++ while ((c=fromhex(*tmp))<16) { ++ l=(l<<4)+c; ++ ++tmp; ++ } ++ *dest=l; ++ return tmp-src; ++} +diff -uNr djbdns-1.05/seek_set.c djbdns-1.05-ipv6/seek_set.c +--- djbdns-1.05/seek_set.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/seek_set.c 2017-01-07 13:54:44.911689356 +0100 +@@ -1,4 +1,5 @@ + #include <sys/types.h> ++#include <unistd.h> + #include "seek.h" + + #define SET 0 /* sigh */ +diff -uNr djbdns-1.05/server.c djbdns-1.05-ipv6/server.c +--- djbdns-1.05/server.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/server.c 2017-01-07 13:34:48.963745102 +0100 +@@ -4,6 +4,7 @@ + #include "buffer.h" + #include "strerr.h" + #include "ip4.h" ++#include "ip6.h" + #include "uint16.h" + #include "ndelay.h" + #include "socket.h" +@@ -11,13 +12,16 @@ + #include "qlog.h" + #include "response.h" + #include "dns.h" ++#include "alloc.h" ++#include "iopause.h" ++#include "str.h" + + extern char *fatal; + extern char *starting; + extern int respond(char *,char *,char *); + extern void initialize(void); + +-static char ip[4]; ++static char ip[16]; + static uint16 port; + + static char buf[513]; +@@ -25,6 +29,11 @@ + + static char *q; + ++void nomem() ++{ ++ strerr_die2x(111,fatal,"out of memory"); ++} ++ + static int doit(void) + { + unsigned int pos; +@@ -82,35 +91,86 @@ + int main() + { + char *x; +- int udp53; ++ int *udp53; ++ unsigned int off; ++ unsigned int cnt; ++ iopause_fd *iop; + + x = env_get("IP"); + if (!x) + strerr_die2x(111,fatal,"$IP not set"); +- if (!ip4_scan(x,ip)) +- strerr_die3x(111,fatal,"unable to parse IP address ",x); +- +- udp53 = socket_udp(); +- if (udp53 == -1) +- strerr_die2sys(111,fatal,"unable to create UDP socket: "); +- if (socket_bind4_reuse(udp53,ip,53) == -1) +- strerr_die2sys(111,fatal,"unable to bind UDP socket: "); +- ++ off=cnt=0; ++ while (x[off]) { ++ unsigned int l; ++ char dummy[16]; ++ l=ip6_scan(x+off,dummy); ++ if (!l) ++ strerr_die3x(111,fatal,"unable to parse IP address ",x+off); ++ cnt++; ++ if (!x[off+l]) break; ++ if (x[off+l]=='%') ++ while (x[off+l] && x[off+l]!=',') ++l; ++ if (x[off+l]!=',') ++ strerr_die3x(111,fatal,"unable to parse IP address ",x+off); ++ off+=l+1; ++ } ++ udp53=(int *) alloc(sizeof(int) *cnt); ++ if (!udp53) nomem(); ++ iop=(iopause_fd *) alloc(sizeof(*iop) * cnt); ++ if (!iop) nomem(); ++ ++ off=cnt=0; ++ while (x[off]) { ++ unsigned int l; ++ uint32 ifid=0; ++ l=ip6_scan(x+off,ip); ++ udp53[cnt] = socket_udp6(); ++ if (udp53[cnt] == -1) ++ strerr_die2sys(111,fatal,"unable to create UDP socket: "); ++ if (x[off+l]=='%') { ++ char* interface=x+off+l+1; ++ int Len=str_chr(interface,','); ++ if (interface[Len]) { ++ interface[Len]=0; ++ ifid=socket_getifidx(interface); ++ interface[Len]=','; ++ } else ++ ifid=socket_getifidx(interface); ++ l+=Len; ++ } ++ if (socket_bind6_reuse(udp53[cnt],ip,53,ifid) == -1) ++ strerr_die2sys(111,fatal,"unable to bind UDP socket: "); ++ ndelay_off(udp53[cnt]); ++ socket_tryreservein(udp53[cnt],65536); ++ iop[cnt].fd=udp53[cnt]; ++ iop[cnt].events=IOPAUSE_READ; ++ cnt++; ++ if (!x[off+l]) break; ++ off+=l+1; ++ } + droproot(fatal); + + initialize(); +- +- ndelay_off(udp53); +- socket_tryreservein(udp53,65536); + + buffer_putsflush(buffer_2,starting); + + for (;;) { +- len = socket_recv4(udp53,buf,sizeof buf,ip,&port); +- if (len < 0) continue; +- if (!doit()) continue; +- if (response_len > 512) response_tc(); +- socket_send4(udp53,response,response_len,ip,port); +- /* may block for buffer space; if it fails, too bad */ ++ struct taia stamp; ++ struct taia deadline; ++ unsigned int i; ++ uint32 ifid; ++ taia_now(&stamp); ++ taia_uint(&deadline,300); ++ taia_add(&deadline,&deadline,&stamp); ++ iopause(iop,cnt,&deadline,&stamp); ++ for (i=0;i<cnt;i++) ++ if (iop[i].revents) { ++ len = socket_recv6(udp53[i],buf,sizeof buf,ip,&port,&ifid); ++ if (len < 0) continue; ++ if (!doit()) continue; ++ if (response_len > 512) response_tc(); ++ socket_send6(udp53[i],response,response_len,ip,port,ifid); ++ /* may block for buffer space; if it fails, too bad */ ++ } + } + } +diff -uNr djbdns-1.05/sockaddr_in6.h1 djbdns-1.05-ipv6/sockaddr_in6.h1 +--- djbdns-1.05/sockaddr_in6.h1 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/sockaddr_in6.h1 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,21 @@ ++#include "haveip6.h" ++#ifdef LIBC_HAS_IP6 ++#include <sys/types.h> ++#include <sys/socket.h> ++#define sockaddr_in6 blub ++#include <netinet/in.h> ++#undef sockaddr_in6 ++ ++struct sockaddr_in6 { ++ sa_family_t sin6_family; /* AF_INET6 */ ++ unsigned short sin6_port; /* transport layer port # */ ++ uint32_t sin6_flowinfo; /* IPv6 traffic class & flow info */ ++ struct in6_addr sin6_addr; /* IPv6 address */ ++ uint32_t sin6_scope_id; /* set of interfaces for a scope */ ++}; ++ ++#else ++#include <sys/types.h> ++#include <sys/socket.h> ++#include <netinet/in.h> ++#endif +diff -uNr djbdns-1.05/sockaddr_in6.h2 djbdns-1.05-ipv6/sockaddr_in6.h2 +--- djbdns-1.05/sockaddr_in6.h2 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/sockaddr_in6.h2 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,4 @@ ++#include <sys/types.h> ++#include <sys/socket.h> ++#include <netinet/in.h> ++ +diff -uNr djbdns-1.05/socket.h djbdns-1.05-ipv6/socket.h +--- djbdns-1.05/socket.h 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/socket.h 2017-01-07 13:34:48.963745102 +0100 +@@ -2,21 +2,37 @@ + #define SOCKET_H + + #include "uint16.h" ++#include "uint32.h" + + extern int socket_tcp(void); + extern int socket_udp(void); ++extern int socket_tcp6(void); ++extern int socket_udp6(void); + + extern int socket_connect4(int,const char *,uint16); ++extern int socket_connect6(int s,const char ip[16],uint16 port,uint32 scope_id); + extern int socket_connected(int); +-extern int socket_bind4(int,char *,uint16); ++extern int socket_bind4(int,const char *,uint16); + extern int socket_bind4_reuse(int,char *,uint16); ++extern int socket_bind6(int s,const char *ip,uint16 port,uint32 scope_id); ++extern int socket_bind6_reuse(int s,const char *ip,uint16 port,uint32 scope_id); + extern int socket_listen(int,int); + extern int socket_accept4(int,char *,uint16 *); ++extern int socket_accept6(int s,char *ip,uint16 *port,uint32 *scope_id); + extern int socket_recv4(int,char *,int,char *,uint16 *); + extern int socket_send4(int,const char *,int,const char *,uint16); ++extern int socket_recv6(int s,char *buf,unsigned int len,char *ip,uint16 *port,uint32 *scope_id); ++extern int socket_send6(int s,const char *buf,unsigned int len,const char *ip,uint16 port,uint32 scope_id); + extern int socket_local4(int,char *,uint16 *); + extern int socket_remote4(int,char *,uint16 *); ++extern int socket_local6(int s,char *ip,uint16 *port,uint32 *scope_id); ++extern int socket_remote6(int s,char *ip,uint16 *port,uint32 *scope_id); + + extern void socket_tryreservein(int,int); + ++extern const char* socket_getifname(uint32 interface); ++extern uint32 socket_getifidx(const char *ifname); ++ ++extern int noipv6; ++ + #endif +diff -uNr djbdns-1.05/socket_accept6.c djbdns-1.05-ipv6/socket_accept6.c +--- djbdns-1.05/socket_accept6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_accept6.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,43 @@ ++#include <sys/param.h> ++#include <sys/socket.h> ++#include <netinet/in.h> ++#include "byte.h" ++#include "socket.h" ++#include "ip6.h" ++#include "haveip6.h" ++#include "error.h" ++ ++int socket_accept6(int s,char ip[16],uint16 *port,uint32 *scope_id) ++{ ++#ifdef LIBC_HAS_IP6 ++ struct sockaddr_in6 sa; ++#else ++ struct sockaddr_in sa; ++#endif ++ unsigned int dummy = sizeof sa; ++ int fd; ++ ++ fd = accept(s,(struct sockaddr *) &sa,&dummy); ++ if (fd == -1) return -1; ++ ++#ifdef LIBC_HAS_IP6 ++ if (sa.sin6_family==AF_INET) { ++ struct sockaddr_in *sa4=(struct sockaddr_in*)&sa; ++ byte_copy(ip,12,V4mappedprefix); ++ byte_copy(ip+12,4,(char *) &sa4->sin_addr); ++ uint16_unpack_big((char *) &sa4->sin_port,port); ++ return fd; ++ } ++ byte_copy(ip,16,(char *) &sa.sin6_addr); ++ uint16_unpack_big((char *) &sa.sin6_port,port); ++ if (scope_id) *scope_id=sa.sin6_scope_id; ++ ++ return fd; ++#else ++ byte_copy(ip,12,V4mappedprefix); ++ byte_copy(ip+12,4,(char *) &sa.sin_addr); ++ uint16_unpack_big((char *) &sa.sin_port,port); ++ if (scope_id) *scope_id=0; ++ return fd; ++#endif ++} +diff -uNr djbdns-1.05/socket_bind.c djbdns-1.05-ipv6/socket_bind.c +--- djbdns-1.05/socket_bind.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_bind.c 2017-01-07 13:34:48.963745102 +0100 +@@ -5,7 +5,7 @@ + #include "byte.h" + #include "socket.h" + +-int socket_bind4(int s,char ip[4],uint16 port) ++int socket_bind4(int s,const char ip[4],uint16 port) + { + struct sockaddr_in sa; + +diff -uNr djbdns-1.05/socket_bind6.c djbdns-1.05-ipv6/socket_bind6.c +--- djbdns-1.05/socket_bind6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_bind6.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,43 @@ ++#include <sys/param.h> ++#include "sockaddr_in6.h" ++#include "byte.h" ++#include "socket.h" ++#include "ip6.h" ++#include "haveip6.h" ++#include "error.h" ++ ++int socket_bind6(int s,const char ip[16],uint16 port,uint32 scope_id) ++{ ++#ifdef LIBC_HAS_IP6 ++ struct sockaddr_in6 sa; ++ ++ if (noipv6) { ++#endif ++ int i; ++ for (i=0; i<16; i++) ++ if (ip[i]!=0) break; ++ if (i==16 || ip6_isv4mapped(ip)) ++ return socket_bind4(s,ip+12,port); ++#ifdef LIBC_HAS_IP6 ++ } ++ byte_zero(&sa,sizeof sa); ++ sa.sin6_family = AF_INET6; ++ uint16_pack_big((char *) &sa.sin6_port,port); ++/* implicit: sa.sin6_flowinfo = 0; */ ++ byte_copy((char *) &sa.sin6_addr,16,ip); ++ sa.sin6_scope_id=scope_id; ++ ++ return bind(s,(struct sockaddr *) &sa,sizeof sa); ++#else ++ errno=error_proto; ++ return -1; ++#endif ++} ++ ++int socket_bind6_reuse(int s,const char ip[16],uint16 port,uint32 scope_id) ++{ ++ int opt = 1; ++ setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof opt); ++ return socket_bind6(s,ip,port,scope_id); ++} ++ +diff -uNr djbdns-1.05/socket_connect6.c djbdns-1.05-ipv6/socket_connect6.c +--- djbdns-1.05/socket_connect6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_connect6.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,39 @@ ++#include <sys/param.h> ++#include <sys/types.h> ++#include <sys/socket.h> ++#include <netinet/in.h> ++#include <errno.h> ++#include "byte.h" ++#include "socket.h" ++#include "ip6.h" ++#include "haveip6.h" ++#include "error.h" ++#include "uint32.h" ++#include "ip4.h" ++ ++int socket_connect6(int s,const char ip[16],uint16 port,uint32 scope_id) ++{ ++#ifdef LIBC_HAS_IP6 ++ struct sockaddr_in6 sa; ++ ++ if (noipv6) { ++#endif ++ if (ip6_isv4mapped(ip)) ++ return socket_connect4(s,ip+12,port); ++ if (byte_equal(ip,16,V6loopback)) ++ return socket_connect4(s,ip4loopback,port); ++#ifdef LIBC_HAS_IP6 ++ } ++ byte_zero(&sa,sizeof sa); ++ sa.sin6_family = PF_INET6; ++ uint16_pack_big((char *) &sa.sin6_port,port); ++ sa.sin6_flowinfo = 0; ++ sa.sin6_scope_id = scope_id; ++ byte_copy((char *) &sa.sin6_addr,16,ip); ++ ++ return connect(s,(struct sockaddr *) &sa,sizeof sa); ++#else ++ errno=error_proto; ++ return -1; ++#endif ++} +diff -uNr djbdns-1.05/socket_getifidx.c djbdns-1.05-ipv6/socket_getifidx.c +--- djbdns-1.05/socket_getifidx.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_getifidx.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,13 @@ ++#include <sys/types.h> ++#include <sys/socket.h> ++#include <net/if.h> ++#include "socket.h" ++#include "haven2i.h" ++ ++uint32 socket_getifidx(const char* ifname) { ++#ifdef HAVE_N2I ++ return if_nametoindex(ifname); ++#else ++ return 0; ++#endif ++} +diff -uNr djbdns-1.05/socket_noipv6.c djbdns-1.05-ipv6/socket_noipv6.c +--- djbdns-1.05/socket_noipv6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_noipv6.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,7 @@ ++#include "haveip6.h" ++ ++#ifdef LIBC_HAS_IP6 ++int noipv6=0; ++#else ++int noipv6=1; ++#endif +diff -uNr djbdns-1.05/socket_recv6.c djbdns-1.05-ipv6/socket_recv6.c +--- djbdns-1.05/socket_recv6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_recv6.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,42 @@ ++#include <sys/param.h> ++#include "sockaddr_in6.h" ++#include "byte.h" ++#include "socket.h" ++#include "ip6.h" ++#include "haveip6.h" ++#include "error.h" ++ ++int socket_recv6(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint32 *scope_id) ++{ ++#ifdef LIBC_HAS_IP6 ++ struct sockaddr_in6 sa; ++#else ++ struct sockaddr_in sa; ++#endif ++ unsigned int dummy = sizeof sa; ++ int r; ++ ++ byte_zero(&sa,dummy); ++ r = recvfrom(s,buf,len,0,(struct sockaddr *) &sa,&dummy); ++ if (r == -1) return -1; ++ ++#ifdef LIBC_HAS_IP6 ++ if (noipv6 || sa.sin6_family==AF_INET || sa.sin6_family==PF_INET) { ++ struct sockaddr_in *sa4=(struct sockaddr_in *)&sa; ++ byte_copy(ip,12,V4mappedprefix); ++ byte_copy(ip+12,4,(char *) &sa4->sin_addr); ++ uint16_unpack_big((char *) &sa4->sin_port,port); ++ return r; ++ } ++ byte_copy(ip,16,(char *) &sa.sin6_addr); ++ uint16_unpack_big((char *) &sa.sin6_port,port); ++ if (scope_id) *scope_id=sa.sin6_scope_id; ++#else ++ byte_copy(ip,12,(char *)V4mappedprefix); ++ byte_copy(ip+12,4,(char *) &sa.sin_addr); ++ uint16_unpack_big((char *) &sa.sin_port,port); ++ if (scope_id) *scope_id=0; ++#endif ++ ++ return r; ++} +diff -uNr djbdns-1.05/socket_send6.c djbdns-1.05-ipv6/socket_send6.c +--- djbdns-1.05/socket_send6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_send6.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,39 @@ ++#include <sys/types.h> ++#include <sys/param.h> ++#include <sys/socket.h> ++#include <netinet/in.h> ++#include "byte.h" ++#include "socket.h" ++#include "ip6.h" ++#include "haveip6.h" ++#include "error.h" ++ ++int socket_send6(int s,const char *buf,unsigned int len,const char ip[16],uint16 port,uint32 scope_id) ++{ ++#ifdef LIBC_HAS_IP6 ++ struct sockaddr_in6 sa; ++#else ++ struct sockaddr_in sa; ++#endif ++ ++ byte_zero(&sa,sizeof sa); ++#ifdef LIBC_HAS_IP6 ++ if (noipv6) { ++#endif ++ if (ip6_isv4mapped(ip)) ++ return socket_send4(s,buf,len,ip+12,port); ++ if (byte_equal(ip,16,V6loopback)) ++ return socket_send4(s,buf,len,ip4loopback,port); ++#ifdef LIBC_HAS_IP6 ++ errno=error_proto; ++ return -1; ++ } ++ sa.sin6_family = AF_INET6; ++ uint16_pack_big((char *) &sa.sin6_port,port); ++ byte_copy((char *) &sa.sin6_addr,16,ip); ++ return sendto(s,buf,len,0,(struct sockaddr *) &sa,sizeof sa); ++#else ++ errno=error_proto; ++ return -1; ++#endif ++} +diff -uNr djbdns-1.05/socket_tcp6.c djbdns-1.05-ipv6/socket_tcp6.c +--- djbdns-1.05/socket_tcp6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_tcp6.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,50 @@ ++#include <sys/types.h> ++#include <sys/param.h> ++#include <sys/socket.h> ++#include <netinet/in.h> ++#include <errno.h> ++#include <unistd.h> ++#include "ndelay.h" ++#include "socket.h" ++#include "haveip6.h" ++#include "error.h" ++ ++#ifndef EAFNOSUPPORT ++#define EAFNOSUPPORT EINVAL ++#endif ++#ifndef EPFNOSUPPORT ++#define EPFNOSUPPORT EAFNOSUPPORT ++#endif ++#ifndef EPROTONOSUPPORT ++#define EPROTONOSUPPORT EAFNOSUPPORT ++#endif ++ ++int socket_tcp6(void) ++{ ++#ifdef LIBC_HAS_IP6 ++ int s; ++ ++ if (noipv6) goto compat; ++ s = socket(PF_INET6,SOCK_STREAM,0); ++ if (s == -1) { ++ if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT || errno == EPFNOSUPPORT) { ++compat: ++ s=socket(AF_INET,SOCK_STREAM,0); ++ noipv6=1; ++ if (s==-1) return -1; ++ } else ++ return -1; ++ } ++ if (ndelay_on(s) == -1) { close(s); return -1; } ++#ifdef IPV6_V6ONLY ++ { ++ int zero=0; ++ setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)); ++ } ++#endif ++ return s; ++#else ++ return socket_tcp(); ++#endif ++} ++ +diff -uNr djbdns-1.05/socket_udp6.c djbdns-1.05-ipv6/socket_udp6.c +--- djbdns-1.05/socket_udp6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/socket_udp6.c 2017-01-07 13:34:48.963745102 +0100 +@@ -0,0 +1,49 @@ ++#include <sys/types.h> ++#include <sys/param.h> ++#include <sys/socket.h> ++#include <netinet/in.h> ++#include <errno.h> ++#include <unistd.h> ++#include "ndelay.h" ++#include "socket.h" ++#include "haveip6.h" ++#include "error.h" ++ ++#ifndef EAFNOSUPPORT ++#define EAFNOSUPPORT EINVAL ++#endif ++#ifndef EPFNOSUPPORT ++#define EPFNOSUPPORT EAFNOSUPPORT ++#endif ++#ifndef EPROTONOSUPPORT ++#define EPROTONOSUPPORT EAFNOSUPPORT ++#endif ++ ++int socket_udp6(void) ++{ ++#ifdef LIBC_HAS_IP6 ++ int s; ++ ++ if (noipv6) goto compat; ++ s = socket(PF_INET6,SOCK_DGRAM,0); ++ if (s == -1) { ++ if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPFNOSUPPORT || errno == EPROTONOSUPPORT) { ++compat: ++ s=socket(AF_INET,SOCK_DGRAM,0); ++ noipv6=1; ++ if (s==-1) return -1; ++ } else ++ return -1; ++ } ++ if (ndelay_on(s) == -1) { close(s); return -1; } ++#ifdef IPV6_V6ONLY ++ { ++ int zero=0; ++ setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)); ++ } ++#endif ++ return s; ++#else ++ return socket_udp(); ++#endif ++} +diff -uNr djbdns-1.05/tdlookup.c djbdns-1.05-ipv6/tdlookup.c +--- djbdns-1.05/tdlookup.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/tdlookup.c 2017-01-07 13:34:48.964745102 +0100 +@@ -8,6 +8,8 @@ + #include "dns.h" + #include "seek.h" + #include "response.h" ++#include "ip6.h" ++#include "clientloc.h" + + static int want(const char *owner,const char type[2]) + { +@@ -61,7 +63,7 @@ + if (cdb_read(&c,data,dlen,cdb_datapos(&c)) == -1) return -1; + dpos = dns_packet_copy(data,dlen,0,type,2); if (!dpos) return -1; + dpos = dns_packet_copy(data,dlen,dpos,&ch,1); if (!dpos) return -1; +- if ((ch == '=' + 1) || (ch == '*' + 1)) { ++ if ((ch == '=' + 1) || (ch == '*' + 1) || (ch == '6' + 1)) { + --ch; + dpos = dns_packet_copy(data,dlen,dpos,recordloc,2); if (!dpos) return -1; + if (byte_diff(recordloc,2,clientloc)) continue; +@@ -119,8 +121,9 @@ + char x[20]; + uint16 u16; + char addr[8][4]; +- int addrnum; +- uint32 addrttl; ++ char addr6[8][16]; ++ int addrnum,addr6num; ++ uint32 addrttl,addr6ttl; + int i; + + anpos = response_len; +@@ -152,8 +155,8 @@ + wild = q; + + for (;;) { +- addrnum = 0; +- addrttl = 0; ++ addrnum = addr6num = 0; ++ addrttl = addr6ttl = 0; + cdb_findstart(&c); + while (r = find(wild,wild != q)) { + if (r == -1) return 0; +@@ -171,6 +174,17 @@ + if (addrnum < 1000000) ++addrnum; + continue; + } ++ if (byte_equal(type,2,DNS_T_AAAA) && (dlen - dpos == 16)) { ++ addr6ttl = ttl; ++ i = dns_random(addr6num + 1); ++ if (i < 8) { ++ if ((i < addr6num) && (addr6num < 8)) ++ byte_copy(addr6[addr6num],16,addr6[i]); ++ byte_copy(addr6[i],16,data + dpos); ++ } ++ if (addr6num < 1000000) ++addr6num; ++ continue; ++ } + if (!response_rstart(q,type,ttl)) return 0; + if (byte_equal(type,2,DNS_T_NS) || byte_equal(type,2,DNS_T_CNAME) || byte_equal(type,2,DNS_T_PTR)) { + if (!doname()) return 0; +@@ -195,6 +209,12 @@ + if (!response_addbytes(addr[i],4)) return 0; + response_rfinish(RESPONSE_ANSWER); + } ++ for (i = 0;i < addr6num;++i) ++ if (i < 8) { ++ if (!response_rstart(q,DNS_T_AAAA,addr6ttl)) return 0; ++ if (!response_addbytes(addr6[i],16)) return 0; ++ response_rfinish(RESPONSE_ANSWER); ++ } + + if (flagfound) break; + if (wild == control) break; +@@ -259,6 +279,11 @@ + if (!dobytes(4)) return 0; + response_rfinish(RESPONSE_ADDITIONAL); + } ++ else if (byte_equal(type,2,DNS_T_AAAA)) { ++ if (!response_rstart(d1,DNS_T_AAAA,ttl)) return 0; ++ if (!dobytes(16)) return 0; ++ response_rfinish(RESPONSE_ADDITIONAL); ++ } + } + } + } +@@ -278,30 +303,18 @@ + return 1; + } + +-int respond(char *q,char qtype[2],char ip[4]) ++int respond(char *q,char qtype[2],char ip[16]) + { + int fd; + int r; +- char key[6]; ++ ++ find_client_loc(clientloc, ip); + + tai_now(&now); + fd = open_read("data.cdb"); + if (fd == -1) return 0; + cdb_init(&c,fd); + +- byte_zero(clientloc,2); +- key[0] = 0; +- key[1] = '%'; +- byte_copy(key + 2,4,ip); +- r = cdb_find(&c,key,6); +- if (!r) r = cdb_find(&c,key,5); +- if (!r) r = cdb_find(&c,key,4); +- if (!r) r = cdb_find(&c,key,3); +- if (!r) r = cdb_find(&c,key,2); +- if (r == -1) return 0; +- if (r && (cdb_datalen(&c) == 2)) +- if (cdb_read(&c,clientloc,2,cdb_datapos(&c)) == -1) return 0; +- + r = doit(q,qtype); + + cdb_free(&c); +diff -uNr djbdns-1.05/tinydns-conf.c djbdns-1.05-ipv6/tinydns-conf.c +--- djbdns-1.05/tinydns-conf.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/tinydns-conf.c 2017-01-07 13:34:48.964745102 +0100 +@@ -82,6 +82,18 @@ + finish(); + perm(0755); + ++ start("root/add-host6"); ++ outs("#!/bin/sh\nexec "); ++ outs(auto_home); outs("/bin/tinydns-edit data data.new add host6 ${1+\"$@\"}\n"); ++ finish(); ++ perm(0755); ++ ++ start("root/add-alias6"); ++ outs("#!/bin/sh\nexec "); ++ outs(auto_home); outs("/bin/tinydns-edit data data.new add alias6 ${1+\"$@\"}\n"); ++ finish(); ++ perm(0755); ++ + start("root/add-mx"); + outs("#!/bin/sh\nexec "); + outs(auto_home); outs("/bin/tinydns-edit data data.new add mx ${1+\"$@\"}\n"); +diff -uNr djbdns-1.05/tinydns-data.c djbdns-1.05-ipv6/tinydns-data.c +--- djbdns-1.05/tinydns-data.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/tinydns-data.c 2017-01-07 13:47:57.183708361 +0100 +@@ -8,6 +8,7 @@ + #include "byte.h" + #include "fmt.h" + #include "ip4.h" ++#include "ip6.h" + #include "exit.h" + #include "case.h" + #include "scan.h" +@@ -65,16 +66,23 @@ + char ch; + unsigned int j; + +- for (;;) +- if (*s == '.') +- ++s; +- else { +- j = scan_ulong(s,&u); +- if (!j) return; +- s += j; +- ch = u; +- if (!stralloc_catb(out,&ch,1)) nomem(); +- } ++ if (*s=='s') { ++ ++s; ++ if (!stralloc_catb(out,"s",1) || !stralloc_cats(out,s)) nomem(); ++ } else { ++ if (*s=='f') ++s; ++ if (!stralloc_catb(out,"f",1)) nomem(); ++ for (;;) ++ if (*s == '.') ++ ++s; ++ else { ++ j = scan_ulong(s,&u); ++ if (!j) return; ++ s += j; ++ ch = u; ++ if (!stralloc_catb(out,&ch,1)) nomem(); ++ } ++ } + } + + void txtparse(stralloc *sa) +@@ -172,6 +180,7 @@ + static char *d1; + static char *d2; + char dptr[DNS_NAME4_DOMAIN]; ++char d6ptr[DNS_NAME6_DOMAIN]; + + char strnum[FMT_ULONG]; + +@@ -181,6 +190,14 @@ + strerr_die4x(111,FATAL,"unable to parse data line ",strnum,why); + } + ++static unsigned int scan_u32(const char *s,uint32 *u) { ++ unsigned long l; ++ unsigned int r=scan_ulong(s,&l); ++ if ((uint32)l != l) return 0; ++ if (r) *u=l; ++ return r; ++} ++ + int main() + { + int fddata; +@@ -191,8 +208,9 @@ + unsigned long ttl; + char ttd[8]; + char loc[2]; +- unsigned long u; ++ uint32 u; + char ip[4]; ++ char ip6[16]; + char type[2]; + char soa[20]; + char buf[4]; +@@ -251,19 +269,19 @@ + if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem(); + + if (!stralloc_0(&f[3])) nomem(); +- if (!scan_ulong(f[3].s,&u)) uint32_unpack_big(defaultsoa,&u); ++ if (!scan_u32(f[3].s,&u)) uint32_unpack_big(defaultsoa,&u); + uint32_pack_big(soa,u); + if (!stralloc_0(&f[4])) nomem(); +- if (!scan_ulong(f[4].s,&u)) uint32_unpack_big(defaultsoa + 4,&u); ++ if (!scan_u32(f[4].s,&u)) uint32_unpack_big(defaultsoa + 4,&u); + uint32_pack_big(soa + 4,u); + if (!stralloc_0(&f[5])) nomem(); +- if (!scan_ulong(f[5].s,&u)) uint32_unpack_big(defaultsoa + 8,&u); ++ if (!scan_u32(f[5].s,&u)) uint32_unpack_big(defaultsoa + 8,&u); + uint32_pack_big(soa + 8,u); + if (!stralloc_0(&f[6])) nomem(); +- if (!scan_ulong(f[6].s,&u)) uint32_unpack_big(defaultsoa + 12,&u); ++ if (!scan_u32(f[6].s,&u)) uint32_unpack_big(defaultsoa + 12,&u); + uint32_pack_big(soa + 12,u); + if (!stralloc_0(&f[7])) nomem(); +- if (!scan_ulong(f[7].s,&u)) uint32_unpack_big(defaultsoa + 16,&u); ++ if (!scan_u32(f[7].s,&u)) uint32_unpack_big(defaultsoa + 16,&u); + uint32_pack_big(soa + 16,u); + + if (!stralloc_0(&f[8])) nomem(); +@@ -339,6 +357,33 @@ + } + break; + ++ case '6': case '3': ++ if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem(); ++ if (!stralloc_0(&f[2])) nomem(); ++ if (!scan_ulong(f[2].s,&ttl)) ttl = TTL_POSITIVE; ++ ttdparse(&f[3],ttd); ++ locparse(&f[4],loc); ++ ++ if (!stralloc_0(&f[1])) nomem(); ++ if (ip6_scan_flat(f[1].s,ip6)) { ++ rr_start(DNS_T_AAAA,ttl,ttd,loc); ++ rr_add(ip6,16); ++ rr_finish(d1); ++ ++ if (line.s[0] == '6') { /* emit both .ip6.arpa and .ip6.int */ ++ dns_name6_domain(d6ptr,ip6,DNS_IP6_ARPA); ++ rr_start(DNS_T_PTR,ttl,ttd,loc); ++ rr_addname(d1); ++ rr_finish(d6ptr); ++ ++ dns_name6_domain(d6ptr,ip6,DNS_IP6_INT); ++ rr_start(DNS_T_PTR,ttl,ttd,loc); ++ rr_addname(d1); ++ rr_finish(d6ptr); ++ } ++ } ++ break; ++ + case '@': + if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem(); + if (!stralloc_0(&f[4])) nomem(); +@@ -355,7 +400,7 @@ + if (!dns_domain_fromdot(&d2,f[2].s,f[2].len)) nomem(); + + if (!stralloc_0(&f[3])) nomem(); +- if (!scan_ulong(f[3].s,&u)) u = 0; ++ if (!scan_u32(f[3].s,&u)) u = 0; + + rr_start(DNS_T_MX,ttl,ttd,loc); + uint16_pack_big(buf,u); +@@ -417,7 +462,7 @@ + locparse(&f[5],loc); + + if (!stralloc_0(&f[1])) nomem(); +- scan_ulong(f[1].s,&u); ++ scan_u32(f[1].s,&u); + uint16_pack_big(type,u); + if (byte_equal(type,2,DNS_T_AXFR)) + syntaxerror(": type AXFR prohibited"); +diff -uNr djbdns-1.05/tinydns-edit.c djbdns-1.05-ipv6/tinydns-edit.c +--- djbdns-1.05/tinydns-edit.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/tinydns-edit.c 2017-01-07 13:34:48.964745102 +0100 +@@ -13,6 +13,7 @@ + #include "str.h" + #include "fmt.h" + #include "ip4.h" ++#include "ip6.h" + #include "dns.h" + + #define FATAL "tinydns-edit: fatal: " +@@ -25,7 +26,8 @@ + + void die_usage() + { +- strerr_die1x(100,"tinydns-edit: usage: tinydns-edit data data.new add [ns|childns|host|alias|mx] domain a.b.c.d"); ++ strerr_die1x(100,"tinydns-edit: usage: tinydns-edit data data.new add [ns|childns|host|alias|mx] domain a.b.c.d\n" ++ "tinydns-edit: usage: tinydns-edit data data.new add [host6|alias6] domain a:b:c:d:e:f:g:h"); + } + void nomem() + { +@@ -43,6 +45,7 @@ + char mode; + static char *target; + char targetip[4]; ++char targetip6[16]; + + int fd; + buffer b; +@@ -61,7 +64,9 @@ + static char *d1; + static char *d2; + char ip[4]; ++char ip6[16]; + char ipstr[IP4_FMT]; ++char ip6str[IP6_FMT]; + char strnum[FMT_ULONG]; + + static char *names[26]; +@@ -96,7 +101,9 @@ + if (str_equal(*argv,"ns")) mode = '.'; + else if (str_equal(*argv,"childns")) mode = '&'; + else if (str_equal(*argv,"host")) mode = '='; ++ else if (str_equal(*argv,"host6")) mode = '6'; + else if (str_equal(*argv,"alias")) mode = '+'; ++ else if (str_equal(*argv,"alias6")) mode = '3'; + else if (str_equal(*argv,"mx")) mode = '@'; + else die_usage(); + +@@ -104,7 +111,11 @@ + if (!dns_domain_fromdot(&target,*argv,str_len(*argv))) nomem(); + + if (!*++argv) die_usage(); +- if (!ip4_scan(*argv,targetip)) die_usage(); ++ if (mode == '6' || mode == '3') { ++ if (!ip6_scan(*argv,targetip6)) die_usage(); ++ } else { ++ if (!ip4_scan(*argv,targetip)) die_usage(); ++ } + + umask(077); + +@@ -129,7 +140,7 @@ + if (!dns_domain_fromdot(&names[i],f[0].s,f[0].len)) nomem(); + } + break; +- case '+': case '=': ++ case '+': case '=': case '6': case '3': + ttl = TTL_POSITIVE; + break; + case '@': +@@ -203,6 +214,18 @@ + } + break; + ++ case '6': ++ if (line.s[0] == '6') { ++ if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem(); ++ if (dns_domain_equal(d1,target)) ++ strerr_die2x(100,FATAL,"host name already used"); ++ if (!stralloc_0(&f[1])) nomem(); ++ if (ip6_scan(f[1].s,ip6)) ++ if (byte_equal(ip,16,targetip6)) ++ strerr_die2x(100,FATAL,"IPv6 address already used"); ++ } ++ break; ++ + case '@': + if (line.s[0] == '@') { + if (!dns_domain_fromdot(&d1,f[0].s,f[0].len)) nomem(); +@@ -228,7 +251,11 @@ + if (!stralloc_copyb(&f[0],&mode,1)) nomem(); + if (!dns_domain_todot_cat(&f[0],target)) nomem(); + if (!stralloc_cats(&f[0],":")) nomem(); +- if (!stralloc_catb(&f[0],ipstr,ip4_fmt(ipstr,targetip))) nomem(); ++ if (mode == '6' || mode == '3') { ++ if (!stralloc_catb(&f[0],ip6str,ip6_fmt_flat(ip6str,targetip6))) nomem(); ++ } else { ++ if (!stralloc_catb(&f[0],ipstr,ip4_fmt(ipstr,targetip))) nomem(); ++ } + switch(mode) { + case '.': case '&': case '@': + for (i = 0;i < 26;++i) +diff -uNr djbdns-1.05/tinydns-get.c djbdns-1.05-ipv6/tinydns-get.c +--- djbdns-1.05/tinydns-get.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/tinydns-get.c 2017-01-07 13:34:48.964745102 +0100 +@@ -11,6 +11,7 @@ + #include "printpacket.h" + #include "parsetype.h" + #include "ip4.h" ++#include "ip6.h" + #include "dns.h" + + extern int respond(char *,char *,char *); +@@ -26,7 +27,7 @@ + strerr_die2sys(111,FATAL,"unable to parse: "); + } + +-static char ip[4]; ++static char ip[16]; + static char type[2]; + static char *q; + +@@ -45,7 +46,7 @@ + if (!dns_domain_fromdot(&q,*argv,str_len(*argv))) oops(); + + if (*++argv) { +- if (!ip4_scan(*argv,ip)) usage(); ++ if (!ip6_scan(*argv,ip)) usage(); + } + + if (!stralloc_copys(&out,"")) oops(); +diff -uNr djbdns-1.05/tryip6.c djbdns-1.05-ipv6/tryip6.c +--- djbdns-1.05/tryip6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/tryip6.c 2017-01-07 13:34:48.964745102 +0100 +@@ -0,0 +1,8 @@ ++#include <sys/types.h> ++#include <sys/socket.h> ++#include <netinet/in.h> ++ ++main() { ++ struct sockaddr_in6 sa; ++ sa.sin6_family = PF_INET6; ++} +diff -uNr djbdns-1.05/tryn2i.c djbdns-1.05-ipv6/tryn2i.c +--- djbdns-1.05/tryn2i.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/tryn2i.c 2017-01-07 13:34:48.964745102 +0100 +@@ -0,0 +1,8 @@ ++#include <sys/types.h> ++#include <sys/socket.h> ++#include <net/if.h> ++ ++int main() { ++ static char ifname[IFNAMSIZ]; ++ char *tmp=if_indextoname(0,ifname); ++} +diff -uNr djbdns-1.05/trysa6.c djbdns-1.05-ipv6/trysa6.c +--- djbdns-1.05/trysa6.c 1970-01-01 01:00:00.000000000 +0100 ++++ djbdns-1.05-ipv6/trysa6.c 2017-01-07 13:34:48.964745102 +0100 +@@ -0,0 +1,8 @@ ++#include <sys/types.h> ++#include <sys/socket.h> ++#include <netinet/in.h> ++ ++main() { ++ struct sockaddr_in6 sa; ++ sa.sin6_scope_id = 1; ++} +diff -uNr djbdns-1.05/tryshsgr.c djbdns-1.05-ipv6/tryshsgr.c +--- djbdns-1.05/tryshsgr.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/tryshsgr.c 2017-01-07 13:56:13.159685243 +0100 +@@ -1,6 +1,10 @@ ++#include <sys/types.h> ++#include <unistd.h> ++#include <grp.h> ++ + int main() + { +- short x[4]; ++ gid_t x[4]; + + x[0] = x[1] = 1; + if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1); +diff -uNr djbdns-1.05/utime.c djbdns-1.05-ipv6/utime.c +--- djbdns-1.05/utime.c 2001-02-11 22:11:45.000000000 +0100 ++++ djbdns-1.05-ipv6/utime.c 2017-01-07 13:58:11.607679722 +0100 +@@ -1,5 +1,6 @@ + #include <sys/types.h> + #include <sys/time.h> ++#include <utime.h> + #include "scan.h" + #include "exit.h" + +@@ -7,7 +8,7 @@ + + char *ustr; + unsigned long u; +-time_t ut[2]; ++struct utimbuf ut; + + int main(int argc,char **argv) + { +@@ -18,7 +19,7 @@ + if (!ustr) _exit(100); + scan_ulong(ustr,&u); + +- ut[0] = ut[1] = u; +- if (utime(fn,ut) == -1) _exit(111); ++ ut.actime = ut.modtime = u; ++ if (utime(fn,&ut) == -1) _exit(111); + _exit(0); + } diff --git a/pack/djbdns/tar b/pack/djbdns/tar @@ -0,0 +1 @@ +http://cr.yp.to/djbdns/djbdns-1.05.tar.gz diff --git a/pack/dmenu/tar b/pack/dmenu/tar @@ -0,0 +1 @@ +http://dl.suckless.org/tools/dmenu-4.6.tar.gz diff --git a/pack/dq/build b/pack/dq/build @@ -0,0 +1,7 @@ +#!/bin/sh -ex + +echo bin >conf-bin +echo share/man >conf-man +make + +sh -e ./make-install.sh "$PREFIX" diff --git a/pack/dq/tar b/pack/dq/tar @@ -0,0 +1 @@ +https://mojzis.com/software/dq/dq-20161210.tar.gz diff --git a/pack/drawterm/build b/pack/drawterm/build @@ -0,0 +1,14 @@ +#!/bin/sh -ex +case ($(uname)) in +(OpenBSD) export CONF=openbsd ;; +(FreeBSD) export CONF=freebsd ;; +(Solaris) export CONF=sun ;; +(*) export CONF=unix ;; +esac + +cd "$SOURCE" +make + +mkdir -p "$PREFIX/bin/" "$PREFIX/share/man/man1/" +cp drawterm "$PREFIX/bin/" +cp drawterm.1 "$PREFIX/share/man/man1/" diff --git a/pack/drawterm/tar b/pack/drawterm/tar @@ -0,0 +1 @@ +https://code.9front.org/hg/drawterm/archive/tip.tar.gz diff --git a/pack/dvtm/build b/pack/dvtm/build @@ -0,0 +1,2 @@ +#!/bin/sh -ex +cp -f config.h config.mk $SOURCE diff --git a/pack/dvtm/config.h b/pack/dvtm/config.h @@ -0,0 +1,222 @@ +/* valid curses attributes are listed below they can be ORed + * + * A_NORMAL Normal display (no highlight) + * A_STANDOUT Best highlighting mode of the terminal. + * A_UNDERLINE Underlining + * A_REVERSE Reverse video + * A_BLINK Blinking + * A_DIM Half bright + * A_BOLD Extra bright or bold + * A_PROTECT Protected mode + * A_INVIS Invisible or blank mode + */ + +enum { + DEFAULT, + RED, + BLACK, +}; + +static Color colors[] = { + [DEFAULT] = { .fg = -1, .bg = -1, .fg256 = -1, .bg256 = -1, }, + [RED] = { .fg = COLOR_RED, .bg = -1, .fg256 = 1, .bg256 = -1, }, + [BLACK] = { .fg = COLOR_BLACK, .bg = -1, .fg256 = 0, .bg256 = -1, }, +}; + +#define COLOR(c) COLOR_PAIR(colors[c].pair) +/* curses attributes for the currently focused window */ +#define SELECTED_ATTR A_BOLD +/* curses attributes for normal (not selected) windows */ +#define NORMAL_ATTR (COLOR(BLACK) | A_BOLD) +/* curses attributes for a window with pending urgent flag */ +#define URGENT_ATTR (COLOR(RED) | A_BOLD) +/* curses attributes for the status bar */ +#define BAR_ATTR (COLOR(DEFAULT) | A_NORMAL) +/* characters for beginning and end of status bar message */ +#define BAR_BEGIN ' ' +#define BAR_END ' ' +/* status bar (command line option -s) position */ +#define BAR_POS BAR_TOP /* BAR_BOTTOM, BAR_OFF */ +/* whether status bar should be hidden if only one client exists */ +#define BAR_AUTOHIDE false +/* master width factor [0.1 .. 0.9] */ +#define MFACT 0.5 +/* number of clients in master area */ +#define NMASTER 1 +/* scroll back buffer size in lines */ +#define SCROLL_HISTORY 500 +/* printf format string for the tag in the status bar */ +#define TAG_SYMBOL " %s " +/* curses attributes for the currently selected tags */ +#define TAG_SEL (COLOR(DEFAULT) | A_REVERSE) +/* curses attributes for not selected tags which contain no windows */ +#define TAG_NORMAL (COLOR(BLACK) | A_BOLD) +/* curses attributes for not selected tags which contain windows */ +#define TAG_OCCUPIED (COLOR(DEFAULT) | A_BOLD) +/* curses attributes for not selected tags which with urgent windows */ +#define TAG_URGENT (COLOR(RED) | A_BOLD) + +const char tags[][8] = { "1", "2", "3", "4", "5" }; + +#include "tile.c" +#include "grid.c" +#include "bstack.c" +#include "tstack.c" +#include "vstack.c" +#include "fullscreen.c" +#include "fibonacci.c" + +/* by default the first layout entry is used */ +static Layout layouts[] = { + { "[f]", tile }, + { "[b]", bstack }, + { "[u]", tstack }, + { "[n]", vstack }, + { "[g]", grid }, + { "[o]", spiral }, + { "[w]", dwindle }, + { "[m]", fullscreen }, +}; + +#define MOD CTRL('@') +#define TAGKEYS(KEY,TAG) \ + { { MOD, 'v', KEY, }, { view, { tags[TAG] } } }, \ + { { MOD, 't', KEY, }, { tag, { tags[TAG] } } }, \ + { { MOD, 'V', KEY, }, { toggleview, { tags[TAG] } } }, \ + { { MOD, 'T', KEY, }, { toggletag, { tags[TAG] } } }, + +/* you can specifiy at most 3 arguments */ +static KeyBinding bindings[] = { + { { MOD, 'c', }, { create, { NULL } } }, + { { MOD, 'C', }, { create, { NULL, NULL, "$CWD" } } }, + { { MOD, 'x', 'x', }, { killclient, { NULL } } }, + { { MOD, 'j', }, { focusnext, { NULL } } }, + { { MOD, 'J', }, { focusdown, { NULL } } }, + { { MOD, 'K', }, { focusup, { NULL } } }, + { { MOD, 'H', }, { focusleft, { NULL } } }, + { { MOD, 'L', }, { focusright, { NULL } } }, + { { MOD, 'k', }, { focusprev, { NULL } } }, + { { MOD, 'f', }, { setlayout, { "[f]" } } }, + { { MOD, 'b', }, { setlayout, { "[b]" } } }, + { { MOD, 'u', }, { setlayout, { "[u]" } } }, + { { MOD, 'n', }, { setlayout, { "[n]" } } }, + { { MOD, 'g', }, { setlayout, { "[g]" } } }, + { { MOD, 'o', }, { setlayout, { "[o]" } } }, + { { MOD, 'w', }, { setlayout, { "[w]" } } }, + { { MOD, 'm', }, { setlayout, { "[m]" } } }, + { { MOD, ' ', }, { setlayout, { NULL } } }, + { { MOD, 'i', }, { incnmaster, { "+1" } } }, + { { MOD, 'd', }, { incnmaster, { "-1" } } }, + { { MOD, 'h', }, { setmfact, { "-0.05" } } }, + { { MOD, 'l', }, { setmfact, { "+0.05" } } }, + { { MOD, '.', }, { toggleminimize, { NULL } } }, + { { MOD, 's', }, { togglebar, { NULL } } }, + { { MOD, 'S', }, { togglebarpos, { NULL } } }, + { { MOD, 'M', }, { togglemouse, { NULL } } }, + { { MOD, '\n', }, { zoom , { NULL } } }, + { { MOD, '\r', }, { zoom , { NULL } } }, + { { MOD, '1', }, { focusn, { "1" } } }, + { { MOD, '2', }, { focusn, { "2" } } }, + { { MOD, '3', }, { focusn, { "3" } } }, + { { MOD, '4', }, { focusn, { "4" } } }, + { { MOD, '5', }, { focusn, { "5" } } }, + { { MOD, '6', }, { focusn, { "6" } } }, + { { MOD, '7', }, { focusn, { "7" } } }, + { { MOD, '8', }, { focusn, { "8" } } }, + { { MOD, '9', }, { focusn, { "9" } } }, + { { MOD, '\t', }, { focuslast, { NULL } } }, + { { MOD, 'q', 'q', }, { quit, { NULL } } }, + { { MOD, 'a', }, { togglerunall, { NULL } } }, + { { MOD, CTRL('L'), }, { redraw, { NULL } } }, + { { MOD, 'r', }, { redraw, { NULL } } }, + { { MOD, 'e', }, { copymode, { "dvtm-editor" } } }, + { { MOD, 'E', }, { copymode, { "dvtm-pager" } } }, + { { MOD, '/', }, { copymode, { "dvtm-pager", "/" } } }, + { { MOD, 'p', }, { paste, { NULL } } }, + { { MOD, KEY_PPAGE, }, { scrollback, { "-1" } } }, + { { MOD, KEY_NPAGE, }, { scrollback, { "1" } } }, + { { MOD, '?', }, { create, { "man dvtm", "dvtm help" } } }, + { { MOD, MOD, }, { send, { (const char []){MOD, 0} } } }, + { { KEY_SPREVIOUS, }, { scrollback, { "-1" } } }, + { { KEY_SNEXT, }, { scrollback, { "1" } } }, + { { MOD, '0', }, { view, { NULL } } }, + { { MOD, KEY_F(1), }, { view, { tags[0] } } }, + { { MOD, KEY_F(2), }, { view, { tags[1] } } }, + { { MOD, KEY_F(3), }, { view, { tags[2] } } }, + { { MOD, KEY_F(4), }, { view, { tags[3] } } }, + { { MOD, KEY_F(5), }, { view, { tags[4] } } }, + { { MOD, 'v', '0' }, { view, { NULL } } }, + { { MOD, 'v', '\t', }, { viewprevtag, { NULL } } }, + { { MOD, 't', '0' }, { tag, { NULL } } }, + TAGKEYS( '1', 0) + TAGKEYS( '2', 1) + TAGKEYS( '3', 2) + TAGKEYS( '4', 3) + TAGKEYS( '5', 4) +}; + +static const ColorRule colorrules[] = { + { "", A_NORMAL, &colors[DEFAULT] }, /* default */ +}; + +/* possible values for the mouse buttons are listed below: + * + * BUTTON1_PRESSED mouse button 1 down + * BUTTON1_RELEASED mouse button 1 up + * BUTTON1_CLICKED mouse button 1 clicked + * BUTTON1_DOUBLE_CLICKED mouse button 1 double clicked + * BUTTON1_TRIPLE_CLICKED mouse button 1 triple clicked + * BUTTON2_PRESSED mouse button 2 down + * BUTTON2_RELEASED mouse button 2 up + * BUTTON2_CLICKED mouse button 2 clicked + * BUTTON2_DOUBLE_CLICKED mouse button 2 double clicked + * BUTTON2_TRIPLE_CLICKED mouse button 2 triple clicked + * BUTTON3_PRESSED mouse button 3 down + * BUTTON3_RELEASED mouse button 3 up + * BUTTON3_CLICKED mouse button 3 clicked + * BUTTON3_DOUBLE_CLICKED mouse button 3 double clicked + * BUTTON3_TRIPLE_CLICKED mouse button 3 triple clicked + * BUTTON4_PRESSED mouse button 4 down + * BUTTON4_RELEASED mouse button 4 up + * BUTTON4_CLICKED mouse button 4 clicked + * BUTTON4_DOUBLE_CLICKED mouse button 4 double clicked + * BUTTON4_TRIPLE_CLICKED mouse button 4 triple clicked + * BUTTON_SHIFT shift was down during button state change + * BUTTON_CTRL control was down during button state change + * BUTTON_ALT alt was down during button state change + * ALL_MOUSE_EVENTS report all button state changes + * REPORT_MOUSE_POSITION report mouse movement + */ + +#ifdef NCURSES_MOUSE_VERSION +# define CONFIG_MOUSE /* compile in mouse support if we build against ncurses */ +#endif + +#define ENABLE_MOUSE true /* whether to enable mouse events by default */ + +#ifdef CONFIG_MOUSE +static Button buttons[] = { + { BUTTON1_CLICKED, { mouse_focus, { NULL } } }, + { BUTTON1_DOUBLE_CLICKED, { mouse_fullscreen, { "[ ]" } } }, + { BUTTON2_CLICKED, { mouse_zoom, { NULL } } }, + { BUTTON3_CLICKED, { mouse_minimize, { NULL } } }, +}; +#endif /* CONFIG_MOUSE */ + +static Cmd commands[] = { + /* create [cmd...]: create a new window, run `cmd` in the shell if specified */ + { "create", { create, { NULL } } }, + /* focus <win_id>: focus the window whose `DVTM_WINDOW_ID` is `win_id` */ + { "focus", { focusid, { NULL } } }, + /* tag <win_id> <tag> [tag ...]: add +tag, remove -tag or set tag of the window with the given identifier */ + { "tag", { tagid, { NULL } } }, +}; + +/* gets executed when dvtm is started */ +static Action actions[] = { + { create, { NULL } }, +}; + +static char const * const keytable[] = { + /* add your custom key escape sequences */ +}; diff --git a/pack/dvtm/config.mk b/pack/dvtm/config.mk @@ -0,0 +1,14 @@ +# Customize below to fit your system + +PREFIX ?= /usr/local +MANPREFIX = ${PREFIX}/share/man +# specify your systems terminfo directory +# leave empty to install into your home folder +TERMINFO = + +INCS = -I. +LIBS = -lc -lutil -lcurses +CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE +CFLAGS += -std=c99 ${INCS} -DNDEBUG ${CPPFLAGS} + +CC ?= cc diff --git a/pack/dvtm/git b/pack/dvtm/git @@ -0,0 +1 @@ +git://github.com/martanne/dvtm diff --git a/pack/dwm/build b/pack/dwm/build @@ -0,0 +1,5 @@ +#!/bin/sh -ex + +cp $PACK/config.h $PACK/config.mk . + +make PREIFX=$PREFIX install diff --git a/pack/dwm/config.h b/pack/dwm/config.h @@ -0,0 +1,133 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ +static const int showbar = 1; /* 0 means no bar */ +static const int topbar = 1; /* 0 means bottom bar */ +static const char *fonts[] = { "terminus:pixelsize=16" }; +static const char dmenufont[] = "terminus:pixelsize=16"; +static const char termfont[] = "terminus:pixelsize=16"; +static const char col_light[] = "#dddddd"; +static const char col_shade[] = "#333333"; +static const char col_black[] = "#000000"; +static const char col_tint[] = "#00ff99"; +static const char *colors[][3] = { + /* fg bg border */ + [SchemeNorm] = { col_light, col_black, col_shade }, + [SchemeSel] = { col_shade, col_light, col_tint }, +}; + +/* tagging */ +static const char *tags[] = { "1:term", "2:web", "3:media", "4:chat" }; + +static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ + /* class instance title tags mask isfloating monitor */ + { "acme", NULL, NULL, 1 << 0, 0, -1 }, + { "Chrome", NULL, NULL, 1 << 1, 0, -1 }, + { "Iceweasel", NULL, NULL, 1 << 1, 0, -1 }, + { "Firefox", NULL, NULL, 1 << 1, 0, -1 }, + { "Surf", NULL, NULL, 1 << 1, 0, -1 }, + { "Midori", NULL, NULL, 1 << 1, 0, -1 }, + { "Zathura", NULL, NULL, 1 << 2, 0, -1 }, + { "MuPDF", NULL, NULL, 1 << 2, 0, -1 }, + { "ffplay", NULL, NULL, 1 << 2, 0, -1 }, + { "avplay", NULL, NULL, 1 << 2, 0, -1 }, + { "SDL_App", NULL, NULL, 1 << 2, 0, -1 }, + { "MPlayer", NULL, NULL, 1 << 2, 0, -1 }, + { NULL, "libreoffice", NULL, 1 << 2, 0, -1 }, + { "Blender", NULL, NULL, 1 << 2, 0, -1 }, + { "Gimp", NULL, NULL, 1 << 2, 0, -1 }, + { "sent", NULL, NULL, 1 << 2, 0, -1 }, +}; + +/* layout(s) */ +static const float mfact = 0.50; /* factor of master area size [0.05..0.95] */ +static const int nmaster = 1; /* number of clients in master area */ +static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ + +static const Layout layouts[] = { + /* symbol arrange function */ + { "[t]", tile }, /* first entry is default */ + { "[f]", NULL }, /* no layout function means floating behavior */ + { "[m]", monocle }, +}; + +/* key definitions */ +#define MODKEY Mod4Mask +#define TAGKEYS(KEY,TAG) \ + { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ + { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, + +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + +/* commands */ +static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_shade, "-nf", col_light, "-sb", col_light, "-sf", col_shade, NULL }; +static const char *termcmd[] = { "st", "-f", termfont, NULL }; +static const char *menucmd[] = { "st", "-f", termfont, "-e", "io", NULL }; +static const char *opencmd[] = { "st", "-f", termfont, "-e", "plumb", NULL }; +static const char *pstrcmd[] = { "st", "-f", termfont, "-e", "rc", "-c", "ptree | less -S", NULL }; + +static Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_space, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_o, spawn, {.v = menucmd } }, + { MODKEY, XK_p, spawn, {.v = opencmd } }, + { MODKEY, XK_x, spawn, {.v = pstrcmd } }, + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.02} }, + { MODKEY, XK_l, setmfact, {.f = +0.02} }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY, XK_BackSpace, killclient, {0} }, + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY, XK_Escape, quit, {0} }, +}; + +/* button definitions */ +/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +static Button buttons[] = { + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + { ClkTagBar, 0, Button1, view, {0} }, + { ClkTagBar, 0, Button3, toggleview, {0} }, + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, +}; diff --git a/pack/dwm/config.mk b/pack/dwm/config.mk @@ -0,0 +1,37 @@ +# dwm version +VERSION = 6.1 + +# Customize below to fit your system + +# paths +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man + +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib + +# Xinerama, comment if you don't want it +XINERAMALIBS = -lXinerama +XINERAMAFLAGS = -DXINERAMA + +# freetype +FREETYPELIBS = -lfontconfig -lXft +# OpenBSD (uncomment) +FREETYPEINC = ${X11INC}/freetype2 + +# includes and libs +INCS = -I${X11INC} -I${FREETYPEINC} +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} + +# flags +CPPFLAGS = -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} +CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS} +LDFLAGS = -s ${LIBS} + +# Solaris +#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" +#LDFLAGS = ${LIBS} + +# compiler and linker +CC = cc diff --git a/pack/dwm/git b/pack/dwm/git @@ -0,0 +1 @@ +git://git.suckless.org/dwm diff --git a/pack/ed/git b/pack/ed/git @@ -0,0 +1 @@ +git://git.2f30.org/ed diff --git a/pack/eel/git b/pack/eel/git @@ -0,0 +1 @@ +git://josuah.net/eel diff --git a/pack/enchive/tar b/pack/enchive/tar @@ -0,0 +1 @@ +http://github.com/skeeto/enchive/archive/master.tar.gz diff --git a/pack/entr/build b/pack/entr/build @@ -0,0 +1,3 @@ +#!/bin/sh -ex +./configure +make PREFIX=$PREFIX MANPREFIX=$PREFIX/share/man/ install diff --git a/pack/entr/tar b/pack/entr/tar @@ -0,0 +1 @@ +http://entrproject.org/code/entr-3.8.tar.gz diff --git a/pack/execline/build b/pack/execline/build @@ -0,0 +1,9 @@ +#!/bin/sh -ex + +./configure \ + --prefix=$PREFIX/ \ + --with-sysdeps=$DEST/lib/skalibs/sysdeps \ + --with-include=$DEST/include \ + --with-lib=$DEST/lib/skalibs + +gmake install diff --git a/pack/execline/tar b/pack/execline/tar @@ -0,0 +1 @@ +http://skarnet.org/software/execline/execline-2.5.0.0.tar.gz diff --git a/pack/ezmlm/tar b/pack/ezmlm/tar @@ -0,0 +1 @@ +https://cr.yp.to/software/ezmlm-0.53.tar.gz diff --git a/pack/farbfeld-resize/git b/pack/farbfeld-resize/git @@ -0,0 +1 @@ +git://github.com/ender672/farbfeld-resize diff --git a/pack/farbfeld/build b/pack/farbfeld/build @@ -0,0 +1,2 @@ +#!/bin/sh -ex +cp config.mk $SOURCE/config.mk diff --git a/pack/farbfeld/config.mk b/pack/farbfeld/config.mk @@ -0,0 +1,18 @@ +# farbfeld version +VERSION = 3 + +# Customize below to fit your system + +# paths +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man + +# flags +CPPFLAGS = -D_DEFAULT_SOURCE +CFLAGS = -std=c99 -pedantic -Wall -Wextra -Os -I'$(PACK)/include' +LDFLAGS = -s +PNG-LDFLAGS = -lpng -L'$(root)/lib' +JPG-LDFLAGS = -ljpeg -L'$(root)/lib' + +# compiler and linker +CC = cc diff --git a/pack/farbfeld/tar b/pack/farbfeld/tar @@ -0,0 +1 @@ +http://dl.suckless.org/farbfeld/farbfeld-3.tar.gz diff --git a/pack/ff2txt/git b/pack/ff2txt/git @@ -0,0 +1 @@ +git://bitreich.org/ff2txt diff --git a/pack/fluxcapacitor/git b/pack/fluxcapacitor/git @@ -0,0 +1 @@ +git://github.com/majek/fluxcapacitor diff --git a/pack/geomyidae/tar b/pack/geomyidae/tar @@ -0,0 +1 @@ +http://git.r-36.net/geomyidae/snapshot/geomyidae-HEAD.tar.gz diff --git a/pack/ghostscript/tar b/pack/ghostscript/tar @@ -0,0 +1 @@ +https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs922/ghostscript-9.22.tar.gz diff --git a/pack/git/build b/pack/git/build @@ -0,0 +1,4 @@ +#!/bin/sh -ex + +./configure --prefix="$PREFIX" \ + --without-tcltk diff --git a/pack/git/tar b/pack/git/tar @@ -0,0 +1 @@ +http://www.kernel.org/pub/software/scm/git/git-2.10.0.tar.gz diff --git a/pack/gmake/build b/pack/gmake/build @@ -0,0 +1,4 @@ +#!/bin/sh -ex +./configure --prefix="$PREFIX" --program-prefix=g +./build.sh +./make install diff --git a/pack/gmake/tar b/pack/gmake/tar @@ -0,0 +1 @@ +http://mirror.ibcp.fr/pub/gnu/make/make-4.2.tar.gz diff --git a/pack/gophermap/git b/pack/gophermap/git @@ -0,0 +1 @@ +git://josuah.net/gophermap diff --git a/pack/icecast/tar b/pack/icecast/tar @@ -0,0 +1 @@ +http://downloads.xiph.org/releases/icecast/icecast-2.4.3.tar.gz diff --git a/pack/ics2txt/git b/pack/ics2txt/git @@ -0,0 +1 @@ +git://bitreich.org/ics2txt diff --git a/pack/ii/build b/pack/ii/build @@ -0,0 +1,5 @@ +#!/bin/sh -ex + +! patch -N -p1 <$PACK/ii-1.8-ucspi.diff + +make PREFIX="$PREFIX" install diff --git a/pack/ii/git b/pack/ii/git @@ -0,0 +1 @@ +git://git.suckless.org/ii diff --git a/pack/ii/ii-1.8-ucspi.diff b/pack/ii/ii-1.8-ucspi.diff @@ -0,0 +1,335 @@ +diff -up ii-1.8/ii.c ii-1.8-mod/ii.c +--- ii-1.8/ii.c Sun Feb 4 14:36:09 2018 ++++ ii-1.8-mod/ii.c Mon Feb 26 22:24:36 2018 +@@ -1,16 +1,13 @@ + /* See LICENSE file for license details. */ + #include <sys/select.h> +-#include <sys/socket.h> + #include <sys/stat.h> + #include <sys/types.h> +-#include <sys/un.h> + + #include <ctype.h> + #include <errno.h> + #include <fcntl.h> + #include <limits.h> + #include <netdb.h> +-#include <netinet/in.h> + #include <pwd.h> + #include <signal.h> + #include <stdarg.h> +@@ -20,6 +17,9 @@ + #include <time.h> + #include <unistd.h> + ++#define READ_FD 6 ++#define WRITE_FD 7 ++ + char *argv0; + + #include "arg.h" +@@ -56,16 +56,16 @@ static void channel_rm(Channel *); + static void create_dirtree(const char *); + static void create_filepath(char *, size_t, const char *, const char *, const char *); + static void ewritestr(int, const char *); +-static void handle_channels_input(int, Channel *); +-static void handle_server_output(int); ++static void handle_channels_input(Channel *); ++static void handle_server_output(void); + static int isnumeric(const char *); +-static void loginkey(int, const char *); +-static void loginuser(int, const char *, const char *); +-static void proc_channels_input(int, Channel *, char *); +-static void proc_channels_privmsg(int, Channel *, char *); +-static void proc_server_cmd(int, char *); ++static void loginkey(const char *); ++static void loginuser(const char *, const char *); ++static void proc_channels_input(Channel *, char *); ++static void proc_channels_privmsg(Channel *, char *); ++static void proc_server_cmd(char *); + static int read_line(int, char *, size_t); +-static void run(int, const char *); ++static void run(const char *); + static void setup(void); + static void sighandler(int); + static int tcpopen(const char *, const char *); +@@ -319,84 +319,22 @@ channel_leave(Channel *c) + } + + static void +-loginkey(int ircfd, const char *key) ++loginkey(const char *key) + { + snprintf(msg, sizeof(msg), "PASS %s\r\n", key); +- ewritestr(ircfd, msg); ++ ewritestr(WRITE_FD, msg); + } + + static void +-loginuser(int ircfd, const char *host, const char *fullname) ++loginuser(const char *host, const char *fullname) + { + snprintf(msg, sizeof(msg), "NICK %s\r\nUSER %s localhost %s :%s\r\n", + nick, nick, host, fullname); + puts(msg); +- ewritestr(ircfd, msg); ++ ewritestr(WRITE_FD, msg); + } + + static int +-udsopen(const char *uds) +-{ +- struct sockaddr_un sun; +- size_t len; +- int fd; +- +- if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { +- fprintf(stderr, "%s: socket: %s\n", argv0, strerror(errno)); +- exit(1); +- } +- +- sun.sun_family = AF_UNIX; +- if (strlcpy(sun.sun_path, uds, sizeof(sun.sun_path)) >= sizeof(sun.sun_path)) { +- fprintf(stderr, "%s: UNIX domain socket path truncation\n", argv0); +- exit(1); +- } +- len = strlen(sun.sun_path) + 1 + sizeof(sun.sun_family); +- if (connect(fd, (struct sockaddr *)&sun, len) == -1) { +- fprintf(stderr, "%s: connect: %s\n", argv0, strerror(errno)); +- exit(1); +- } +- return fd; +-} +- +-static int +-tcpopen(const char *host, const char *service) +-{ +- struct addrinfo hints, *res = NULL, *rp; +- int fd = -1, e; +- +- memset(&hints, 0, sizeof(hints)); +- hints.ai_family = AF_UNSPEC; /* allow IPv4 or IPv6 */ +- hints.ai_flags = AI_NUMERICSERV; /* avoid name lookup for port */ +- hints.ai_socktype = SOCK_STREAM; +- +- if ((e = getaddrinfo(host, service, &hints, &res))) { +- fprintf(stderr, "%s: getaddrinfo: %s\n", argv0, gai_strerror(e)); +- exit(1); +- } +- +- for (rp = res; rp; rp = rp->ai_next) { +- fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); +- if (fd == -1) +- continue; +- if (connect(fd, res->ai_addr, res->ai_addrlen) == -1) { +- close(fd); +- fd = -1; +- continue; +- } +- break; /* success */ +- } +- if (fd == -1) { +- fprintf(stderr, "%s: could not connect to %s:%s: %s\n", +- argv0, host, service, strerror(errno)); +- exit(1); +- } +- +- freeaddrinfo(res); +- return fd; +-} +- +-static int + isnumeric(const char *s) + { + errno = 0; +@@ -445,22 +383,22 @@ channel_print(Channel *c, const char *buf) + } + + static void +-proc_channels_privmsg(int ircfd, Channel *c, char *buf) ++proc_channels_privmsg(Channel *c, char *buf) + { + snprintf(msg, sizeof(msg), "<%s> %s", nick, buf); + channel_print(c, msg); + snprintf(msg, sizeof(msg), "PRIVMSG %s :%s\r\n", c->name, buf); +- ewritestr(ircfd, msg); ++ ewritestr(WRITE_FD, msg); + } + + static void +-proc_channels_input(int ircfd, Channel *c, char *buf) ++proc_channels_input(Channel *c, char *buf) + { + char *p = NULL; + size_t buflen; + + if (buf[0] != '/' && buf[0] != '\0') { +- proc_channels_privmsg(ircfd, c, buf); ++ proc_channels_privmsg(c, buf); + return; + } + msg[0] = '\0'; +@@ -481,7 +419,7 @@ proc_channels_input(int ircfd, Channel *c, char *buf) + channel_join(&buf[3]); + } else if (p) { + if ((c = channel_join(&buf[3]))) +- proc_channels_privmsg(ircfd, c, p + 1); ++ proc_channels_privmsg(c, p + 1); + return; + } + break; +@@ -513,7 +451,7 @@ proc_channels_input(int ircfd, Channel *c, char *buf) + else + snprintf(msg, sizeof(msg), + "PART %s :leaving\r\n", c->name); +- ewritestr(ircfd, msg); ++ ewritestr(WRITE_FD, msg); + channel_leave(c); + return; + break; +@@ -523,7 +461,7 @@ proc_channels_input(int ircfd, Channel *c, char *buf) + else + snprintf(msg, sizeof(msg), + "QUIT %s\r\n", "bye"); +- ewritestr(ircfd, msg); ++ ewritestr(WRITE_FD, msg); + isrunning = 0; + return; + break; +@@ -536,11 +474,11 @@ proc_channels_input(int ircfd, Channel *c, char *buf) + snprintf(msg, sizeof(msg), "%s\r\n", &buf[1]); + } + if (msg[0] != '\0') +- ewritestr(ircfd, msg); ++ ewritestr(WRITE_FD, msg); + } + + static void +-proc_server_cmd(int fd, char *buf) ++proc_server_cmd(char *buf) + { + Channel *c; + const char *channel; +@@ -588,7 +526,7 @@ proc_server_cmd(int fd, char *buf) + return; + } else if (!strcmp("PING", argv[TOK_CMD])) { + snprintf(msg, sizeof(msg), "PONG %s\r\n", argv[TOK_TEXT]); +- ewritestr(fd, msg); ++ ewritestr(WRITE_FD, msg); + return; + } else if (!argv[TOK_NICKSRV] || !argv[TOK_USER]) { + /* server command */ +@@ -675,7 +613,7 @@ read_line(int fd, char *buf, size_t bufsiz) + } + + static void +-handle_channels_input(int ircfd, Channel *c) ++handle_channels_input(Channel *c) + { + char buf[IRC_MSG_MAX]; + +@@ -684,22 +622,22 @@ handle_channels_input(int ircfd, Channel *c) + channel_rm(c); + return; + } +- proc_channels_input(ircfd, c, buf); ++ proc_channels_input(c, buf); + } + + static void +-handle_server_output(int ircfd) ++handle_server_output(void) + { + char buf[IRC_MSG_MAX]; + +- if (read_line(ircfd, buf, sizeof(buf)) == -1) { ++ if (read_line(READ_FD, buf, sizeof(buf)) == -1) { + fprintf(stderr, "%s: remote host closed connection: %s\n", + argv0, strerror(errno)); + exit(1); + } + fprintf(stdout, "%lu %s\n", (unsigned long)time(NULL), buf); + fflush(stdout); +- proc_server_cmd(ircfd, buf); ++ proc_server_cmd(buf); + } + + static void +@@ -721,7 +659,7 @@ setup(void) + } + + static void +-run(int ircfd, const char *host) ++run(const char *host) + { + Channel *c, *tmp; + fd_set rdset; +@@ -731,9 +669,9 @@ run(int ircfd, const char *host) + + snprintf(ping_msg, sizeof(ping_msg), "PING %s\r\n", host); + while (isrunning) { +- maxfd = ircfd; ++ maxfd = READ_FD; + FD_ZERO(&rdset); +- FD_SET(ircfd, &rdset); ++ FD_SET(READ_FD, &rdset); + for (c = channels; c; c = c->next) { + if (c->fdin > maxfd) + maxfd = c->fdin; +@@ -752,17 +690,17 @@ run(int ircfd, const char *host) + channel_print(channelmaster, "-!- ii shutting down: ping timeout"); + exit(2); /* status code 2 for timeout */ + } +- ewritestr(ircfd, ping_msg); ++ ewritestr(WRITE_FD, ping_msg); + continue; + } +- if (FD_ISSET(ircfd, &rdset)) { +- handle_server_output(ircfd); ++ if (FD_ISSET(READ_FD, &rdset)) { ++ handle_server_output(); + last_response = time(NULL); + } + for (c = channels; c; c = tmp) { + tmp = c->next; + if (FD_ISSET(c->fdin, &rdset)) +- handle_channels_input(ircfd, c); ++ handle_channels_input(c); + } + } + } +@@ -775,7 +713,7 @@ main(int argc, char *argv[]) + const char *key = NULL, *fullname = NULL, *host = ""; + const char *uds = NULL, *service = "6667"; + char prefix[PATH_MAX]; +- int ircfd, r; ++ int r; + + /* use nickname and home dir of user by default */ + if (!(spw = getpwuid(getuid()))) { +@@ -815,11 +753,6 @@ main(int argc, char *argv[]) + if (!*host) + usage(); + +- if (uds) +- ircfd = udsopen(uds); +- else +- ircfd = tcpopen(host, service); +- + #ifdef __OpenBSD__ + /* OpenBSD pledge(2) support */ + if (pledge("stdio rpath wpath cpath dpath", NULL) == -1) { +@@ -837,10 +770,10 @@ main(int argc, char *argv[]) + + channelmaster = channel_add(""); /* master channel */ + if (key) +- loginkey(ircfd, key); +- loginuser(ircfd, host, fullname && *fullname ? fullname : nick); ++ loginkey(key); ++ loginuser(host, fullname && *fullname ? fullname : nick); + setup(); +- run(ircfd, host); ++ run(host); + if (channelmaster) + channel_leave(channelmaster); + diff --git a/pack/ii/tar b/pack/ii/tar @@ -0,0 +1 @@ +http://dl.suckless.org/tools/ii-1.8.tar.gz diff --git a/pack/iomenu/build b/pack/iomenu/build @@ -0,0 +1,3 @@ +#!/bin/sh -ex + +make PREFIX=$PREFIX install diff --git a/pack/iomenu/git b/pack/iomenu/git @@ -0,0 +1 @@ +git://bitreich.org/iomenu diff --git a/pack/ired/tar b/pack/ired/tar @@ -0,0 +1 @@ +http://www.radare.org/get/ired-0.5.0.tar.gz diff --git a/pack/irssi/build b/pack/irssi/build @@ -0,0 +1,13 @@ +#!/bin/sh -ex +export OPENSSL_CFLAGS = -I$PACK/include +export OPENSSL_LIBS = -L$PACK/lib -lssl + +cp -R * $SOURCE/ +cd $SOURCE +./configure \ + --prefix="$PREFIX" \ + --without-proxy \ + --with-perl=no \ + --with-otr=static \ + --with-libotr-prefix="$PACK/lib/" \ + --with-libotr-inc-prefix="$PACK/include/" \ diff --git a/pack/irssi/git b/pack/irssi/git @@ -0,0 +1 @@ +git://github.com/irssi/irssi/ diff --git a/pack/jq/tar b/pack/jq/tar @@ -0,0 +1 @@ +http://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz diff --git a/pack/lel/git b/pack/lel/git @@ -0,0 +1 @@ +git://git.2f30.org/lel.git diff --git a/pack/less/tar b/pack/less/tar @@ -0,0 +1 @@ +http://ftp.gnu.org/gnu/less/less-481.tar.gz diff --git a/pack/libalsa/tar b/pack/libalsa/tar @@ -0,0 +1 @@ +ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.1.5.tar.bz2 diff --git a/pack/libav/tar b/pack/libav/tar @@ -0,0 +1 @@ +https://libav.org/releases/libav-12.3.tar.xz diff --git a/pack/libbearssl/build b/pack/libbearssl/build @@ -0,0 +1,6 @@ +#!/bin/sh -ex +gmake +mkdir -p "$PREFIX/bin" "$PREFIX/lib" "$PREFIX/include" +cp build/brssl build/test* "$PREFIX/bin" +cp build/libbearssl.* "$PREFIX/lib" +cp inc/* "$PREFIX/include" diff --git a/pack/libbearssl/tar b/pack/libbearssl/tar @@ -0,0 +1 @@ +https://bearssl.org/bearssl-0.4.tar.gz diff --git a/pack/libbzip2/tar b/pack/libbzip2/tar @@ -0,0 +1 @@ +http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz diff --git a/pack/libc9/git b/pack/libc9/git @@ -0,0 +1 @@ +git://github.com/ftrvxmtrx/c9.git diff --git a/pack/libcurses/git b/pack/libcurses/git @@ -0,0 +1 @@ +git://github.com/sabotage-linux/netbsd-curses diff --git a/pack/libedit/tar b/pack/libedit/tar @@ -0,0 +1 @@ +https://thrysoee.dk/editline/libedit-20170329-3.1.tar.gz diff --git a/pack/libevent/tar b/pack/libevent/tar @@ -0,0 +1 @@ +https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz diff --git a/pack/libflac/tar b/pack/libflac/tar @@ -0,0 +1 @@ +http://downloads.xiph.org/releases/flac/flac-1.3.2.tar.xz diff --git a/pack/libgit2/build b/pack/libgit2/build @@ -0,0 +1,14 @@ +#!/bin/sh -ex +cp "$PACK/features.h" "$SOURCE/include/git2/sys/" + +rm -f "$SOURCE/src/hash/hash_generic.c" +rm -f "$SOURCE/src/hash/hash_win32.c" +rm -fR "$SOURCE/src/win32/" + +cc -c -fPIC -I../include/ -I./ -I../deps/http-parser/ \ + *.c */*.c */*/*.c ../deps/http-parser/*.c +cc -shared -o libgit2.so *.o + +mkdir -p "$PREFIX/lib/" +cp libgit2.so "$PREFIX//lib/" +cp -R "$SOURCE/include/" "$PREFIX/" diff --git a/pack/libgit2/features.h b/pack/libgit2/features.h @@ -0,0 +1,36 @@ +#ifndef INCLUDE_features_h__ +#define INCLUDE_features_h__ + +/* #undef GIT_DEBUG_POOL */ +/* #undef GIT_TRACE */ +#define GIT_THREADS 1 +/* #undef GIT_MSVC_CRTDBG */ + +#define GIT_ARCH_64 1 +/* #undef GIT_ARCH_32 */ + +/* #undef GIT_USE_ICONV */ +#define GIT_USE_NSEC 1 +#define GIT_USE_STAT_MTIM 1 +/* #undef GIT_USE_STAT_MTIMESPEC */ +/* #undef GIT_USE_STAT_MTIME_NSEC */ +#define GIT_USE_FUTIMENS 1 +/* #undef GIT_USE_REGCOMP_L */ + +/* #define GIT_SSH 1 */ +/* #define GIT_SSH_MEMORY_CREDENTIALS 1 */ + +/* #undef GIT_GSSAPI */ +/* #undef GIT_WINHTTP */ +/* #define GIT_CURL 1 */ + +/* #define GIT_HTTPS 1 */ +#define GIT_OPENSSL 1 +/* #undef GIT_SECURE_TRANSPORT */ + +#define GIT_SHA1_COLLISIONDETECT 1 +/* #undef GIT_SHA1_WIN32 */ +/* #undef GIT_SHA1_COMMON_CRYPTO */ +/* #undef GIT_SHA1_OPENSSL */ + +#endif diff --git a/pack/libgit2/tar b/pack/libgit2/tar @@ -0,0 +1 @@ +https://github.com/libgit2/libgit2/archive/v0.27.2.tar.gz diff --git a/pack/libhts/tar b/pack/libhts/tar @@ -0,0 +1 @@ +https://github.com/samtools/htslib/releases/download/1.8/htslib-1.8.tar.bz2 diff --git a/pack/libixp/tar b/pack/libixp/tar @@ -0,0 +1 @@ +http://dl.suckless.org/libs/libixp-0.5.tar.gz diff --git a/pack/libjpeg/tar b/pack/libjpeg/tar @@ -0,0 +1 @@ +http://ijg.org/files/jpegsrc.v9c.tar.gz diff --git a/pack/liblz4/git b/pack/liblz4/git @@ -0,0 +1 @@ +git://github.com/lz4/lz4 diff --git a/pack/liblzma/tar b/pack/liblzma/tar @@ -0,0 +1 @@ +https://tukaani.org/xz/xz-5.2.3.tar.gz diff --git a/pack/libmpg123/tar b/pack/libmpg123/tar @@ -0,0 +1 @@ +http://mpg123.org/download/mpg123-1.25.8.tar.bz2 diff --git a/pack/libmusl/tar b/pack/libmusl/tar @@ -0,0 +1 @@ +https://www.musl-libc.org/releases/musl-1.1.16.tar.gz diff --git a/pack/libogg/tar b/pack/libogg/tar @@ -0,0 +1 @@ +http://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.xz diff --git a/pack/libopus/tar b/pack/libopus/tar @@ -0,0 +1 @@ +https://archive.mozilla.org/pub/opus/opus-1.3-beta.tar.gz diff --git a/pack/libotr/tar b/pack/libotr/tar @@ -0,0 +1 @@ +https://otr.cypherpunks.ca/libotr-4.1.1.tar.gz diff --git a/pack/libowfat/tar b/pack/libowfat/tar @@ -0,0 +1 @@ +http://www.fefe.de/libowfat/libowfat-0.31.tar.xz diff --git a/pack/libpcap/tar b/pack/libpcap/tar @@ -0,0 +1 @@ +http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz diff --git a/pack/libpng/tar b/pack/libpng/tar @@ -0,0 +1 @@ +ftp://ftp-osl.osuosl.org/pub/libpng/src/libpng16/libpng-1.6.34.tar.xz diff --git a/pack/libressl/tar b/pack/libressl/tar @@ -0,0 +1 @@ +https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.6.0.tar.gz diff --git a/pack/libskarnet/build b/pack/libskarnet/build @@ -0,0 +1,4 @@ +#!/bin/sh -ex + +./configure --prefix="$PREFIX" +gmake install diff --git a/pack/libskarnet/tar b/pack/libskarnet/tar @@ -0,0 +1 @@ +http://skarnet.org/software/skalibs/skalibs-2.6.4.0.tar.gz diff --git a/pack/libsodium/tar b/pack/libsodium/tar @@ -0,0 +1 @@ +https://download.libsodium.org/libsodium/releases/libsodium-1.0.16.tar.gz diff --git a/pack/libtermkey/tar b/pack/libtermkey/tar @@ -0,0 +1 @@ +http://www.leonerd.org.uk/code/libtermkey/libtermkey-0.20.tar.gz diff --git a/pack/libtool/tar b/pack/libtool/tar @@ -0,0 +1 @@ +http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz diff --git a/pack/libtox/tar b/pack/libtox/tar @@ -0,0 +1 @@ +http://github.com/TokTok/c-toxcore/releases/download/v0.1.10/c-toxcore-0.1.10.tar.gz diff --git a/pack/libutf/git b/pack/libutf/git @@ -0,0 +1 @@ +git://github.com/cls/libutf diff --git a/pack/libvorbis/tar b/pack/libvorbis/tar @@ -0,0 +1 @@ +http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz diff --git a/pack/libvpx/tar b/pack/libvpx/tar @@ -0,0 +1 @@ +http://github.com/webmproject/libvpx/archive/v1.6.1.tar.gz diff --git a/pack/libx11/tar b/pack/libx11/tar @@ -0,0 +1 @@ +https://www.x.org/releases/X11R7.7/src/lib/libX11-1.5.0.tar.bz2 diff --git a/pack/libz/tar b/pack/libz/tar @@ -0,0 +1 @@ +https://sortix.org/libz/release/libz-1.2.8.2015.12.26.tar.gz diff --git a/pack/links2/build b/pack/links2/build @@ -0,0 +1,5 @@ +#!/bin/sh -ex +make +mkdir -p "$PREFIX/bin" "$PREFIX/share/man/man1" +cp links "$PREFIX/bin" +cp links.1 "$PREFIX/share/man/man1" diff --git a/pack/links2/git b/pack/links2/git @@ -0,0 +1 @@ +git://git.codemadness.org/links2 diff --git a/pack/man-freebsd/tar b/pack/man-freebsd/tar @@ -0,0 +1 @@ +https://www.freebsd.org/cgi/man.cgi?manpath=freebsd-release-ports diff --git a/pack/man-linux/tar b/pack/man-linux/tar @@ -0,0 +1 @@ +https://www.kernel.org/pub/linux/docs/man-pages/man-pages-4.11.tar.gz diff --git a/pack/man-plan9/tar b/pack/man-plan9/tar @@ -0,0 +1 @@ +https://www.freebsd.org/cgi/man.cgi?manpath=plan9 diff --git a/pack/man-posix/build b/pack/man-posix/build @@ -0,0 +1,3 @@ +#!/bin/sh -ex + +make PREFIX="$PREFIX" install diff --git a/pack/man-posix/tar b/pack/man-posix/tar @@ -0,0 +1 @@ +http://www.kernel.org/pub/linux/docs/man-pages/man-pages-posix/man-pages-posix-2013-a.tar.gz diff --git a/pack/mandoc/tar b/pack/mandoc/tar @@ -0,0 +1 @@ +http://mandoc.bsd.lv/snapshots/mandoc.tar.gz diff --git a/pack/mblaze/build b/pack/mblaze/build @@ -0,0 +1,3 @@ +#!/bin/sh -ex + +gmake PREFIX="$PREFIX" install diff --git a/pack/mblaze/tar b/pack/mblaze/tar @@ -0,0 +1 @@ +http://github.com/chneukirchen/mblaze/archive/master.tar.gz diff --git a/pack/ministat/git b/pack/ministat/git @@ -0,0 +1 @@ +git://git.vuxu.org/ministat diff --git a/pack/miniwi/git b/pack/miniwi/git @@ -0,0 +1 @@ +git://josuah.net/miniwi.git diff --git a/pack/mpop/build b/pack/mpop/build @@ -0,0 +1,8 @@ +#!/bin/sh -ex + +export libssl_CFLAGS="-I'$PACK/include'" +export libssl_LIBS="-L'$PACK/lib' -lssl -lcrypto" + +./configure --prefix="$PREFIX" + +make install diff --git a/pack/mpop/tar b/pack/mpop/tar @@ -0,0 +1 @@ +https://downloads.sourceforge.net/project/mpop/mpop/1.2.6/mpop-1.2.6.tar.xz diff --git a/pack/msmtp/build b/pack/msmtp/build @@ -0,0 +1,7 @@ +#!/bin/sh -ex +export libssl_CFLAGS="-I'$PACK/include'" +export libssl_LIBS="-L'$PACK/lib' -lssl -lcrypto" + +./configure --prefix="$PREFIX" --with-tls=openssl + +make install diff --git a/pack/msmtp/tar b/pack/msmtp/tar @@ -0,0 +1 @@ +http://downloads.sourceforge.net/project/msmtp/msmtp/1.6.5/msmtp-1.6.5.tar.xz diff --git a/pack/mujs/tar b/pack/mujs/tar @@ -0,0 +1 @@ +http://dev.mujs.com/downloads/mujs-1.0.0.tar.xz diff --git a/pack/mupdf/tar b/pack/mupdf/tar @@ -0,0 +1 @@ +https://mupdf.com/downloads/mupdf-1.12.0-source.tar.xz diff --git a/pack/netpgp/tar b/pack/netpgp/tar @@ -0,0 +1 @@ +http://www.netpgp.com/src/netpgp.tar.gz diff --git a/pack/ngircd/build b/pack/ngircd/build @@ -0,0 +1,2 @@ +#!/bin/sh -ex +./configure --sbindir="$PREFIX/bin" --with-openssl diff --git a/pack/ngircd/tar b/pack/ngircd/tar @@ -0,0 +1 @@ +http://ngircd.barton.de/pub/ngircd/ngircd-24.tar.gz diff --git a/pack/oksh/tar b/pack/oksh/tar @@ -0,0 +1 @@ +http://devio.us/%7Ebcallah/oksh/oksh-20180120.tar.gz diff --git a/pack/openssh/build.nero b/pack/openssh/build.nero @@ -0,0 +1,37 @@ +#!/bin/sh +set -e + +patch -p1 < "$PKGDIR"/openssh-sys_param.patch + +export CC="$CC -L$PACK/lib -isystem $PACK/include" + +[ -n "$CROSS_COMPILE" ] && CONFFLAGS="$CONFFLAGS --host=$CROSS_COMPILE" + +# prevent from installing some things (keysign and maybe others) setuid. +sed -i 's@-m 4711@-m 0750@g' Makefile.in + +CC="$CC -D_BSD_SOURCE -DMISSING_FD_MASK -DMISSING_NFDBITS" \ +./configure $CONFFLAGS --prefix="$OPT" \ + --sbindir="$OPT"/bin --libexecdir="$OPT"/lib/ssh \ + --sysconfdir="$OPT"/etc/ssh \ + --with-sysroot="$PACK" \ + --with-privsep-user=nobody \ + --with-xauth="$OPT"/bin/xauth \ + --with-ldflags="$LDFLAGS -Wl,-rpath-link=$PACK$OPT/lib" \ + --without-stackprotect \ + --with-md5-passwords --with-mantype=man --mandir="$OPT"/share/man \ + --disable-strip --disable-lastlog --disable-utmp --disable-utmpx --disable-btmp \ + --disable-wtmp --disable-wtmpx --disable-pututline --disable-pututxline + +mkdir netinet +touch netinet/in_systm.h + +sed -i '/USE_BTMP/d' config.h +sed -i '/USE_UTMP/d' config.h +sed -i 's@HAVE_DECL_HOWMANY 1@HAVE_DECL_HOWMANY 0@' config.h + +make $MAKEFLAGS + +#key generation is disabled for packaging +#the sshd service will create the keys on service prereqs +make DESTDIR="$PREFIX" install-nokeys diff --git a/pack/openssh/openssh-sys_param.patch b/pack/openssh/openssh-sys_param.patch @@ -0,0 +1,10 @@ +--- openssh-6.5p1.org/sshd.c ++++ openssh-6.5p1/sshd.c +@@ -44,6 +44,7 @@ + + #include "includes.h" + ++#include <sys/param.h> /* MAXHOSTNAMELEN */ + #include <sys/types.h> + #include <sys/ioctl.h> + #include <sys/socket.h> diff --git a/pack/openssh/tar b/pack/openssh/tar @@ -0,0 +1 @@ +https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.5p1.tar.gz diff --git a/pack/opentracker/git b/pack/opentracker/git @@ -0,0 +1 @@ +git://erdgeist.org/opentracker diff --git a/pack/opus-tools/tar b/pack/opus-tools/tar @@ -0,0 +1 @@ +https://archive.mozilla.org/pub/opus/opus-tools-0.1.10.tar.gz diff --git a/pack/ploot/git b/pack/ploot/git @@ -0,0 +1 @@ +git://bitreich.org/ploot diff --git a/pack/plstree/build b/pack/plstree/build @@ -0,0 +1,3 @@ +#!/bin/sh -e + +make PREFIX="$PREFIX" install diff --git a/pack/plstree/git b/pack/plstree/git @@ -0,0 +1 @@ +git://bitreich.org/plstree diff --git a/pack/qemu/build b/pack/qemu/build @@ -0,0 +1,2 @@ +#!/bin/sh -ex +./configure --python=python3 diff --git a/pack/qemu/tar b/pack/qemu/tar @@ -0,0 +1 @@ +https://download.qemu.org/qemu-2.12.0-rc3.tar.xz diff --git a/pack/qmail/build b/pack/qmail/build @@ -0,0 +1,16 @@ +#!/bin/sh -ex +echo gcc -O2 -include /usr/include/errno.h >conf-cc +echo "$PREFIX/bin" >conf-bin +echo "$PREFIX/man" >conf-man +echo /home/qmail >conf-qmail + +mkdir -p "$PREFIX/bin" +mkdir -p "$PREFIX/share" + +ln -sf "$(whatis troff)" nroff +export PATH=$PWD:$PATH + +make setup check +./config +cp -r /home/qmail/bin "$PREFIX" +cp -r /home/qmail/man "$PREFIX/share/" diff --git a/pack/qmail/tar b/pack/qmail/tar @@ -0,0 +1 @@ +http://www.qmail.org/netqmail-1.06.tar.gz diff --git a/pack/quark/build b/pack/quark/build @@ -0,0 +1,5 @@ +#!/bin/sh -e + +cp "$PACK/config.h" . + +make PREFIX="$PREFIX" install diff --git a/pack/quark/config.h b/pack/quark/config.h @@ -0,0 +1,59 @@ +static const char *host = "localhost"; +static const char *port = "80"; +static const char *servedir = "."; +static const char *docindex = "index.html"; +static const char *user = "nobody"; +static const char *group = "nogroup"; + +static int listdirs = 1; +static int vhosts = 0; + +static const int maxnprocs = 512; +#define HEADER_MAX 4096 +#define FIELD_MAX 200 + +/* virtual hosts */ +static struct { + const char *name; + const char *regex; + const char *dir; + regex_t re; +} vhost[] = { + /* canonical host host regex directory */ + { "josuah.net", "josuah\\.net$", "josuah.net" }, + { "cyberia.systems", "cyberia\\.systems$", "cyberia.systems" }, + { "atelier-fu.fr", "atelier-fu\\.fr", "atelier-fu.fr" } +}; + +/* mime-types */ +static const struct { + char *ext; + char *type; +} mimes[] = { + { "xml", "application/xml" }, + { "xhtml", "application/xhtml+xml" }, + { "html", "text/html; charset=UTF-8" }, + { "htm", "text/html; charset=UTF-8" }, + { "css", "text/css" }, + { "txt", "text/plain" }, + { "md", "text/plain" }, + { "c", "text/plain" }, + { "h", "text/plain" }, + { "gz", "application/x-gtar" }, + { "tar", "application/tar" }, + { "pdf", "application/x-pdf" }, + { "png", "image/png" }, + { "gif", "image/gif" }, + { "jpeg", "image/jpg" }, + { "jpg", "image/jpg" }, + { "iso", "application/x-iso9660-image" }, + { "webp", "image/webp" }, + { "svg", "image/svg+xml" }, + { "flac", "audio/flac" }, + { "mp3", "audio/mpeg" }, + { "opus", "audio/ogg" }, + { "ogg", "audio/ogg" }, + { "mp4", "video/mp4" }, + { "ogv", "video/ogg" }, + { "webm", "video/webm" }, +}; diff --git a/pack/quark/git b/pack/quark/git @@ -0,0 +1 @@ +git://git.suckless.org/quark diff --git a/pack/radare2/build b/pack/radare2/build @@ -0,0 +1,2 @@ +#!/bin/sh -ex +export LDFLAGS=-lm diff --git a/pack/radare2/git b/pack/radare2/git @@ -0,0 +1 @@ +git://github.com/radare/radare2 diff --git a/pack/ratox/config.mk b/pack/ratox/config.mk @@ -0,0 +1,27 @@ +# ratox version +VERSION = 0.4 + +# paths +MANPREFIX = $(PREFIX)/share/man + +CC = cc +LD = $(CC) + +CPPFLAGS = \ + -DVERSION=\"${VERSION}\" \ + -D_NSIG=NSIG + +CFLAGS = \ + -I/usr/local/include \ + -I$(PACK)/opt/libtox/include \ + -I$(PACK)/opt/libvpx/include \ + -I$(PACK)/opt/libopus/include \ + -Wall -Wunused $(CPPFLAGS) + +LDFLAGS = \ + -L/usr/local/lib \ + -L$(PACK)/opt/libtox/lib \ + -L$(PACK)/opt/libvpx/lib \ + -L$(PACK)/opt/libopus/lib + +LDLIBS = -ltoxcore -ltoxav -ltoxencryptsave -lopus -lvpx -lm -lpthread diff --git a/pack/ratox/git b/pack/ratox/git @@ -0,0 +1 @@ +git://git.2f30.org/ratox.git diff --git a/pack/redis/tar b/pack/redis/tar @@ -0,0 +1 @@ +http://download.redis.io/releases/redis-4.0.8.tar.gz diff --git a/pack/reflex/build b/pack/reflex/build @@ -0,0 +1,2 @@ +#!/bin/sh -ex +CONFFLAGS='--program-transform s,re,,' diff --git a/pack/reflex/tar b/pack/reflex/tar @@ -0,0 +1 @@ +http://invisible-island.net/datafiles/release/reflex.tar.gz diff --git a/pack/rlwrap/tar b/pack/rlwrap/tar @@ -0,0 +1 @@ +https://github.com/hanslub42/rlwrap/releases/download/v0.43/rlwrap-0.43.tar.gz diff --git a/pack/rsync/rsync-fix-proto.h-tstamp-target.patch b/pack/rsync/rsync-fix-proto.h-tstamp-target.patch @@ -0,0 +1,12 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -205,7 +205,7 @@ + proto.h: proto.h-tstamp + @if test -f proto.h; then :; else cp -p $(srcdir)/proto.h .; fi + +-proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c config.h ++proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c + perl $(srcdir)/mkproto.pl $(srcdir)/*.c $(srcdir)/lib/compat.c + + man: rsync.1 rsyncd.conf.5 man-copy + diff --git a/pack/rsync/tar b/pack/rsync/tar @@ -0,0 +1 @@ +https://rsync.samba.org/ftp/rsync/rsync-3.1.2.tar.gz diff --git a/pack/runit/build b/pack/runit/build @@ -0,0 +1,9 @@ +#!/bin/sh -ex + +test -d src || mv */* . + +./package/compile +mkdir -p $PREFIX//share/man/man8 +cp man/* $PREFIX//share/man/man8 +mkdir -p $PREFIX//bin +cp command/* $PREFIX//bin diff --git a/pack/runit/tar b/pack/runit/tar @@ -0,0 +1 @@ +http://smarden.org/runit/runit-2.1.2.tar.gz diff --git a/pack/s6-dns/build b/pack/s6-dns/build @@ -0,0 +1,9 @@ +#!/bin/sh -ex + +./configure \ + --prefix=$PREFIX/ \ + --with-sysdeps=$DEST/lib/skalibs/sysdeps \ + --with-include=$DEST/include \ + --with-lib=$DEST/lib/skalibs + +gmake install diff --git a/pack/s6-dns/tar b/pack/s6-dns/tar @@ -0,0 +1 @@ +http://skarnet.org/software/s6-dns/s6-dns-2.3.0.0.tar.gz diff --git a/pack/s6-networking/build b/pack/s6-networking/build @@ -0,0 +1,14 @@ +#!/bin/sh -ex + +./configure \ + --prefix=$PREFIX/ \ + --with-sysdeps=$DEST/lib/skalibs/sysdeps \ + --with-include=$DEST/include \ + --with-lib=$DEST/lib/skalibs \ + --with-lib=$DEST/lib/execline \ + --with-lib=$DEST/lib/s6 \ + --with-lib=$DEST/lib/s6-dns \ + --enable-ssl=bearssl \ + --with-ssl-path=$DEST + +gmake install diff --git a/pack/s6-networking/tar b/pack/s6-networking/tar @@ -0,0 +1 @@ +http://skarnet.org/software/s6-networking/s6-networking-2.3.0.2.tar.gz diff --git a/pack/s6-rc/build b/pack/s6-rc/build @@ -0,0 +1,11 @@ +#!/bin/sh -ex + +./configure \ + --prefix=$PREFIX/ \ + --with-sysdeps=$DEST/lib/skalibs/sysdeps \ + --with-include=$DEST/include \ + --with-lib=$DEST/lib/skalibs \ + --with-lib=$DEST/lib/execline \ + --with-lib=$DEST/lib/s6 + +gmake install diff --git a/pack/s6-rc/tar b/pack/s6-rc/tar @@ -0,0 +1 @@ +http://skarnet.org/software/s6-rc/s6-rc-0.4.0.1.tar.gz diff --git a/pack/s6/build b/pack/s6/build @@ -0,0 +1,10 @@ +#!/bin/sh -ex + +./configure \ + --prefix=$PREFIX/ \ + --with-sysdeps=$DEST/lib/skalibs/sysdeps \ + --with-include=$DEST/include \ + --with-lib=$DEST/lib/skalibs \ + --with-lib=$DEST/lib/execline + +gmake install diff --git a/pack/s6/tar b/pack/s6/tar @@ -0,0 +1 @@ +http://skarnet.org/software/s6/s6-2.7.1.1.tar.gz diff --git a/pack/sacc/git b/pack/sacc/git @@ -0,0 +1 @@ +git://bitreich.org/sacc diff --git a/pack/sacc/tar b/pack/sacc/tar @@ -0,0 +1 @@ +ftp://ftp@bitreich.org/releases/sacc/sacc-v1.00.tgz diff --git a/pack/samtools/tar b/pack/samtools/tar @@ -0,0 +1 @@ +https://github.com/samtools/samtools/releases/download/1.8/samtools-1.8.tar.bz2 diff --git a/pack/sbase/git b/pack/sbase/git @@ -0,0 +1 @@ +git://git.suckless.org/sbase diff --git a/pack/scc/git b/pack/scc/git @@ -0,0 +1 @@ +git://git.simple-cc.org/scc diff --git a/pack/scron/git b/pack/scron/git @@ -0,0 +1 @@ +git://git.2f30.org/scron.git diff --git a/pack/scrypt/tar b/pack/scrypt/tar @@ -0,0 +1 @@ +https://www.tarsnap.com/scrypt/scrypt-1.2.1.tgz diff --git a/pack/sct/build b/pack/sct/build @@ -0,0 +1,5 @@ +#!/bin/sh -ex + +mkdir -p "$PREFIX/bin" +cc -std=c99 -L /usr/X11R6/lib -I /usr/X11R6/include \ + -o "$PREFIX/bin/sct" sct.c -lm -lX11 -lXrandr diff --git a/pack/sct/sct.c b/pack/sct/sct.c @@ -0,0 +1,77 @@ +/* public domain, do as you wish */ +#include <X11/Xlib.h> +#include <X11/Xproto.h> +#include <X11/Xatom.h> +#include <X11/extensions/Xrandr.h> + +#include <stdlib.h> +#include <math.h> + + +/* cribbed from redshift, but truncated with 500K steps */ +static const struct { float r; float g; float b; } whitepoints[] = { + { 1.00000000, 0.18172716, 0.00000000, }, /* 1000K */ + { 1.00000000, 0.42322816, 0.00000000, }, + { 1.00000000, 0.54360078, 0.08679949, }, + { 1.00000000, 0.64373109, 0.28819679, }, + { 1.00000000, 0.71976951, 0.42860152, }, + { 1.00000000, 0.77987699, 0.54642268, }, + { 1.00000000, 0.82854786, 0.64816570, }, + { 1.00000000, 0.86860704, 0.73688797, }, + { 1.00000000, 0.90198230, 0.81465502, }, + { 1.00000000, 0.93853986, 0.88130458, }, + { 1.00000000, 0.97107439, 0.94305985, }, + { 1.00000000, 1.00000000, 1.00000000, }, /* 6500K */ + { 0.95160805, 0.96983355, 1.00000000, }, + { 0.91194747, 0.94470005, 1.00000000, }, + { 0.87906581, 0.92357340, 1.00000000, }, + { 0.85139976, 0.90559011, 1.00000000, }, + { 0.82782969, 0.89011714, 1.00000000, }, + { 0.80753191, 0.87667891, 1.00000000, }, + { 0.78988728, 0.86491137, 1.00000000, }, /* 10000K */ + { 0.77442176, 0.85453121, 1.00000000, }, +}; + +int +main(int argc, char **argv) +{ + Display *dpy = XOpenDisplay(NULL); + int screen = DefaultScreen(dpy); + Window root = RootWindow(dpy, screen); + + XRRScreenResources *res = XRRGetScreenResourcesCurrent(dpy, root); + + int temp = 6500; + if (argc > 1) + temp = atoi(argv[1]); + if (temp < 1000 || temp > 10000) + temp = 6500; + + temp -= 1000; + double ratio = temp % 500 / 500.0; +#define AVG(c) whitepoints[temp / 500].c * (1 - ratio) + whitepoints[temp / 500 + 1].c * ratio + double gammar = AVG(r); + double gammag = AVG(g); + double gammab = AVG(b); + + int num_crtcs = res->ncrtc; + for (int c = 0; c < res->ncrtc; c++) { + int crtcxid = res->crtcs[c]; + XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(dpy, res, crtcxid); + + int size = XRRGetCrtcGammaSize(dpy, crtcxid); + + XRRCrtcGamma *crtc_gamma = XRRAllocGamma(size); + + for (int i = 0; i < size; i++) { + double g = 65535.0 * i / size; + crtc_gamma->red[i] = g * gammar; + crtc_gamma->green[i] = g * gammag; + crtc_gamma->blue[i] = g * gammab; + } + XRRSetCrtcGamma(dpy, crtcxid, crtc_gamma); + + XFree(crtc_gamma); + } +} + diff --git a/pack/sent/config.h b/pack/sent/config.h @@ -0,0 +1,56 @@ +/* See LICENSE file for copyright and license details. */ + +static char *fontfallbacks[] = { + "dejavu sans", + "roboto", + "ubuntu", +}; +#define NUMFONTSCALES 42 +#define FONTSZ(x) ((int)(10.0 * powf(1.1288, (x)))) /* x in [0, NUMFONTSCALES-1] */ + +static const char *colors[] = { + "#000000", /* foreground color */ + "#FFFFFF", /* background color */ +}; + +static const float linespacing = 1.4; + +/* how much screen estate is to be used at max for the content */ +static const float usablewidth = 0.95; +static const float usableheight = 0.95; + +static Mousekey mshortcuts[] = { + /* button function argument */ + { Button1, advance, {.i = +1} }, + { Button3, advance, {.i = -1} }, + { Button4, advance, {.i = -1} }, + { Button5, advance, {.i = +1} }, +}; + +static Shortcut shortcuts[] = { + /* keysym function argument */ + { XK_Escape, quit, {0} }, + { XK_q, quit, {0} }, + { XK_Right, advance, {.i = +1} }, + { XK_Left, advance, {.i = -1} }, + { XK_Return, advance, {.i = +1} }, + { XK_space, advance, {.i = +1} }, + { XK_BackSpace, advance, {.i = -1} }, + { XK_l, advance, {.i = +1} }, + { XK_h, advance, {.i = -1} }, + { XK_j, advance, {.i = +1} }, + { XK_k, advance, {.i = -1} }, + { XK_Down, advance, {.i = +1} }, + { XK_Up, advance, {.i = -1} }, + { XK_Next, advance, {.i = +1} }, + { XK_Prior, advance, {.i = -1} }, + { XK_n, advance, {.i = +1} }, + { XK_p, advance, {.i = -1} }, + { XK_r, reload, {0} }, +}; + +static Filter filters[] = { + { "\\.ff$", "cat" }, + { "\\.ff.bz2$", "bunzip2" }, + { "\\.[a-z0-9]+$", "2ff" }, +}; diff --git a/pack/sent/config.mk b/pack/sent/config.mk @@ -0,0 +1,28 @@ +# sent version +VERSION = 1 + +# Customize below to fit your system + +# paths +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man + +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib + +# includes and libs +INCS = -I. -I/usr/include -I/usr/local/include -I${X11INC} \ + -I/usr/include/freetype2 -I/usr/local/include/freetype2 \ + -I${X11INC}/freetype2 + +LIBS = -L/usr/lib -L/usr/local/lib -L${X11LIB} -lc -lm -lXft -lfontconfig -lX11 + +# flags +CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600 +CFLAGS += -g -std=c99 -pedantic -Wall ${INCS} ${CPPFLAGS} +LDFLAGS += -g ${LIBS} +#CFLAGS += -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} +#LDFLAGS += ${LIBS} + +# compiler and linker +CC ?= cc diff --git a/pack/sent/git b/pack/sent/git @@ -0,0 +1 @@ +git://git.suckless.org/sent diff --git a/pack/sfeed/build b/pack/sfeed/build @@ -0,0 +1,5 @@ +#!/bin/sh -ex +cp "$PACK/sfeed/sfeed_twtxt.c" . + +make MANPREFIX="$PREFIX/share/man" PREFIX="$PREFIX" install +cc -o "$PREFIX/bin/sfeed_twtxt" sfeed_twtxt.c util.c diff --git a/pack/sfeed/git b/pack/sfeed/git @@ -0,0 +1 @@ +git://git.codemadness.org/sfeed diff --git a/pack/sfeed/sfeed_twtxt.c b/pack/sfeed/sfeed_twtxt.c @@ -0,0 +1,84 @@ +#include <ctype.h> +#include <err.h> +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "util.h" + +static char *line; +static size_t linesize; + +static void +printtext(FILE *fp, const char *s) +{ + for (; *s; s++) + if (!iscntrl(*s)) + fputc(*s, fp); +} + +static void +printfeed(FILE *fp, const char *feedname) +{ + char *fields[FieldLast]; + struct tm *tm; + time_t parsedtime; + ssize_t linelen; + + while ((linelen = getline(&line, &linesize, fp)) > 0) { + if (line[linelen - 1] == '\n') + line[--linelen] = '\0'; + if (!parseline(line, fields)) + break; + + parsedtime = 0; + strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (!(tm = gmtime(&parsedtime))) + err(1, "localtime"); + + fprintf(stdout, "%04d-%02d-%02dT%02d:%02d:%02dZ\t", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + if (feedname[0]) + printf("[%s] ", feedname); + printtext(stdout, fields[FieldTitle]); + if (fields[FieldLink][0]) { + fputs(" @<", stdout); + if (fields[FieldAuthor][0]) { + printtext(stdout, fields[FieldAuthor]); + fputs(" ", stdout); + } + printtext(stdout, fields[FieldLink]); + fputs(">", stdout); + } + putchar('\n'); + } +} + +int +main(int argc, char *argv[]) +{ + FILE *fp; + char *name; + int i; + + if (pledge(argc == 1 ? "stdio" : "stdio rpath", NULL) == -1) + err(1, "pledge"); + + if (argc == 1) { + printfeed(stdin, ""); + } else { + for (i = 1; i < argc; i++) { + if (!(fp = fopen(argv[i], "r"))) + err(1, "fopen: %s", argv[i]); + name = ((name = strrchr(argv[i], '/'))) ? name + 1 : argv[i]; + printfeed(fp, name); + if (ferror(fp)) + err(1, "ferror: %s", argv[i]); + fclose(fp); + } + } + return 0; +} diff --git a/pack/shntool/tar b/pack/shntool/tar @@ -0,0 +1 @@ +http://www.etree.org/shnutils/shntool/dist/src/shntool-3.0.10.tar.gz diff --git a/pack/snooze/build b/pack/snooze/build @@ -0,0 +1,3 @@ +#!/bin/sh -e + +make PREFIX="$PREFIX" install diff --git a/pack/snooze/git b/pack/snooze/git @@ -0,0 +1 @@ +git://git.vuxu.org/snooze diff --git a/pack/spoon/build b/pack/spoon/build @@ -0,0 +1,7 @@ +#!/bin/sh -ex +cp "$(dirname "$0")/config.h" "./config.h" + +./configure +sed -r '/mpd/ s,^[^#],#,' Makefile >sed +mv sed Makefile +make PREFIX="$PREFIX" install diff --git a/pack/spoon/config.h b/pack/spoon/config.h @@ -0,0 +1,17 @@ +/* delay between each update in seconds */ +int delay = 1; + +struct ent ents[] = { + /* reorder/edit/remove these as you see fit */ + { .fmt = " [%s]", .read = countread, .arg = "/home/mail/INBOX/new" }, + { .fmt = " [%s]", .read = mixread, .arg = NULL }, + { .fmt = " [%s]", .read = loadread, .arg = NULL }, + { .fmt = " [%s]", .read = cpuread, .arg = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" }, + { .fmt = " [%s'C]", .read = tempread, .arg = "/sys/class/hwmon/hwmon1/temp1_input" }, + { .fmt = " %s", .read = battread, .arg = &(struct battarg){ .cap = "/sys/class/power_supply/BAT0/capacity", .ac = "/sys/class/power_supply/AC/online" } }, + { .fmt = " %s", .read = wifiread, .arg = NULL }, + { .fmt = " [%s]", .read = xkblayoutread, .arg = NULL }, + { .fmt = " %s", .read = keyread, .arg = &(struct keyarg){ .sym = XK_Caps_Lock, .on = "[caps] ", .off = "" } }, + { .fmt = "%s", .read = fileread, .arg = "/etc/myname" }, + { .fmt = " %s", .read = dateread, .arg = &(struct datearg){ .fmt = "%a %Y/%m/%d %H:%M", .tz = NULL } }, +}; diff --git a/pack/spoon/git b/pack/spoon/git @@ -0,0 +1 @@ +git://git.2f30.org/spoon.git diff --git a/pack/sqlite/tar b/pack/sqlite/tar @@ -0,0 +1 @@ +https://www.sqlite.org/2018/sqlite-autoconf-3220000.tar.gz diff --git a/pack/sselp/git b/pack/sselp/git @@ -0,0 +1 @@ +git://git.suckless.org/sselp/ diff --git a/pack/st/build b/pack/st/build @@ -0,0 +1,6 @@ +#!/bin/sh -ex + +cp "$PACK/helios_dark.h" colors.h +cp "$PACK/config.h" "$PACK/config.mk" . + +make PREFIX="$PREFIX" install diff --git a/pack/st/colors.h b/pack/st/colors.h @@ -0,0 +1,27 @@ +/* Terminal colors (16 first used in escape sequence) */ +static const char *colorname[] = { + + /* 8 normal colors */ + [0] = "#000000", /* black */ + [1] = "#dc322f", /* red */ + [2] = "#859900", /* green */ + [3] = "#b58900", /* yellow */ + [4] = "#268bd2", /* blue */ + [5] = "#8833bb", /* magenta */ + [6] = "#119988", /* cyan */ + [7] = "#dddddd", /* white */ + + /* 8 bright colors */ + [8] = "#777777", /* black */ + [9] = "#ff3333", /* red */ + [10] = "#22ff44", /* green */ + [11] = "#bb9911", /* yellow */ + [12] = "#3366ff", /* blue */ + [13] = "#9966cc", /* magenta */ + [14] = "#33bbaa", /* cyan */ + [15] = "#ffffff", /* white */ + + /* special colors */ + [256] = "#000000", /* background */ + [257] = "#dddddd", /* foreground */ +}; diff --git a/pack/st/config.h b/pack/st/config.h @@ -0,0 +1,416 @@ +/* See LICENSE file for copyright and license details. */ + +/* + * appearance + * + * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html + */ +static char font[] = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; +static int borderpx = 2; + +/* + * What program is execed by st depends of these precedence rules: + * 1: program passed with -e + * 2: utmp option + * 3: SHELL environment variable + * 4: value of shell in /etc/passwd + * 5: value of shell in config.h + */ +static char shell[] = "/bin/sh"; +static char *utmp = NULL; +static char stty_args[] = "stty raw pass8 nl -echo -iexten -cstopb 38400"; + +/* identification sequence returned in DA and DECID */ +static char vtiden[] = "\033[?6c"; + +/* Kerning / character bounding-box multipliers */ +static float cwscale = 1.0; +static float chscale = 1.0; + +/* + * word delimiter string + * + * More advanced example: " `'\"()[]{}" + */ +static char worddelimiters[] = " "; + +/* selection timeouts (in milliseconds) */ +static unsigned int doubleclicktimeout = 300; +static unsigned int tripleclicktimeout = 600; + +/* alt screens */ +static int allowaltscreen = 1; + +/* frames per second st should at maximum draw to the screen */ +static unsigned int xfps = 120; +static unsigned int actionfps = 30; + +/* + * blinking timeout (set to 0 to disable blinking) for the terminal blinking + * attribute. + */ +static unsigned int blinktimeout = 800; + +/* + * thickness of underline and bar cursors + */ +static unsigned int cursorthickness = 2; + +/* + * bell volume. It must be a value between -100 and 100. Use 0 for disabling + * it + */ +static int bellvolume = 0; + +/* default TERM value */ +static char termname[] = "st-256color"; + +/* + * spaces per tab + * + * When you are changing this value, don't forget to adapt the »it« value in + * the st.info and appropriately install the st.info in the environment where + * you use this st version. + * + * it#$tabspaces, + * + * Secondly make sure your kernel is not expanding tabs. When running `stty + * -a` »tab0« should appear. You can tell the terminal to not expand tabs by + * running following command: + * + * stty tabs + */ +static unsigned int tabspaces = 8; + +#include "colors.h" + +/* + * Default colors (colorname index) + * foreground, background, cursor, reverse cursor + */ +static unsigned int defaultfg = 257; +static unsigned int defaultbg = 256; +static unsigned int defaultcs = 257; +static unsigned int defaultrcs = 256; + +/* + * Default shape of cursor + * 2: Block ("█") + * 4: Underline ("_") + * 6: Bar ("|") + * 7: Snowman ("☃") + */ +static unsigned int cursorshape = 2; + +/* + * Default colour and shape of the mouse cursor + */ +static unsigned int mouseshape = XC_xterm; +static unsigned int mousefg = 7; +static unsigned int mousebg = 0; + +/* + * Colors used, when the specific fg == defaultfg. So in reverse mode this + * will reverse too. Another logic would only make the simple feature too + * complex. + */ +static unsigned int defaultitalic = 11; +static unsigned int defaultunderline = 7; + +/* + * Internal mouse shortcuts. + * Beware that overloading Button1 will disable the selection. + */ +static MouseShortcut mshortcuts[] = { + /* button mask string */ + { Button4, XK_ANY_MOD, "\031" }, + { Button5, XK_ANY_MOD, "\005" }, +}; + +/* Internal keyboard shortcuts. */ +#define MODKEY Mod1Mask + +static Shortcut shortcuts[] = { + /* mask keysym function argument */ + { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, + { ControlMask, XK_Print, toggleprinter, {.i = 0} }, + { ShiftMask, XK_Print, printscreen, {.i = 0} }, + { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, + { MODKEY|ShiftMask, XK_Prior, xzoom, {.f = +1} }, + { MODKEY|ShiftMask, XK_Next, xzoom, {.f = -1} }, + { MODKEY|ShiftMask, XK_Home, xzoomreset, {.f = 0} }, + { ShiftMask, XK_Insert, selpaste, {.i = 0} }, + { MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} }, + { MODKEY|ShiftMask, XK_C, clipcopy, {.i = 0} }, + { MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} }, + { MODKEY, XK_Num_Lock, numlock, {.i = 0} }, +}; + +/* + * Special keys (change & recompile st.info accordingly) + * + * Mask value: + * * Use XK_ANY_MOD to match the key no matter modifiers state + * * Use XK_NO_MOD to match the key alone (no modifiers) + * appkey value: + * * 0: no value + * * > 0: keypad application mode enabled + * * = 2: term.numlock = 1 + * * < 0: keypad application mode disabled + * appcursor value: + * * 0: no value + * * > 0: cursor application mode enabled + * * < 0: cursor application mode disabled + * crlf value + * * 0: no value + * * > 0: crlf mode is enabled + * * < 0: crlf mode is disabled + * + * Be careful with the order of the definitions because st searches in + * this table sequentially, so any XK_ANY_MOD must be in the last + * position for a key. + */ + +/* + * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF) + * to be mapped below, add them to this array. + */ +static KeySym mappedkeys[] = { -1 }; + +/* + * State bits to ignore when matching key or button events. By default, + * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored. + */ +static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; + +/* + * Override mouse-select while mask is active (when MODE_MOUSE is set). + * Note that if you want to use ShiftMask with selmasks, set this to an other + * modifier, set to 0 to not use it. + */ +static uint forceselmod = ShiftMask; + +/* + * This is the huge key array which defines all compatibility to the Linux + * world. Please decide about changes wisely. + */ +static Key key[] = { + /* keysym mask string appkey appcursor crlf */ + { XK_KP_Home, ShiftMask, "\033[2J", 0, -1, 0}, + { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1, 0}, + { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1, 0}, + { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1, 0}, + { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0, 0}, + { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1, 0}, + { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1, 0}, + { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0, 0}, + { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1, 0}, + { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1, 0}, + { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0, 0}, + { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1, 0}, + { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1, 0}, + { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0, 0}, + { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1, 0}, + { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1, 0}, + { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0, 0}, + { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0, 0}, + { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0, 0}, + { XK_KP_End, ControlMask, "\033[J", -1, 0, 0}, + { XK_KP_End, ControlMask, "\033[1;5F", +1, 0, 0}, + { XK_KP_End, ShiftMask, "\033[K", -1, 0, 0}, + { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0, 0}, + { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0, 0}, + { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0, 0}, + { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0, 0}, + { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0, 0}, + { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0, 0}, + { XK_KP_Insert, ControlMask, "\033[L", -1, 0, 0}, + { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0, 0}, + { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0, 0}, + { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0, 0}, + { XK_KP_Delete, ControlMask, "\033[M", -1, 0, 0}, + { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0, 0}, + { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0, 0}, + { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, + { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0, 0}, + { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0, 0}, + { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0, 0}, + { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0, -1}, + { XK_KP_Enter, XK_ANY_MOD, "\r\n", -1, 0, +1}, + { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0, 0}, + { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0, 0}, + { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0, 0}, + { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0, 0}, + { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0, 0}, + { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0, 0}, + { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0, 0}, + { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0, 0}, + { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0, 0}, + { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0, 0}, + { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0, 0}, + { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0, 0}, + { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0, 0}, + { XK_Up, ShiftMask, "\033[1;2A", 0, 0, 0}, + { XK_Up, ControlMask, "\033[1;5A", 0, 0, 0}, + { XK_Up, Mod1Mask, "\033[1;3A", 0, 0, 0}, + { XK_Up, XK_ANY_MOD, "\033[A", 0, -1, 0}, + { XK_Up, XK_ANY_MOD, "\033OA", 0, +1, 0}, + { XK_Down, ShiftMask, "\033[1;2B", 0, 0, 0}, + { XK_Down, ControlMask, "\033[1;5B", 0, 0, 0}, + { XK_Down, Mod1Mask, "\033[1;3B", 0, 0, 0}, + { XK_Down, XK_ANY_MOD, "\033[B", 0, -1, 0}, + { XK_Down, XK_ANY_MOD, "\033OB", 0, +1, 0}, + { XK_Left, ShiftMask, "\033[1;2D", 0, 0, 0}, + { XK_Left, ControlMask, "\033[1;5D", 0, 0, 0}, + { XK_Left, Mod1Mask, "\033[1;3D", 0, 0, 0}, + { XK_Left, XK_ANY_MOD, "\033[D", 0, -1, 0}, + { XK_Left, XK_ANY_MOD, "\033OD", 0, +1, 0}, + { XK_Right, ShiftMask, "\033[1;2C", 0, 0, 0}, + { XK_Right, ControlMask, "\033[1;5C", 0, 0, 0}, + { XK_Right, Mod1Mask, "\033[1;3C", 0, 0, 0}, + { XK_Right, XK_ANY_MOD, "\033[C", 0, -1, 0}, + { XK_Right, XK_ANY_MOD, "\033OC", 0, +1, 0}, + { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0, 0}, + { XK_Return, Mod1Mask, "\033\r", 0, 0, -1}, + { XK_Return, Mod1Mask, "\033\r\n", 0, 0, +1}, + { XK_Return, XK_ANY_MOD, "\r", 0, 0, -1}, + { XK_Return, XK_ANY_MOD, "\r\n", 0, 0, +1}, + { XK_Insert, ShiftMask, "\033[4l", -1, 0, 0}, + { XK_Insert, ShiftMask, "\033[2;2~", +1, 0, 0}, + { XK_Insert, ControlMask, "\033[L", -1, 0, 0}, + { XK_Insert, ControlMask, "\033[2;5~", +1, 0, 0}, + { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0, 0}, + { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0, 0}, + { XK_Delete, ControlMask, "\033[M", -1, 0, 0}, + { XK_Delete, ControlMask, "\033[3;5~", +1, 0, 0}, + { XK_Delete, ShiftMask, "\033[2K", -1, 0, 0}, + { XK_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, + { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, + { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, + { XK_BackSpace, XK_NO_MOD, "\177", 0, 0, 0}, + { XK_BackSpace, Mod1Mask, "\033\177", 0, 0, 0}, + { XK_Home, ShiftMask, "\033[2J", 0, -1, 0}, + { XK_Home, ShiftMask, "\033[1;2H", 0, +1, 0}, + { XK_Home, XK_ANY_MOD, "\033[H", 0, -1, 0}, + { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1, 0}, + { XK_End, ControlMask, "\033[J", -1, 0, 0}, + { XK_End, ControlMask, "\033[1;5F", +1, 0, 0}, + { XK_End, ShiftMask, "\033[K", -1, 0, 0}, + { XK_End, ShiftMask, "\033[1;2F", +1, 0, 0}, + { XK_End, XK_ANY_MOD, "\033[4~", 0, 0, 0}, + { XK_Prior, ControlMask, "\033[5;5~", 0, 0, 0}, + { XK_Prior, ShiftMask, "\033[5;2~", 0, 0, 0}, + { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0, 0}, + { XK_Next, ControlMask, "\033[6;5~", 0, 0, 0}, + { XK_Next, ShiftMask, "\033[6;2~", 0, 0, 0}, + { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0, 0}, + { XK_F1, XK_NO_MOD, "\033OP" , 0, 0, 0}, + { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0, 0}, + { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0, 0}, + { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0, 0}, + { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0, 0}, + { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0, 0}, + { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0, 0}, + { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0, 0}, + { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0, 0}, + { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0, 0}, + { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0, 0}, + { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0, 0}, + { XK_F3, XK_NO_MOD, "\033OR" , 0, 0, 0}, + { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0, 0}, + { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0, 0}, + { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0, 0}, + { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0, 0}, + { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0, 0}, + { XK_F4, XK_NO_MOD, "\033OS" , 0, 0, 0}, + { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0, 0}, + { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0, 0}, + { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0, 0}, + { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0, 0}, + { XK_F5, XK_NO_MOD, "\033[15~", 0, 0, 0}, + { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0, 0}, + { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0, 0}, + { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0, 0}, + { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0, 0}, + { XK_F6, XK_NO_MOD, "\033[17~", 0, 0, 0}, + { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0, 0}, + { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0, 0}, + { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0, 0}, + { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0, 0}, + { XK_F7, XK_NO_MOD, "\033[18~", 0, 0, 0}, + { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0, 0}, + { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0, 0}, + { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0, 0}, + { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0, 0}, + { XK_F8, XK_NO_MOD, "\033[19~", 0, 0, 0}, + { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0, 0}, + { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0, 0}, + { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0, 0}, + { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0, 0}, + { XK_F9, XK_NO_MOD, "\033[20~", 0, 0, 0}, + { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0, 0}, + { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0, 0}, + { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0, 0}, + { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0, 0}, + { XK_F10, XK_NO_MOD, "\033[21~", 0, 0, 0}, + { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0, 0}, + { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0, 0}, + { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0, 0}, + { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0, 0}, + { XK_F11, XK_NO_MOD, "\033[23~", 0, 0, 0}, + { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0, 0}, + { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0, 0}, + { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0, 0}, + { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0, 0}, + { XK_F12, XK_NO_MOD, "\033[24~", 0, 0, 0}, + { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0, 0}, + { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0, 0}, + { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0, 0}, + { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0, 0}, + { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0, 0}, + { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0, 0}, + { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0, 0}, + { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0, 0}, + { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0, 0}, + { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0, 0}, + { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0, 0}, + { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0, 0}, + { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0, 0}, + { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0, 0}, + { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0, 0}, + { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0, 0}, + { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0, 0}, + { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0, 0}, + { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0, 0}, + { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0, 0}, + { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0, 0}, + { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0, 0}, + { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0, 0}, + { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0, 0}, + { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0, 0}, + { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0, 0}, + { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0, 0}, +}; + +/* + * Selection types' masks. + * Use the same masks as usual. + * Button1Mask is always unset, to make masks match between ButtonPress. + * ButtonRelease and MotionNotify. + * If no match is found, regular selection is used. + */ +static uint selmasks[] = { + [SEL_RECTANGULAR] = Mod1Mask, +}; + +/* + * Printable characters in ASCII, used to estimate the advance width + * of single wide characters. + */ +static char ascii_printable[] = + " !\"#$%&'()*+,-./0123456789:;<=>?" + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + "`abcdefghijklmnopqrstuvwxyz{|}~"; + diff --git a/pack/st/config.mk b/pack/st/config.mk @@ -0,0 +1,28 @@ +# st version +VERSION = 0.7 + +# Customize below to fit your system + +# paths +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man + +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib + +# includes and libs +INCS = -I. -I/usr/include -I${X11INC} \ + `pkg-config --cflags fontconfig` \ + `pkg-config --cflags freetype2` +LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lX11 -lutil -lXft \ + `pkg-config --libs fontconfig` \ + `pkg-config --libs freetype2` + +# flags +CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600 +CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS} +LDFLAGS += -g ${LIBS} + +# compiler and linker +# CC = cc + diff --git a/pack/st/helios_dark.h b/pack/st/helios_dark.h @@ -0,0 +1,27 @@ +/* Terminal colors (16 first used in escape sequence) */ +static const char *colorname[] = { + + /* 8 normal colors */ + [0] = "#000000", /* black */ + [1] = "#dc322f", /* red */ + [2] = "#859900", /* green */ + [3] = "#b58900", /* yellow */ + [4] = "#268bd2", /* blue */ + [5] = "#8833bb", /* magenta */ + [6] = "#119988", /* cyan */ + [7] = "#dddddd", /* white */ + + /* 8 bright colors */ + [8] = "#777777", /* black */ + [9] = "#ff3333", /* red */ + [10] = "#22ff44", /* green */ + [11] = "#bb9911", /* yellow */ + [12] = "#3366ff", /* blue */ + [13] = "#9966cc", /* magenta */ + [14] = "#33bbaa", /* cyan */ + [15] = "#ffffff", /* white */ + + /* special colors */ + [256] = "#000000", /* background */ + [257] = "#dddddd", /* foreground */ +}; diff --git a/pack/st/solarized_dark.h b/pack/st/solarized_dark.h @@ -0,0 +1,27 @@ +/* Terminal colors (16 first used in escape sequence) */ +static const char *colorname[] = { + + /* 8 normal colors */ + [0] = "#002b36", /* black */ + [1] = "#dc322f", /* red */ + [2] = "#859900", /* green */ + [3] = "#b58900", /* yellow */ + [4] = "#268bd2", /* blue */ + [5] = "#6c71c4", /* magenta */ + [6] = "#2aa198", /* cyan */ + [7] = "#fdf6e3", /* white */ + + /* 8 bright colors */ + [8] = "#657b83", /* black */ + [9] = "#dc322f", /* red */ + [10] = "#859900", /* green */ + [11] = "#b58900", /* yellow */ + [12] = "#268bd2", /* blue */ + [13] = "#6c71c4", /* magenta */ + [14] = "#2aa198", /* cyan */ + [15] = "#ffffff", /* white */ + + /* special colors */ + [256] = "#002b36", /* background */ + [257] = "#fdf6e3", /* foreground */ +}; diff --git a/pack/st/solarized_light.h b/pack/st/solarized_light.h @@ -0,0 +1,27 @@ +/* Terminal colors (16 first used in escape sequence) */ +static const char *colorname[] = { + + /* 8 normal colors */ + [0] = "#002b36", /* black */ + [1] = "#dc322f", /* red */ + [2] = "#859900", /* green */ + [3] = "#b58900", /* yellow */ + [4] = "#268bd2", /* blue */ + [5] = "#6c71c4", /* magenta */ + [6] = "#2aa198", /* cyan */ + [7] = "#93a1a1", /* white */ + + /* 8 bright colors */ + [8] = "#657b83", /* black */ + [9] = "#dc322f", /* red */ + [10] = "#859900", /* green */ + [11] = "#b58900", /* yellow */ + [12] = "#268bd2", /* blue */ + [13] = "#6c71c4", /* magenta */ + [14] = "#2aa198", /* cyan */ + [15] = "#fdf6e3", /* white */ + + /* special colors */ + [256] = "#fdf6e3", /* background */ + [257] = "#586e75", /* foreground */ +}; diff --git a/pack/st/tar b/pack/st/tar @@ -0,0 +1 @@ +http://dl.suckless.org/st/st-0.7.tar.gz diff --git a/pack/stagit-gopher/config.mk b/pack/stagit-gopher/config.mk @@ -0,0 +1,29 @@ +# customize below to fit your system + +# paths +PREFIX = ${PREFIX} +MANPREFIX = ${PREFIX}/share/man + +# compiler and linker +#CC = cc + +GITINC = $(PACK)/include +GITLIB = $(PACK)/lib + +# includes and libs +INCS = -I${GITINC} +LIBS = -L${GITLIB} -lgit2 -lz -lssl -lpthread + +# debug +#CFLAGS = -fstack-protector-all -O0 -g -std=c99 -Wall -Wextra -pedantic ${INCS} +#LDFLAGS = ${LIBS} + +# optimized +CFLAGS = -O2 -std=c99 ${INCS} +LDFLAGS = -s ${LIBS} + +# optimized static +#CFLAGS = -static -O2 -std=c99 ${INCS} +#LDFLAGS = -static -s ${LIBS} + +CPPFLAGS = -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE ${INCS} diff --git a/pack/stagit-gopher/git b/pack/stagit-gopher/git @@ -0,0 +1 @@ +git://git.codemadness.org/stagit-gopher diff --git a/pack/stagit/config.mk b/pack/stagit/config.mk @@ -0,0 +1,29 @@ +# customize below to fit your system + +# paths +PREFIX = ${PREFIX} +MANPREFIX = ${PREFIX}/share/man + +# compiler and linker +#CC = cc + +GITINC = $(PACK)/include +GITLIB = $(PACK)/lib + +# includes and libs +INCS = -I${GITINC} +LIBS = -L${GITLIB} -lgit2 -lz -lssl -lpthread + +# debug +#CFLAGS = -fstack-protector-all -O0 -g -std=c99 -Wall -Wextra -pedantic ${INCS} +#LDFLAGS = ${LIBS} + +# optimized +CFLAGS = -O2 -std=c99 ${INCS} +LDFLAGS = -s ${LIBS} + +# optimized static +#CFLAGS = -static -O2 -std=c99 ${INCS} +#LDFLAGS = -static -s ${LIBS} + +CPPFLAGS = -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE ${INCS} diff --git a/pack/stagit/git b/pack/stagit/git @@ -0,0 +1 @@ +git://git.codemadness.org/stagit diff --git a/pack/supervise/death_tally b/pack/supervise/death_tally diff --git a/pack/supervise/lock b/pack/supervise/lock diff --git a/pack/supervise/status b/pack/supervise/status Binary files differ. diff --git a/pack/tabbed/build b/pack/tabbed/build @@ -0,0 +1,5 @@ +#!/bin/sh -e + +cp "$PACK/config.mk" . + +make PREFIX="$PREFIX" install diff --git a/pack/tabbed/config.mk b/pack/tabbed/config.mk @@ -0,0 +1,33 @@ +# tabbed version +VERSION = 0.6 + +# Customize below to fit your system + +# paths +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man + +X11INC = /usr/X11R6/include +X11LIB = /usr/X11R6/lib + +# freetype +FREETYPELIBS = -lfontconfig -lXft +FREETYPEINC = /usr/include/freetype2 +# OpenBSD (uncomment) +FREETYPEINC = ${X11INC}/freetype2 + +# includes and libs +INCS = -I. -I/usr/include -I$(X11INC) -I${FREETYPEINC} +LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${FREETYPELIBS} + +# flags +CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE +CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} +LDFLAGS = -s ${LIBS} + +# Solaris +#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" +#LDFLAGS = ${LIBS} + +# compiler and linker +CC = cc diff --git a/pack/tabbed/git b/pack/tabbed/git @@ -0,0 +1 @@ +git://git.suckless.org/tabbed diff --git a/pack/tarsnap/tar b/pack/tarsnap/tar @@ -0,0 +1 @@ +https://www.tarsnap.com/download/tarsnap-autoconf-1.0.39.tgz diff --git a/pack/tcpdump/tar b/pack/tcpdump/tar @@ -0,0 +1 @@ +http://www.tcpdump.org/release/tcpdump-4.9.1.tar.gz diff --git a/pack/tinc/tar b/pack/tinc/tar @@ -0,0 +1 @@ +http://tinc-vpn.org/packages/tinc-1.1pre15.tar.gz diff --git a/pack/tinyssh/build b/pack/tinyssh/build @@ -0,0 +1,5 @@ +#!/bin/sh -ex +echo bin >conf-bin +echo share/man >conf-man +make +sh -e ./make-install.sh "$PREFIX" diff --git a/pack/tinyssh/git b/pack/tinyssh/git @@ -0,0 +1 @@ +git://github.com/janmojzis/tinyssh diff --git a/pack/tinyssh/tar b/pack/tinyssh/tar @@ -0,0 +1 @@ +https://mojzis.com/software/tinyssh/tinyssh-20180201.tar.gz diff --git a/pack/tmux/tar b/pack/tmux/tar @@ -0,0 +1 @@ +https://github.com/tmux/tmux/releases/download/2.6/tmux-2.6.tar.gz diff --git a/pack/tnftp/tar b/pack/tnftp/tar @@ -0,0 +1 @@ +ftp://ftp.netbsd.org/pub/NetBSD/misc/tnftp/tnftp-20151004.tar.gz diff --git a/pack/tor/build b/pack/tor/build @@ -0,0 +1,5 @@ +#!/bin/sh -ex +./configure --prefix="$PREFIX" \ + --sbindir="$PREFIX/bin" \ + --with-libevent-dir="$PACK" \ + --with-openssl-dir="$PACK" diff --git a/pack/tor/tar b/pack/tor/tar @@ -0,0 +1 @@ +http://www.torproject.org/dist/tor-0.3.1.8.tar.gz diff --git a/pack/transmission/build b/pack/transmission/build @@ -0,0 +1,4 @@ +#!/bin/sh -ex +./configure --prefix="$PREFIX" \ + --disable-nls \ + --without-gtk diff --git a/pack/transmission/tar b/pack/transmission/tar @@ -0,0 +1 @@ +https://github.com/transmission/transmission-releases/raw/master/transmission-2.94.tar.xz diff --git a/pack/tttml/git b/pack/tttml/git @@ -0,0 +1 @@ +git://bitreich.org/tttml diff --git a/pack/u9fs/build b/pack/u9fs/build @@ -0,0 +1,8 @@ +#!/bin/sh -ex +sed '4 s/^$/#define ruserok(a, b, c, d) (-1)/' authrhosts.c >sed +mv sed authrhosts.c + +mkdir -p "$PREFIX/bin" +make DESTROOT="$PREFIX" install +mkdir -p "$PREFIX/share/man/man8" +cp u9fs.man "$PREFIX/share/man/man8/u9fs.8" diff --git a/pack/u9fs/git b/pack/u9fs/git @@ -0,0 +1 @@ +git://github.com/sevki/u9fs diff --git a/pack/vis/build b/pack/vis/build @@ -0,0 +1,11 @@ +#!/bin/sh -ex +export CFLAGS=-I"'$PACK/include'" +export LDFLAGS=-L"'$PACK/lib'" + +./configure --prefix="$PREFIX" \ + --disable-curses \ + --disable-lua \ + --disable-lpeg-static \ + --disable-tre + +gmake install diff --git a/pack/vis/git b/pack/vis/git @@ -0,0 +1 @@ +git://github.com/martanne/vis diff --git a/pack/vorbis-tools/tar b/pack/vorbis-tools/tar @@ -0,0 +1 @@ +https://ftp.osuosl.org/pub/xiph/releases/vorbis/vorbis-tools-1.4.0.tar.gz diff --git a/pack/yacc/build b/pack/yacc/build @@ -0,0 +1,3 @@ +#!/bin/sh -ex +./configure +make prefix="$PREFIX" install diff --git a/pack/yacc/tar b/pack/yacc/tar @@ -0,0 +1 @@ +https://devio.us/~bcallah/yacc/yacc-20161230.tar.gz diff --git a/pack/yasm/tar b/pack/yasm/tar @@ -0,0 +1 @@ +http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz diff --git a/s6/backup/log/run b/s6/backup/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/backup/ diff --git a/s6/backup/run b/s6/backup/run @@ -0,0 +1,9 @@ +#!/usr/local/bin/execlineb +# backup script copying data from home dirs to backup dir + +fdmove -c 2 1 + +cd /home + +snooze -M 0 -H 6 +rsync -r lib git mail bkp/ diff --git a/s6/btpd/log/run b/s6/btpd/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/btpd/ diff --git a/s6/btpd/run b/s6/btpd/run @@ -0,0 +1,6 @@ +#!/usr/local/bin/execlineb +# bit torrent protocol daemon (btpd) + +fdmove -c 2 1 + +btpd --no-daemon -d . diff --git a/s6/cherrymusic/log/run b/s6/cherrymusic/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/cherrymusic/ diff --git a/s6/cherrymusic/run b/s6/cherrymusic/run @@ -0,0 +1,9 @@ +#!/usr/local/bin/execlineb +# web-based music streaming + +fdmove -c 2 1 + +python3.6 +/pack/src/cherrymusic/cherrymusic + --setup + --port 8080 diff --git a/s6/collectd/data/conf b/s6/collectd/data/conf @@ -0,0 +1,66 @@ +#Hostname "localhost" +#FQDNLookup true + +AutoLoadPlugin true + +Interval 900 +MaxReadInterval 86400 +Timeout 2 +ReadThreads 5 +WriteThreads 5 +WriteQueueLimitHigh 1000000 +WriteQueueLimitLow 800000 + +<Plugin logfile> + LogLevel info + File STDOUT + Timestamp true + PrintSeverity true +</Plugin> + +<Plugin cpu> + ReportByCpu false + ReportByState true + ValuesPercentage true + ReportNumCpu false + ReportGuestState false + SubtractGuestState true +</Plugin> + +<Plugin csv> + DataDir "/home/collectd" +</Plugin> + +#<Plugin df> +# Device "/dev/hda1" +# MountPoint "/home" +# FSType "ext3" +# IgnoreSelected false +# ReportByDevice false +# ReportInodes false +# ValuesAbsolute true +# ValuesPercentage false +#</Plugin> + +#<Plugin disk> +# Disk "/^[hs]d[a-f][0-9]?$/" +# IgnoreSelected false +# UseBSDName false +# UdevNameAttr "DEVNAME" +#</Plugin> + +#<Plugin interface> +# Interface "eth0" +# IgnoreSelected false +# ReportInactive true +# UniqueName false +#</Plugin> + +<Plugin load> + ReportRelative true +</Plugin> + +<Plugin memory> + ValuesAbsolute false + ValuesPercentage true +</Plugin> diff --git a/s6/collectd/log/run b/s6/collectd/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/collectd/ diff --git a/s6/collectd/run b/s6/collectd/run @@ -0,0 +1,6 @@ +#!/usr/local/bin/execlineb +# statistics collection daemon + +fdmove -c 2 1 + +collectd -f -C data/conf diff --git a/s6/djbdns-axfrdns/env/ROOT b/s6/djbdns-axfrdns/env/ROOT @@ -0,0 +1 @@ +/home/dns/ diff --git a/s6/djbdns-axfrdns/log/run b/s6/djbdns-axfrdns/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/djbdns-axfrdns/ diff --git a/s6/djbdns-axfrdns/run b/s6/djbdns-axfrdns/run @@ -0,0 +1,11 @@ +#!/usr/local/bin/execlineb +# djbdns zone transfert dns server + +fdmove -c 2 1 + +s6-envuidgid dns +s6-envdir env +s6-softliimt 300000 + +tcpserver -vDRHl0 0.0.0.0 53 +axrfdns diff --git a/s6/djbdns-dnscache/data/ip/127.0.0.1 b/s6/djbdns-dnscache/data/ip/127.0.0.1 diff --git a/s6/djbdns-dnscache/data/servers/@ b/s6/djbdns-dnscache/data/servers/@ diff --git a/s6/djbdns-dnscache/env/CACHESIZE b/s6/djbdns-dnscache/env/CACHESIZE @@ -0,0 +1 @@ +1000000 diff --git a/s6/djbdns-dnscache/env/DATALIMIT b/s6/djbdns-dnscache/env/DATALIMIT @@ -0,0 +1 @@ +3000000 diff --git a/s6/djbdns-dnscache/env/IP b/s6/djbdns-dnscache/env/IP @@ -0,0 +1 @@ +127.0.0.1 diff --git a/s6/djbdns-dnscache/env/IPSEND b/s6/djbdns-dnscache/env/IPSEND @@ -0,0 +1 @@ +0.0.0.0 diff --git a/s6/djbdns-dnscache/env/ROOT b/s6/djbdns-dnscache/env/ROOT @@ -0,0 +1 @@ +/home/dns/ diff --git a/s6/djbdns-dnscache/log/run b/s6/djbdns-dnscache/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/djbdns-dnscache/ diff --git a/s6/djbdns-dnscache/run b/s6/djbdns-dnscache/run @@ -0,0 +1,13 @@ +#!/usr/local/bin/execlineb +# djbdns caching recursive dns server + +fdmove -c 2 1 + +importas D DATALIMIT + +s6-envguid dns +s6-envdir env +s6-softlimit -o 250 -d $D + +pipeline { dd 'if=/dev/random' } +dnscache diff --git a/s6/djbdns-tinydns/data/add-alias b/s6/djbdns-tinydns/data/add-alias @@ -0,0 +1,2 @@ +#!/9/bin/rc -e +exec tinydns-edit data data.new add alias $* diff --git a/s6/djbdns-tinydns/data/add-childns b/s6/djbdns-tinydns/data/add-childns @@ -0,0 +1,2 @@ +#!/9/bin/rc -e +exec tinydns-edit data data.new add childns $* diff --git a/s6/djbdns-tinydns/data/add-host b/s6/djbdns-tinydns/data/add-host @@ -0,0 +1,2 @@ +#!/9/bin/rc -e +exec tinydns-edit data data.new add host $* diff --git a/s6/djbdns-tinydns/data/add-mx b/s6/djbdns-tinydns/data/add-mx @@ -0,0 +1,2 @@ +#!/9/bin/rc -e +exec tinydns-edit data data.new add mx $* diff --git a/s6/djbdns-tinydns/data/add-ns b/s6/djbdns-tinydns/data/add-ns @@ -0,0 +1,2 @@ +#!/9/bin/rc -e +exec tinydns-edit data data.new add ns $* diff --git a/s6/djbdns-tinydns/data/data b/s6/djbdns-tinydns/data/data diff --git a/s6/djbdns-tinydns/data/mkfile b/s6/djbdns-tinydns/data/mkfile @@ -0,0 +1,2 @@ +data.cdb: data + tinydns-data diff --git a/s6/djbdns-tinydns/env/IP b/s6/djbdns-tinydns/env/IP @@ -0,0 +1 @@ +0.0.0.0 diff --git a/s6/djbdns-tinydns/env/ROOT b/s6/djbdns-tinydns/env/ROOT @@ -0,0 +1 @@ +/home/dns/ diff --git a/s6/djbdns-tinydns/log/run b/s6/djbdns-tinydns/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/djbdns-tinydns/ diff --git a/s6/djbdns-tinydns/run b/s6/djbdns-tinydns/run @@ -0,0 +1,9 @@ +#!/usr/local/bin/execlineb +# djbdns authoritative dns server + +fdmove -c 2 1 + +s6-envguid dns +s6-envdir env + +tinydns diff --git a/s6/djbdns-walldns/env/IP b/s6/djbdns-walldns/env/IP @@ -0,0 +1 @@ +0.0.0.0 diff --git a/s6/djbdns-walldns/env/ROOT b/s6/djbdns-walldns/env/ROOT @@ -0,0 +1 @@ +/home/dns/ diff --git a/s6/djbdns-walldns/log/run b/s6/djbdns-walldns/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/djbdns-walldns/ diff --git a/s6/djbdns-walldns/run b/s6/djbdns-walldns/run @@ -0,0 +1,8 @@ +#!/usr/local/bin/execlineb +# djbdns wall dns server + +fdmove -c 2 1 + +s6-envdir env + +walldns diff --git a/s6/fossil/log/run b/s6/fossil/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/fossil/ diff --git a/s6/fossil/run b/s6/fossil/run @@ -0,0 +1,11 @@ +#!/usr/local/bin/execlineb +# Write Once Read Many (WORM) storage system from Plan 9 (p9p) + +fdmove -c 2 1 + +foreground { mkdir -p /home/venti } + +fossil -s + -c conf + -a tcp!*!17034 + -h tcp!*!8080 diff --git a/s6/geomyidae/log/run b/s6/geomyidae/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/geomyidae/ diff --git a/s6/geomyidae/run b/s6/geomyidae/run @@ -0,0 +1,9 @@ +#!/usr/local/bin/execlineb +# simple gopher server with index.gph syntax and CGI support + +fdmove -c 2 1 + +geomyidae -d + -b /home/srv/josuah.net + -h 0.0.0.0 + -p 70 diff --git a/s6/git-daemon/log/run b/s6/git-daemon/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/git-daemon/ diff --git a/s6/git-daemon/run b/s6/git-daemon/run @@ -0,0 +1,10 @@ +#!/usr/local/bin/execlineb +# git daemon for serving git:// + +fdmove -c 2 1 + +tcpserver 0.0.0.0 9418 +git daemon + --inetd + --export-all + --base-path'='/home/git diff --git a/s6/git-mirror/data/mirror b/s6/git-mirror/data/mirror diff --git a/s6/git-mirror/log/run b/s6/git-mirror/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/git-mirror/ diff --git a/s6/git-mirror/run b/s6/git-mirror/run @@ -0,0 +1,6 @@ +#!/usr/local/bin/execlineb +# periodically mirror git repositories + +fdmove -c 2 1 + +snooze -M 0 -H 5 ./data/mirror diff --git a/s6/gproxy/data/gproxy b/s6/gproxy/data/gproxy @@ -0,0 +1,110 @@ +#!/usr/bin/awk -f + +# proxy from gopher to http and html for use with inetd + +# /etc/inetd.conf: +# gproxy stream tcp nowait nobody /.../gproxy gproxy host + +BEGIN { + HOST = ARGV[1]; + ARGC = 0; +} + +{ + sub("^GET /(gopher://)?", ""); sub(" HTTP/[0-9].*$", ""); + gsub(" ", "%20"); + gsub("\t", "%0b"); + gsub("\\\\", "%5c"); + + host = $0 + if (sub("^[^:]*:", ":")) { + sub(":.*", "", host); + } else if (sub("[^/]*/", "/")) { + sub("/.*", "", host); + } else { + $0 = ""; + } + + port = $0 + if (sub("^:[0-9]+:", "") || sub("^:[0-9]+/", "/")) { + sub(":", "", port); + sub("[:/].*", "", port); + } else if (sub("^:[0-9]+$", "")) { + sub(":", "", port); + } else { + port = "70"; + } + + flag = $0; + if (sub("^/.", "")) { + sub("^/", "", flag); + sub("/.*", "", flag); + } else { + flag = "1"; + } + + path = $0; + + exit; +} + +function esc(str) +{ + gsub("&", "\\&amp;", str); + gsub("<", "\\&lt;", str); + gsub(">", "\\&gt;", str); + gsub("\"", "\\&quot;", str); + return str; +} + +function url(f) +{ + if (sub("^URL:", "", f[2])) + return f[2]; + return sprintf("http://%s/%s:%s/%s%s", HOST, f[3], f[4], f[0], f[2]); +} + +function link(f) +{ + return sprintf("<a href=\"%s\">%s</a>", url(f), esc(f[1])); +} + +END { + gsub("'", "", path); + gsub("'", "", host); + if (host == "") + host = "localhost"; + cmd = "printf '%s\r\n' '" path "' | nc -w 5 '" host "' 70" + + print("HTTP/1.1 200 OK\r"); + + if (flag == "1" || flag == "") { + print("Content-Type: text/html; charset=UTF-8\r"); + print("\r"); + print("<!doctype html><title>" HOST "</title>"); + print("<style>a { text-decoration:none; color:#077; }</style>"); + print("<pre style=\"width: 80ch; margin: auto;\">"); + + while (cmd | getline) { + sub("\r$", ""); + split($0, f, "\t"); + f[0] = substr(f[1], 1, 1); + sub(".", "", f[1]); + + if (f[0] == "i") + printf("%s\n", esc(f[1])); + else + print(link(f)); + } + print("</pre>"); + + } else if (flag == "0") { + print("Content-Type: text/plain; charset=UTF-8\r"); + print("\r"); + system(cmd); + + } else { + print("\r"); + system(cmd); + } +} diff --git a/s6/gproxy/log/run b/s6/gproxy/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/gproxy/ diff --git a/s6/gproxy/run b/s6/gproxy/run @@ -0,0 +1,6 @@ +#!/usr/local/bin/execlineb +# experimental gopher to http proxy + +fdmove -c 2 1 + +tcpserver 0.0.0.0 8080 ./data/gproxy <host> diff --git a/s6/ii-tail/log/run b/s6/ii-tail/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/ii-tail/ diff --git a/s6/ii-tail/run b/s6/ii-tail/run @@ -0,0 +1,13 @@ +#!/usr/local/bin/execlineb -B +# watch for new channels on all directories and watch all files for nick name + +fdmove -c 2 1 + +s6-envdir env +importas USER USER +s6-setsiduid ${USER} +importas HOME HOME +cd ${HOME}/irc/ + +fdmove 1 ./out +tail -f -n 3 ./*/out ./*/*/out diff --git a/s6/ii-tcp/env/HOST b/s6/ii-tcp/env/HOST @@ -0,0 +1 @@ +irc.freenode.net diff --git a/s6/ii-tcp/env/NAME b/s6/ii-tcp/env/NAME diff --git a/s6/ii-tcp/env/NICK b/s6/ii-tcp/env/NICK @@ -0,0 +1 @@ +josuah diff --git a/s6/ii-tcp/env/PASS b/s6/ii-tcp/env/PASS diff --git a/s6/ii-tcp/env/PORT b/s6/ii-tcp/env/PORT @@ -0,0 +1 @@ +6697 diff --git a/s6/ii-tcp/env/USER b/s6/ii-tcp/env/USER @@ -0,0 +1 @@ +josuah diff --git a/s6/ii-tcp/log/run b/s6/ii-tcp/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/ii-tcp/ diff --git a/s6/ii-tcp/run b/s6/ii-tcp/run @@ -0,0 +1,29 @@ +#!/usr/local/bin/execlineb -P +# connect to an irc server through ii through tlsserver + +fdmove -c 2 1 + +s6-envdir env + +multisubstitute { + importas HOST HOST + importas PORT PORT + importas USER USER + importas NICK NICK + importas NAME NAME +} + +ifelse -n { test -f ${CAFILE} } { + redirfd -r 0 /dev/null + redirfd -w 1 ${CAFILE} + openssl s_client -showcerts -connect ${HOST}:6697 +} + +s6-setuidgid ${USER} + +s6-tcpclient ${HOST} ${PORT} + +ii -s ${HOST} + -n ${NICK} + -f ${NAME} + -k PASS diff --git a/s6/ii-tls/data/.empty b/s6/ii-tls/data/.empty diff --git a/s6/ii-tls/env/CAFILE b/s6/ii-tls/env/CAFILE @@ -0,0 +1 @@ +./data/cert.pem diff --git a/s6/ii-tls/env/HOST b/s6/ii-tls/env/HOST @@ -0,0 +1 @@ +173.230.128.213 diff --git a/s6/ii-tls/env/NAME b/s6/ii-tls/env/NAME diff --git a/s6/ii-tls/env/NICK b/s6/ii-tls/env/NICK @@ -0,0 +1 @@ +josuah diff --git a/s6/ii-tls/env/PASS b/s6/ii-tls/env/PASS diff --git a/s6/ii-tls/env/PORT b/s6/ii-tls/env/PORT @@ -0,0 +1 @@ +6697 diff --git a/s6/ii-tls/env/USER b/s6/ii-tls/env/USER @@ -0,0 +1 @@ +josuah diff --git a/s6/ii-tls/log/run b/s6/ii-tls/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/ii-tls/ diff --git a/s6/ii-tls/run b/s6/ii-tls/run @@ -0,0 +1,30 @@ +#!/usr/local/bin/execlineb +# connect to an irc server through ii through tlsserver + +fdmove -c 2 1 + +s6-envdir env + +multisubstitute { +importas HOST HOST +importas PORT PORT +importas USER USER +importas NICK NICK +importas NAME NAME +importas CAFILE CAFILE +} + +ifelse -n { test -f ${CAFILE} } { + redirfd -r 0 /dev/null + redirfd -w 1 ${CAFILE} + openssl s_client -showcerts -connect ${HOST}:6697 +} + +s6-setuidgid ${USER} + +s6-tlsclient ${HOST} ${PORT} + +ii -s ${HOST} + -n ${NICK} + -f ${NAME} + -k PASS diff --git a/s6/mpop/data/mpoprc b/s6/mpop/data/mpoprc @@ -0,0 +1,15 @@ +defaults +tls on +tls_certcheck off +tls_starttls off +uidls_file ~/mail/%U + +account mail@josuah.net +host mail.gandi.net +user mail@josuah.net +auth user +passwordeval "enchive -a$((3600*12)) extract /mnt/key/vault/mpop /dev/stdout" +delivery maildir ~/mail/INBOX +keep on + +account default : mail@josuah.net diff --git a/s6/mpop/env/USER b/s6/mpop/env/USER @@ -0,0 +1 @@ +josuah diff --git a/s6/mpop/log/run b/s6/mpop/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/mpop/ diff --git a/s6/mpop/run b/s6/mpop/run @@ -0,0 +1,16 @@ +#!/usr/local/bin/execlineb -P +# update pop mail using mpop + +fdmove -c 2 1 + +s6-envdir env + +importas USER USER +redirfd -r 0 ./data/mpoprc # it might not be readable as ${USER} +s6-setuidgid ${USER} + +backtick -n HOME { homeof ${USER} } +importas HOME HOME +cd ${HOME} + +snooze -M /5 -H * mpop -C /dev/stdin diff --git a/s6/ngircd/data/conf b/s6/ngircd/data/conf @@ -0,0 +1,45 @@ +[Global] + Name = XXX + AdminInfo1 = josuah + AdminInfo2 = XXX + AdminEMail = mail@josuah.net + Info = XXX + MotdFile = motd + Network = XXX + Ports = 6697 + +[Limits] + MaxConnections = 128 + MaxConnectionsIP = 20 + MaxJoins = 50 + MaxNickLength = 10 + PingTimeout = 120 + PongTimeout = 120 + +[Options] + AllowedChannelTypes = #&+ + AllowRemoteOper = yes + CloakHost = %x%x + CloakHostSalt = XXX + DefaultUserModes = iC + DNS = no + Ident = no + MorePrivacy = yes + OperCanUseMode = yes + OperChanPAutoOp = yes + +[SSL] + Ports = 6697 + CertFile = pem + DHFile = dhp + KeyFile = key + KeyFilePassword = XXX + CipherList = AES+RSA + +[Operator] + Name = josuah + Password = XXX + Mask = josuah!XXX + +[Server] + XXX diff --git a/s6/ngircd/data/motd b/s6/ngircd/data/motd @@ -0,0 +1,37 @@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@ This server is not ready yet, visit https://cyberia.uptime.party/ @ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + + __,--- + ,-' / + / , , /_ _ __ . ___ + / / / / \ ,'_| /' / ,' / + \__\ /_ /__,'_\__ / __ /__\__/___ __ _ + \/ + ____/ + +Listening on ports: 6697 (TLS) +irc.cyberia.systems + +Welcome to Cyberia +We're stoked you are here +Love Lain or be lame + +Rules: + - No spamming or flooding + - No clones or malicious bots + - No takeovers + - No distribution of child pornography + - Do not harass other users + - Clients must respond to VERSION requests + + We reserve the right to remove your access to this server and network + at any time at our opers discretion. + +First steps: + - Find an existing IRC channel on this network: /list + - Join an IRC channel or create your own: /join <#channel> + +Getting help: + - For helpdesk on using IRC: /join #help + - For network issues, status and server operator queries: /join #noc diff --git a/s6/ngircd/data/tls b/s6/ngircd/data/tls @@ -0,0 +1,8 @@ +#!/9/bin/rc -ex + +openssl req -x509 -newkey rsa:4096 -days 365 -keyout key -out pem +chmod 400 key +chmod 444 pem + +openssl dhparam -out dhp 4096 +chmod 444 dhp diff --git a/s6/ngircd/log/run b/s6/ngircd/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/ngircd/ diff --git a/s6/ngircd/run b/s6/ngircd/run @@ -0,0 +1,6 @@ +#!/usr/local/bin/execlineb +# Internet Relay Chat (IRC) daemon with TLS support (see ./tls) + +fdmove -c 2 1 + +ngircd -n -f ./data/conf diff --git a/s6/opentracker/log/run b/s6/opentracker/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/opentracker/ diff --git a/s6/opentracker/run b/s6/opentracker/run @@ -0,0 +1,6 @@ +#!/usr/local/bin/execlineb +# torrent tracker server + +fdmove -c 2 1 + +opentracker -d /home/tracker diff --git a/s6/plot/data/plot b/s6/plot/data/plot @@ -0,0 +1,62 @@ +#!/9/bin/rc -e + +fn csv_cat_tail { + lines=$1 + shift + sed 1q $1 + {for (file in $*) sed 1d $file} | tail -n $lines +} + +fn csv_join { + file=$1 + shift + + if (~ $#* 0) + exec cat $file + if not csv_join $* | tr ',' '\t' | + join -1 1 -2 1 <{tr ',' '\t' <$file} - | tr ' ' ',' +} + +fn csv_labels { + printf 'epoch' + printf ',%s' $* + printf '\n' + + sed 1d # because first line often contains data since boot time +} + +last=100 + +mkdir -p $SRV/img + +for (host in /var/collectd/*) { + cd $host + + if (test -d cpu) { + csv_join \ + <{csv_cat_tail $last cpu/percent-idle-*} \ + <{csv_cat_tail $last cpu/percent-nice-*} \ + <{csv_cat_tail $last cpu/percent-user-*} \ + <{csv_cat_tail $last cpu/percent-interrupt-*} \ + <{csv_cat_tail $last cpu/percent-system-*} | + csv_labels idle nice user interrupt system | + ploot -t CPU -u % green cyan yellow red orange | + ff2png >$img/cpu.png + } + + if (test -d load) { + csv_cat_tail $last load/load-relative-* | + ploot -t Load red yellow orange | + ff2png >$img/load.png + } + + if (test -d memory) { + csv_join \ + <{csv_cat_tail $last memory/percent-active-*} \ + <{csv_cat_tail $last memory/percent-inactive-*} \ + <{csv_cat_tail $last memory/percent-free-*} | + csv_labels active inactive free | + ploot -t Memory -u % red yellow green | + ff2png >$img/mem.png + } +} diff --git a/s6/plot/log/run b/s6/plot/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/plot/ diff --git a/s6/plot/run b/s6/plot/run @@ -0,0 +1,6 @@ +#!/usr/local/bin/execlineb +# generate statistics with the plot tool + +fdmove -c 2 1 + +snooze -H * -M * -S * ./data/plot diff --git a/s6/qemu-tap/log/run b/s6/qemu-tap/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/qemu-tap/ diff --git a/s6/qemu-tap/run b/s6/qemu-tap/run @@ -0,0 +1,23 @@ +#!/usr/local/bin/execlineb +# qemu without networking services, using a tap ethernet device + +# The virtual machine main interface (nic,vlan=0) is communicating +# through a tap device (tap,vlan=0) in the host that is not connected to +# anything yet. A bridge needs to be setup between this interface and +# anything it needs to connect to. + +fdmove 2 1 + +backtick name { getcwd PWD basename $PWD } +importas name name + +qemu-system-x86_64 + -name $name + -m 333M + -netdev tap,id=nd0,ifname=tap0,script=no,downscript=no + -device virtio-net,netdev=nd0,mac=52:54:00:00:00:00 + /var/iso/$name.iso + +# -display none +# -display curses +# -display vnc=0.0.0.0:0 diff --git a/s6/qemu-user/log/run b/s6/qemu-user/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/qemu-user/ diff --git a/s6/qemu-user/run b/s6/qemu-user/run @@ -0,0 +1,21 @@ +#!/usr/local/bin/execlineb +# qemu with facilitated networking services + +# The virtual machine communicates with the hypervisor, which setups +# a lot of servers (dns, tftp, dhcp...) for ease of use. + +fdmove -c 2 1 + +backtick name { getcwd PWD basename $PWD } +importas name name + +qemu-system-x86_64 + -m 333M + -name $name + -netdev user,id=nd0,hostfwd=tcp::10000-:22 + -device e1000,netdev=nd0 + -display none + /var/iso/$name.iso + +# -display curses +# -display vnc=0.0.0.0:$vnc diff --git a/s6/qmail-smtpd/log/run b/s6/qmail-smtpd/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/qmail-smtpd/ diff --git a/s6/qmail-smtpd/run b/s6/qmail-smtpd/run @@ -0,0 +1,9 @@ +#!/usr/local/bin/execlineb +# qmail smtp daemon + +fdmove -c 2 1 + +s6-envuidgid qmaild + +s6-tcpserver -U 0.0.0.0 25 +qmail-smtpd diff --git a/s6/qmail-start/log/run b/s6/qmail-start/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/qmail-start/ diff --git a/s6/qmail-start/run b/s6/qmail-start/run @@ -0,0 +1,8 @@ +#!/usr/local/bin/execlineb +# start watching qmail dir for queued messages + +fdmove -c 2 1 + +foreground { redirfd 1 /home/qmail/defaultdelivery echo ./Maildir/ } + +qmail-start ./Maildir/ diff --git a/s6/quark-tor/log/run b/s6/quark-tor/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/quark-tor/ diff --git a/s6/quark-tor/run b/s6/quark-tor/run @@ -0,0 +1,17 @@ +#!/usr/local/bin/execlineb +# static http server + +fdmove -c 2 1 + +backtick tor { homeof tor } +importas tor tor + +backtick host { cat $tor/http/hostname } +importas host host + +quark -l + -u srv + -h 0.0.0.0 + -p 80 + -d /home/srv + -v $host" "$host"$ cyberia.systems" diff --git a/s6/quark/log/run b/s6/quark/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/quark/ diff --git a/s6/quark/run b/s6/quark/run @@ -0,0 +1,14 @@ +#!/usr/local/bin/execlineb +# static http server + +fdmove -c 2 1 + +quark -l + -u srv + -h 0.0.0.0 + -p 80 + -d /home/srv + -v "josuah.net josuah.net$ josuah.net" + -v "josuah.cyb josuah.cyb$ josuah.net" + -v "cyberia.systems cyberia.systems$ cyberia.systems" + -v "www.atelier-fu.fr atelier-fu.fr$ atelier-fu.fr" diff --git a/s6/ratox/log/run b/s6/ratox/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/ratox/ diff --git a/s6/ratox/run b/s6/ratox/run @@ -0,0 +1,11 @@ +#!/usr/local/bin/execlineb +# tox protocol client communicating through the filesystem + +fdmove -c 2 1 + +define dir /home/tox + +mkdir -p $dir +cd $dir + +exec ratox diff --git a/s6/ssh-fwd/log/run b/s6/ssh-fwd/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/ssh-fwd/ diff --git a/s6/ssh-fwd/run b/s6/ssh-fwd/run @@ -0,0 +1,7 @@ +#!/usr/local/bin/execlineb +# ssh tunnelling + +fdmove -c 2 1 + +ssh -L <port_local>:<host>:<port_remote> + -n <user>@<host> diff --git a/s6/tinc/data/conf.d/common.conf b/s6/tinc/data/conf.d/common.conf @@ -0,0 +1,2 @@ +DeviceStandby = no +PingTimeout = 15 diff --git a/s6/tinc/data/hosts/kroa b/s6/tinc/data/hosts/kroa @@ -0,0 +1,13 @@ +Address = kroa.josuah.net +Subnet = 172.16.55.5 +Port = 6655 + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAmnT1YEcPTOiaa/GfWsFF1p3Qo/xeIjIb6e/cG62nKcjJSS+L3G+P +VUFOT7YfRdggzWDAMvxdAq5+DFcg2v3iDm8yTcv8ITaSKHFp4Tarkl2zEs5VELVY +mcPrYI99oyo9xiXh+x1G9/wp+uKxgoeU4m0+iNwyZw7ypoIgJhx8TfT7rgaXmyNX +HDBu/hBH7orTF3TMRp/VrWqD8UQyD0tK1gGQe4WIQJqouPxd44O8tKRgtha69q42 +kZ92DuFHLjTkYFjt4WKGEUAdja+aqbk5QeNyoOHtw9VkTIJcWShwPTYj0Ykdm/BS +oyBpV8pID+xWz81lpMilfanlPjgmzc6UvQIDAQAB +-----END RSA PUBLIC KEY----- +Ed25519PublicKey = UzE1NtmdKv3MWpslesWIT4/AB3a8WZX+AP/2suMRUnK diff --git a/s6/tinc/data/hosts/nas b/s6/tinc/data/hosts/nas @@ -0,0 +1,13 @@ +Address = nas.josuah.net +Subnet = 172.16.55.2 +Port = 655 + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAxFl/zn8owPVa0EBaazQaUck0ImV3+VS9+jOs0tePcQxuYHtX94dm +ZlYADJP/TaN8IEezQcgm2+iyavoOEBTCKhQ7/mYqG6UI2bcZjtu5UFl37YUJEYHN +dhvrhJwoYOWTFSu/d+UT/k8tFxoW308AXxqmb85egSBg8zaekrS7ibBSMi+AVaAz +g/Me+qgWh2j6jGh55Av1JeJ+1trlRLIvMRDwPe0U4hRjEZ/nBXFQS67AW1qg2tSF +3ieQgIr12FyZMw3ieWKiUW3JShdYRRMnV8hfKsn98R8LOirXBY2nCqRkWvKjYyY6 +bN2MzG57jdprYDR4ljglDFaXsNCDFgWTXwIDAQAB +-----END RSA PUBLIC KEY----- +Ed25519PublicKey = QbVvGg+CgFHyzWzbmG4hpY7Kus3kMZean2Vj52v2roN diff --git a/s6/tinc/data/hosts/pdmg b/s6/tinc/data/hosts/pdmg @@ -0,0 +1,12 @@ +Subnet = 172.16.55.4 +Port = 655 + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAxnCPtS3uHC8ZwZCDDPpDZWfuQF2PP1GdqHAF7pmk1mXCfapSVU/I +5gVP7scrbSKhNXpeQvgfRk7BQ+O1TpvhYDJRR6/xlACbaWeoFIQLbBMik10Dvw7k +Zrt/cnF8WTdEgQ52GIhwJhc/ZoBQHLfoAPZrD3lyTG4PQb/VyouQVJq8JgthHgIi +u3jz3meiB292rz9kg+wafl7YVsvWQZMK3CAHWjKLOaSNFYM6zkZU42v5d2mkC1aT +JowYMn0GRTKL4IC2WkzAt1JNK5Hd8YexdKBfqmobZI+SevlPYVkZLM7jmcTR7836 +bdBZF/tZpvRUY7eHSwVni576SwO+zakt3wIDAQAB +-----END RSA PUBLIC KEY----- +Ed25519PublicKey = 5ooarAS0cWAxPQ6q2wn/1ZvhLYuz6ZRSJGZFFMMeZBF diff --git a/s6/tinc/data/hosts/rpi b/s6/tinc/data/hosts/rpi @@ -0,0 +1,13 @@ +Address = rpi.josuah.net +Subnet = 172.16.55.3 +Port = 655 + +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA35oN9yPu+lF7ZmphYandl896xjKYnNjIn5UB4gGvfbBEEA3kKYev +6Z4ApOvw2AgQ3WVbAynG3KbNj5jsCBBG8M9PfSPeFn4jpjycDqORi3sW6z3MQHfZ +u61jif16QtuuwXtrTiWO+MEVmSsCH9Vxtq5L6qJHZA7pEkQMxu/aEjOpYdpwZb/M +AnO7TU+PzTjUte40sfrIczHHkpDh8CdS1mKseF1XcNBhUANB7F6hQwhwD96GdGer +ioqMpltyyXMz4oZvhV+LD/jVOUXD1FZjiqO5TNtCFXYDLF/gxq/vmQ84eDo/I3Mo +E7wbHst5mOSRLBUP9cCAys/r6+JAdg+LfwIDAQAB +-----END RSA PUBLIC KEY----- +Ed25519PublicKey = Zsy56fH9Hbd/qiRWRy/7YEKv4eQUPI1o+3iXs8lHN1N diff --git a/s6/tinc/data/hosts/t470s b/s6/tinc/data/hosts/t470s @@ -0,0 +1,12 @@ +Subnet = 172.16.55.1 + +Port = 12196 +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAs99vlkaTp2BWltxN5KiBMkH/fHV1O3DWARK6ojFlhgENdmGjDxxk +0rshmaAvSjZ3uU2z+QkUIpovqEZf5I5abrAu1yKyMTIMFwqasa5D3TSkcePf+dD7 +LIr/YBWPl6kxHrNd2s3qPXBoYNaTBX7CCdXla7Rlz1/EnkMCfSLLd6YQsaCR4MsE +dwgR17bu5MsvB9YNLvbkqHHZCwvwIHrvX8dxvCr1BZwHAt/SDwg0nnTD2YNBUUl+ +SsXzMNfKiEjqmfHGfzMmP9Q9yjM6W5YAr+/Y7OPb/LnsPbYNC1L5YqaKskM431JU +vcpAPqjRJTvo+ji4hKrKdRal6tE61ZUW4wIDAQAB +-----END RSA PUBLIC KEY----- +Ed25519PublicKey = Wnd7bglt6wxqz/QJT1KH9wajs2LUUnMTHTDSU7/SsQM diff --git a/s6/tinc/data/tinc-up b/s6/tinc/data/tinc-up @@ -0,0 +1,11 @@ +#!/9/bin/rc -xe + +switch (`{uname}) { +case *BSD + ifconfig "$INTERFACE" "$(tinc -c . get subnet)" netmask 255.255.255.0 + +case Linux + ip link set "$INTERFACE" up + ip addr add "$(tinc -c . get subnet | sed q)/24" dev "$INTERFACE" + +} diff --git a/s6/tinc/log/run b/s6/tinc/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/tinc/ diff --git a/s6/tinc/run b/s6/tinc/run @@ -0,0 +1,9 @@ +#!/usr/local/bin/execlineb +# vpn focused on mesh networking + +fdmove -c 2 1 + +tincd -D + -d 5 + --config=./data + --pidfile=./data/pid diff --git a/s6/tinysshd/log/run b/s6/tinysshd/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/tinysshd/ diff --git a/s6/tinysshd/run b/s6/tinysshd/run @@ -0,0 +1,11 @@ +#!/usr/local/bin/execlineb +# SSHv2 server with minimal footprint https://tinyssh.org/ + +fdmove -c 2 1 + +foreground { mkdir -p ./data/ } +foreground { if { test ! -d ./data/key/ } tinysshd-makekey ./data/key/ } +foreground { chmod 500 ./data/key/ } + +s6-tcpserver 0.0.0.0 22 +tinysshd -sovv ./data/key/ diff --git a/s6/tls/log/run b/s6/tls/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/tls/ diff --git a/s6/tls/run b/s6/tls/run @@ -0,0 +1,12 @@ +#!/usr/local/bin/execlineb +# TLS proxy based off brsl and ucspi-unix + +fdmove -c 2 1 + +backtick host { pipeline pwd | sed -r "s,.*/tls-,," } +importas host host + +mkdir -p /tmp/tls + +unixserver /tmp/tls/$host +brssl client $host diff --git a/s6/tor/data/conf b/s6/tor/data/conf @@ -0,0 +1,26 @@ +Log debug stderr +RunAsDaemon 0 + +DataDirectory @LOCALSTATEDIR@/var/tor + +## Once you have configured a hidden service, you can look at the +## contents of the file ".../hidden_service/hostname" for the address +## to tell people. +## +## HiddenServicePort x y:z says to redirect requests on port x to the +## address y:z. + +SOCKSPort 0 +User tor +PIDFile /home/tor/pid +Log notice stderr +DataDirectory /home/tor + +HiddenServiceDir /home/tor/gopher +HiddenServicePort 70 127.0.0.1:71 + +HiddenServiceDir /home/tor/http +HiddenServicePort 80 127.0.0.1:8080 + +HiddenServiceDir /home/tor/icecast +HiddenServicePort 3232 127.0.0.1:3232 diff --git a/s6/tor/log/run b/s6/tor/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/tor/ diff --git a/s6/tor/run b/s6/tor/run @@ -0,0 +1,6 @@ +#!/usr/local/bin/execlineb +# tor daemon for routing and publishing services + +fdmove -c 2 1 + +tor -f ./data/conf diff --git a/s6/u9fs-mount/down b/s6/u9fs-mount/down @@ -0,0 +1,4 @@ +#!/usr/local/bin/execlineb +# mount a 9p filesystem from a local UNIX socket + +exec /mnt/9p diff --git a/s6/u9fs-mount/log/run b/s6/u9fs-mount/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/u9fs-mount/ diff --git a/s6/u9fs-mount/up b/s6/u9fs-mount/up @@ -0,0 +1,5 @@ +#!/usr/local/bin/execlineb +# mount a 9p filesystem from a local UNIX socket + +mkdir -p /mnt/9p +exec 9pfs -U /tmp/9p /mnt/9p diff --git a/s6/u9fs/log/run b/s6/u9fs/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/u9fs/ diff --git a/s6/u9fs/run b/s6/u9fs/run @@ -0,0 +1,8 @@ +#!/usr/local/bin/execlineb +# forward u9fs from a remote host to a local socket through ssh + +fdmove -c 2 1 + +unixserver -v /tmp/9p +ssh u9fs@host +u9fs -l /dev/stderr -a none -u u9fs /home/u9fs diff --git a/s6/venti/data/conf b/s6/venti/data/conf @@ -0,0 +1,8 @@ +index main + +isect /home/venti/isect0 +isect /home/venti/isect1 +arenas /home/venti/arena0 +mem 10M +bcmem 20M +icmem 30M diff --git a/s6/venti/data/fmt b/s6/venti/data/fmt @@ -0,0 +1,9 @@ +#!/9/bin/rc -e + +dd 'if=/dev/zero' 'of=/home/venti/isect0' 'bs=1M' 'count=1k' +dd 'if=/dev/zero' 'of=/home/venti/arena0' 'bs=1M' 'count=1k' + +/9/port/bin/venti/fmtisect isect0 /home/venti/isect0 +/9/port/bin/venti/fmtisect isect1 /home/venti/isect1 +/9/port/bin/venti/fmtarenas arena0 /home/venti/arena0 +/9/port/bin/venti/fmtindex conf diff --git a/s6/venti/log/run b/s6/venti/log/run @@ -0,0 +1,2 @@ +#!/usr/local/bin/execline -P +s6-log t /var/log/venti/ diff --git a/s6/venti/run b/s6/venti/run @@ -0,0 +1,11 @@ +#!/usr/local/bin/execlineb +# write once read many (worm) storage server from plan 9 (p9p) + +fdmove -c 2 1 + +s6-setuidgid venti + +venti -s + -c ./data/conf + -a tcp!*!17034 + -h tcp!*!8080