Skip to content

Instantly share code, notes, and snippets.

View weiss's full-sized avatar

Holger Weiß weiss

View GitHub Profile
@weiss
weiss / ff3.c
Created November 4, 2022 14:40
Read farbfeld image into header array and body buffer
#include <err.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@weiss
weiss / ff2.c
Last active November 4, 2022 14:38
Read farbfeld image into raw buffer
#include <err.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@weiss
weiss / ff1.c
Last active November 4, 2022 14:38
Read farbfeld image into struct
#include <err.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@weiss
weiss / example_app.erl
Last active March 14, 2023 15:08
Erlang/OTP integration of systemd's "notify" start-up type and service watchdog feature
-module(example_app).
-behaviour(application).
-export([start/2, prep_stop/1, stop/1]).
-spec start(application:start_type(), any()) -> {ok, pid()} | {error, term()}.
start(_StartType, _StartArgs) ->
case example_sup:start_link() of
{ok, _PID} = Res ->
ok = systemd:ready(),
Res;
@weiss
weiss / ejabberd-pep.md
Created August 15, 2017 11:55
PEP notifications in ejabberd

XEP-compliant PEP notifications in ejabberd

We need:

  • A new sm_presence_in hook to track the presence of contacts from ejabberd_sm. The existing caps_add and caps_update hooks could be removed.

  • A global table (distributed across the cluster) that maps the FullJID of an

@weiss
weiss / xmpp-flood.py
Created May 12, 2015 11:58
Let two XMPP resources flood each other with messages
#!/usr/bin/env python
#
# By Holger Weiss, based on a script provided by Stefan Karlsson.
#
"""
Log in with two resources and have each of them send a never-ending message
flood to the other one.
1. Install SleekXMPP, e.g. on Debian:
@weiss
weiss / pass-address.patch
Created July 4, 2014 11:42
Also pass the client IP address to external ejabberd authentication script
From holger@zedat.fu-berlin.de Mon Sep 17 00:00:00 2001
From: Holger Weiss <holger@zedat.fu-berlin.de>
Date: Mon, 14 Apr 2014 17:10:49 +0200
Subject: [PATCH] Pass client IP address to authentication script
---
src/ejabberd_auth.erl | 10 +++++++++-
src/ejabberd_auth_external.erl | 34 +++++++++++++++++++---------------
src/ejabberd_c2s.erl | 2 +-
src/extauth.erl | 11 +++++++++--
@weiss
weiss / verify-cert-for-s2s-out.diff
Last active August 29, 2015 14:00
Shortened version of the patch submitted as ejabberd pull request #185
diff --git a/src/ejabberd_s2s.erl b/src/ejabberd_s2s.erl
index 057c60a..eb98943 100644
--- a/src/ejabberd_s2s.erl
+++ b/src/ejabberd_s2s.erl
@@ -207,6 +216,31 @@ try_register(FromTo) ->
dirty_get_connections() ->
mnesia:dirty_all_keys(s2s).
+check_peer_certificate(SockMod, Sock, Peer) ->
+ case SockMod:get_peer_certificate(Sock) of