Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
@dch
dch / http_proxy.go
Created December 7, 2023 18:47 — forked from jim3ma/http_proxy.go
Register Dialer Type for HTTP&HTTPS Proxy in golang
package main
import (
"bufio"
"fmt"
"net"
"net/http"
"net/url"
"crypto/tls"
@dch
dch / jr.fish
Last active September 27, 2023 17:44
see https://git.sr.ht/~dch/diy-jails/ for some background
function jr
set local
set JAIL $argv[1]
set INSTANCE (jls -j $JAIL path)
pkill -TERM -j $JAIL
sleep 3
doas jail -rv $JAIL
doas umount -f $INSTANCE/tmp
doas umount -f $INSTANCE/dev
end
@dch
dch / spicey-rub.md
Last active July 15, 2023 11:49
Dave's magic Spicey Dry Rub

2023 Spicey Rub 2.0

  • measurements don't need to be precise

  • adjust chilli, cayenne & cumin to taste

  • leave your recommendations in the comments!

  • T Tablespoon

  • t teaspoon

  • C metric cup ~ 200mL

Settable via /etc/sysctl.conf:

integer kern.maxvnodes

Target for maximum number of vnodes

integer kern.maxfiles

Maximum number of files

integer kern.securelevel

Current secure level

This file has been truncated, but you can view the full file.
-- SPDX-License-Identifier: CC0-1.0
-- vim:syntax=lua:set ts=4 sw=4:
-- Refer to manual: https://knot-resolver.readthedocs.org/en/stable/
-- Network interface configuration
net.listen('127.0.0.1', 53, { kind = 'dns' })
net.listen('100.64.0.0', 53, { kind = 'dns' })
net.listen('172.16.1.1', 53, { kind = 'dns' })
net.listen('172.16.2.1', 53, { kind = 'dns' })
net.listen('::1', 53, { kind = 'dns', freebind = true })
@dch
dch / _zerotier_vpn_on_freebsd.md
Last active November 25, 2022 08:26
how to set up FreeBSD as a zerotier.com vpn

I'm using [PORT]net/zerotier[/PORT] for quite some time as a way of getting to my systems from other networks very happily. It works in airports, cafes, and all the usual hostile places we travel to.

It provides a L2 encrypted mesh (a bit like VXLAN I suppose) via a tap interface.

What I'd like to do is to use the ZT network as a VPN - routing all traffic from my FreeBSD laptop and phone through the zerotier layer out to my appointed ZT "VPN Gateway". Basically, translating the linux doc here: https://support.zerotier.com/knowledgebase.php?entry=show&search-for=full&article=ZWFhNWMyMTZjODY1ODcwNmFhZmJjYmRhN2I5MjRhOGQ_ -- into FreeBSD config. BTW https://www.zerotier.com/manual.shtml has a lot of background detail if you're interested.I can get the iphone working, but not the laptop.

What works after configuring zerotier to provide the "default route" is different on each device:

  • the iphone works
  • an apple imac works
#!/bin/sh -eu
sudo kldload filemon || /usr/bin/true
# echo 'WITH_CCACHE_BUILD=yes' > /etc/src.conf
echo 'WITH_META_MODE=yes' > /etc/src-env.conf
# echo 'WITH_DIRDEPS_BUILD=yes' >> /etc/src-env.conf
# umask 0022
cd /usr/src
NOW=$(date -u +%Y%m%d-%H%M)
NCPU=$(sysctl -n hw.ncpu)
@dch
dch / _readme.md
Last active October 3, 2022 21:17
GET haproxy sticky table data as json

HTTP JSON API for haproxy stick tables

intro

A quick sketch of haproxy config with lua to provide an HTTP API to query stick tables in JSON format. Probably has a few rough edges around output as kv_pairs() doesn't really understand its output, just building up strings. A proper table traversal function would be better, and verifying its actually valid JSON would be even better.

@dch
dch / main.yml
Created December 12, 2018 19:13
ansible zerotier role
---
- name: zerotier | install pkg
pkgng:
state: latest
name:
- net/zerotier
notify: zerotier | restart
tags:
- pkg
- zerotier
#!/bin/bash
#
# dumpACPItables, get all Tables from Mac OS X ioreg.
#
# 06-19-2009 AlainTox714
#
# path: /usr/local/bin
#
ACPIdir="/Users/${USER}/Desktop/ACPI_tables"