Skip to content

Instantly share code, notes, and snippets.

@Zash
Zash / dnsupdate-policy.lua
Created January 23, 2022 10:55
PowerDNS DNSUPDATE policy script
-- Policy control thing with policy derived from key name
-- "keyname.owner.domain" will be allowed to edit domain (including suddomains)
-- Special keyname "acme" should be allowed to add and remove _acme-challenge TXT records under domain
-- Assumes that the key name can't be faked
function updatepolicy(request)
local tsig = request:getTsigName();
local zone = request:getZoneName();
pdnslog("updatepolicy: tsig "..tsig:toString().." wants to update "..request:getQName():toString().." in "..zone:toString(), pdns.loglevels.Info);
@Zash
Zash / hg.example.com
Last active July 19, 2020 10:27
hgweb+nginx
server {
server_name hg.example.com;
root /var/www/hg.example.com;
listen 0.0.0.0:80;
listen 0.0.0.0:443 ssl;
listen [::]:80;
listen [::]:443 ssl http2;
@Zash
Zash / md-diff.sh
Last active April 21, 2018 15:39
XEP diff stuff
#!/bin/bash
# arguments: file commit commit [diff tool with args]
${4:-diff} \
<(git show "$2:$1" | ./xep2md.sh -) \
<(git show "$3:$1" | ./xep2md.sh -)
@Zash
Zash / mod_s2s_certinfo.lua
Last active July 20, 2016 13:18
Riddim plugin for showing info about certificates along with server-side support plugin.
local xmlns = "http://zash.se/protocol/s2scertinfo";
local st = require"util.stanza";
-- local dump = require"myserialize".serialize;
local base64_encode = require"util.encodings".base64.encode;
local s_char, s_gsub = string.char, string.gsub;
local tonumber = tonumber;
local function unhexbyte(c) return s_char(tonumber(c, 16)) end
local function unhex(s) return s_gsub(s, "..", unhexbyte) end
local function hex2b64(s) return base64_encode(unhex(s)) end