From b471ff4191011b000f60dd2c6dafc6e5ed9458c2 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 5 Sep 2021 22:51:37 +0200 Subject: irc-announce: add tls flag --- krebs/5pkgs/simple/git-hooks/default.nix | 3 +++ krebs/5pkgs/simple/irc-announce/default.nix | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'krebs/5pkgs') diff --git a/krebs/5pkgs/simple/git-hooks/default.nix b/krebs/5pkgs/simple/git-hooks/default.nix index 0a2c8441..012c4ccf 100644 --- a/krebs/5pkgs/simple/git-hooks/default.nix +++ b/krebs/5pkgs/simple/git-hooks/default.nix @@ -12,6 +12,7 @@ with import ; , port ? 6667 , refs ? [] , server + , tls ? false , verbose ? false }: /* sh */ '' #! /bin/sh @@ -39,6 +40,7 @@ with import ; nick=${escapeShellArg nick} channel=${escapeShellArg channel} server=${escapeShellArg server} + tls=${escapeShellArg tls} port=${toString port} host=$nick @@ -114,6 +116,7 @@ with import ; "$port" \ "$nick" \ "$channel" \ + "tls" \ "$message" fi ''; diff --git a/krebs/5pkgs/simple/irc-announce/default.nix b/krebs/5pkgs/simple/irc-announce/default.nix index 52cf1286..5797b366 100644 --- a/krebs/5pkgs/simple/irc-announce/default.nix +++ b/krebs/5pkgs/simple/irc-announce/default.nix @@ -17,7 +17,8 @@ pkgs.writeDashBin "irc-announce" '' IRC_PORT=$2 IRC_NICK=$3_$$ IRC_CHANNEL=$4 - message=$5 + IRC_TLS=$5 + message=$6 export IRC_CHANNEL # for privmsg_cat @@ -34,6 +35,8 @@ pkgs.writeDashBin "irc-announce" '' # privmsg_cat transforms stdin to a privmsg privmsg_cat() { awk '{ print "PRIVMSG "ENVIRON["IRC_CHANNEL"]" :"$0 }'; } + tls_flag() { if [ "$IRC_TLS" -eq 1 ]; then echo "-c"; fi } + # ircin is used to feed the output of netcat back to the "irc client" # so we can implement expect-like behavior with sed^_^ # XXX mkselfdestructingtmpfifo would be nice instead of this cruft @@ -51,6 +54,8 @@ pkgs.writeDashBin "irc-announce" '' echo2 "USER $LOGNAME 0 * :$LOGNAME@$(hostname)" echo2 "NICK $IRC_NICK" + awk 'match($0, /PING(.*)/, m) {print "PONG", m[1]; exit}' + # wait for MODE message sed -n '/^:[^ ]* MODE /q' @@ -67,5 +72,5 @@ pkgs.writeDashBin "irc-announce" '' echo2 'QUIT :Gone to have lunch' } < ircin \ - | nc "$IRC_SERVER" "$IRC_PORT" | tee -a ircin + | nc $(tls_flag) "$IRC_SERVER" "$IRC_PORT" | tee -a ircin '' -- cgit v1.2.3