add unplug command
Ted Unangst tedu@tedunangst.com
Sun, 08 Dec 2019 19:17:38 -0500
3 files changed,
22 insertions(+),
0 deletions(-)
M
docs/changelog.txt
→
docs/changelog.txt
@@ -2,6 +2,8 @@ changelog
-- next ++ Add unplug command for servers that have dropped off the net. + + Add notes field to honkers to document their downfall. + Add notes field to filters for record keeping.
M
docs/honk.8
→
docs/honk.8
@@ -133,6 +133,12 @@ .Pp
The current version of the honk binary may be printed with the .Ic version command. +.Ss unplug +Sometimes servers simply disappear, resulting in many errors trying to deliver +undeliverable messages. +Running +.Ic unplug Ar hostname +will delete all subscriptions and pending deliveries. .Ss Security .Nm is not currently hardened against SSRF, server side request forgery.
M
honk.go
→
honk.go
@@ -210,6 +210,13 @@
func ElaborateUnitTests() { } +func unplugserver(hostname string) { + db := opendatabase() + xid := fmt.Sprintf("%%https://%s/%%", hostname) + db.Exec("delete from honkers where xid like ? and flavor = 'dub'", xid) + db.Exec("delete from doovers where rcpt like ?", xid) +} + func main() { flag.StringVar(&dataDir, "datadir", dataDir, "data directory") flag.StringVar(&viewDir, "viewdir", viewDir, "view directory")@@ -271,6 +278,13 @@ if len(args) > 1 {
arg = args[1] } cleanupdb(arg) + case "unplug": + if len(args) < 2 { + fmt.Printf("usage: honk unplug servername\n") + return + } + name := args[1] + unplugserver(name) case "ping": if len(args) < 3 { fmt.Printf("usage: honk ping from to\n")