irc-announce: add tls flag
This commit is contained in:
parent
aaae1b2f5b
commit
b471ff4191
@ -9,6 +9,7 @@ with import <stockholm/lib>;
|
|||||||
${shell.escape (toString cfg.irc.port)} \
|
${shell.escape (toString cfg.irc.port)} \
|
||||||
${shell.escape cfg.irc.nick} \
|
${shell.escape cfg.irc.nick} \
|
||||||
${shell.escape cfg.irc.channel} \
|
${shell.escape cfg.irc.channel} \
|
||||||
|
${escapeShellArg cfg.irc.tls} \
|
||||||
"$message"
|
"$message"
|
||||||
'';
|
'';
|
||||||
default-get-message = pkgs.writeDash "announce-activation-get-message" ''
|
default-get-message = pkgs.writeDash "announce-activation-get-message" ''
|
||||||
@ -50,6 +51,10 @@ in {
|
|||||||
default = "irc.r";
|
default = "irc.r";
|
||||||
type = types.hostname;
|
type = types.hostname;
|
||||||
};
|
};
|
||||||
|
tls = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -19,6 +19,14 @@ let
|
|||||||
type = types.str;
|
type = types.str;
|
||||||
default = "irc.hackint.org";
|
default = "irc.hackint.org";
|
||||||
};
|
};
|
||||||
|
port = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 6697;
|
||||||
|
};
|
||||||
|
tls = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
message = mkOption {
|
message = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "SSH Hidden Service at ";
|
default = "SSH Hidden Service at ";
|
||||||
@ -53,10 +61,14 @@ let
|
|||||||
echo "still waiting for ${hiddenServiceDir}/hostname"
|
echo "still waiting for ${hiddenServiceDir}/hostname"
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
${pkgs.untilport}/bin/untilport ${cfg.server} 6667 && \
|
${pkgs.untilport}/bin/untilport ${escapeShellArg cfg.server} ${toString cfg.port}
|
||||||
${pkgs.irc-announce}/bin/irc-announce \
|
|
||||||
${cfg.server} 6667 ${config.krebs.build.host.name}-ssh \
|
${pkgs.irc-announce}/bin/irc-announce \
|
||||||
\${cfg.channel} \
|
${escapeShellArg cfg.server} \
|
||||||
|
${toString cfg.port} \
|
||||||
|
"${config.krebs.build.host.name}-ssh" \
|
||||||
|
${escapeShellArg cfg.channel} \
|
||||||
|
${escapeShellArg cfg.tls} \
|
||||||
"${cfg.message}$(cat ${hiddenServiceDir}/hostname)"
|
"${cfg.message}$(cat ${hiddenServiceDir}/hostname)"
|
||||||
'';
|
'';
|
||||||
PrivateTmp = "true";
|
PrivateTmp = "true";
|
||||||
|
@ -12,6 +12,7 @@ with import <stockholm/lib>;
|
|||||||
, port ? 6667
|
, port ? 6667
|
||||||
, refs ? []
|
, refs ? []
|
||||||
, server
|
, server
|
||||||
|
, tls ? false
|
||||||
, verbose ? false
|
, verbose ? false
|
||||||
}: /* sh */ ''
|
}: /* sh */ ''
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
@ -39,6 +40,7 @@ with import <stockholm/lib>;
|
|||||||
nick=${escapeShellArg nick}
|
nick=${escapeShellArg nick}
|
||||||
channel=${escapeShellArg channel}
|
channel=${escapeShellArg channel}
|
||||||
server=${escapeShellArg server}
|
server=${escapeShellArg server}
|
||||||
|
tls=${escapeShellArg tls}
|
||||||
port=${toString port}
|
port=${toString port}
|
||||||
|
|
||||||
host=$nick
|
host=$nick
|
||||||
@ -114,6 +116,7 @@ with import <stockholm/lib>;
|
|||||||
"$port" \
|
"$port" \
|
||||||
"$nick" \
|
"$nick" \
|
||||||
"$channel" \
|
"$channel" \
|
||||||
|
"tls" \
|
||||||
"$message"
|
"$message"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
@ -17,7 +17,8 @@ pkgs.writeDashBin "irc-announce" ''
|
|||||||
IRC_PORT=$2
|
IRC_PORT=$2
|
||||||
IRC_NICK=$3_$$
|
IRC_NICK=$3_$$
|
||||||
IRC_CHANNEL=$4
|
IRC_CHANNEL=$4
|
||||||
message=$5
|
IRC_TLS=$5
|
||||||
|
message=$6
|
||||||
|
|
||||||
export IRC_CHANNEL # for privmsg_cat
|
export IRC_CHANNEL # for privmsg_cat
|
||||||
|
|
||||||
@ -34,6 +35,8 @@ pkgs.writeDashBin "irc-announce" ''
|
|||||||
# privmsg_cat transforms stdin to a privmsg
|
# privmsg_cat transforms stdin to a privmsg
|
||||||
privmsg_cat() { awk '{ print "PRIVMSG "ENVIRON["IRC_CHANNEL"]" :"$0 }'; }
|
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"
|
# ircin is used to feed the output of netcat back to the "irc client"
|
||||||
# so we can implement expect-like behavior with sed^_^
|
# so we can implement expect-like behavior with sed^_^
|
||||||
# XXX mkselfdestructingtmpfifo would be nice instead of this cruft
|
# XXX mkselfdestructingtmpfifo would be nice instead of this cruft
|
||||||
@ -51,6 +54,8 @@ pkgs.writeDashBin "irc-announce" ''
|
|||||||
echo2 "USER $LOGNAME 0 * :$LOGNAME@$(hostname)"
|
echo2 "USER $LOGNAME 0 * :$LOGNAME@$(hostname)"
|
||||||
echo2 "NICK $IRC_NICK"
|
echo2 "NICK $IRC_NICK"
|
||||||
|
|
||||||
|
awk 'match($0, /PING(.*)/, m) {print "PONG", m[1]; exit}'
|
||||||
|
|
||||||
# wait for MODE message
|
# wait for MODE message
|
||||||
sed -n '/^:[^ ]* MODE /q'
|
sed -n '/^:[^ ]* MODE /q'
|
||||||
|
|
||||||
@ -67,5 +72,5 @@ pkgs.writeDashBin "irc-announce" ''
|
|||||||
|
|
||||||
echo2 'QUIT :Gone to have lunch'
|
echo2 'QUIT :Gone to have lunch'
|
||||||
} < ircin \
|
} < ircin \
|
||||||
| nc "$IRC_SERVER" "$IRC_PORT" | tee -a ircin
|
| nc $(tls_flag) "$IRC_SERVER" "$IRC_PORT" | tee -a ircin
|
||||||
''
|
''
|
||||||
|
Loading…
Reference in New Issue
Block a user