From f48a01a202ab0fc6cea71dcc3569d4b99d657b98 Mon Sep 17 00:00:00 2001 From: ron42 <51223319+ron42@users.noreply.github.com> Date: Fri, 24 Jul 2020 13:33:07 +0530 Subject: [PATCH 1/2] Fix handling of multiple SRV records for a single domain --- echoz.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/echoz.sh b/echoz.sh index 8744717..4631789 100755 --- a/echoz.sh +++ b/echoz.sh @@ -6,8 +6,8 @@ jid="$1" password="$2" username="$(echo "$jid" | sed 's/@.*//')" domain="$(echo "$jid" | sed 's/.*@//')" -srv="$( ( dig +short SRV "_xmpp-client._tcp.$domain" | grep . || echo "0 0 5222 $domain" ) | sort -n | sed 's/[[:digit:]]\+[[:space:]][[:digit:]]\+[[:space:]]//')" -host="$(echo "$srv" | sed 's/[[:digit:]]\+[[:space:]]//')" +srv="$( ( dig +short SRV "_xmpp-client._tcp.$domain" | grep . || echo "0 0 5222 $domain" ) | sort -n | sed -n '1s/[[:digit:]]\+[[:space:]][[:digit:]]\+[[:space:]]//p')" +host="$(echo "$srv" | sed 's/[[:digit:]]\+[[:space:]]//' | sed 's/\.$//')" port="$(echo "$srv" | sed 's/[[:space:]].*//')" authstr="$(printf '\0%s\0%s' "$username" "$password" | base64)" rm -f "$pipename" From afa98984d261c936f0e3d2097a5bd522f6b54ead Mon Sep 17 00:00:00 2001 From: ron42 <51223319+ron42@users.noreply.github.com> Date: Sat, 25 Jul 2020 09:47:29 +0530 Subject: [PATCH 2/2] Handle $host in a single sed call --- echoz.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/echoz.sh b/echoz.sh index 4631789..da0512a 100755 --- a/echoz.sh +++ b/echoz.sh @@ -7,7 +7,7 @@ password="$2" username="$(echo "$jid" | sed 's/@.*//')" domain="$(echo "$jid" | sed 's/.*@//')" srv="$( ( dig +short SRV "_xmpp-client._tcp.$domain" | grep . || echo "0 0 5222 $domain" ) | sort -n | sed -n '1s/[[:digit:]]\+[[:space:]][[:digit:]]\+[[:space:]]//p')" -host="$(echo "$srv" | sed 's/[[:digit:]]\+[[:space:]]//' | sed 's/\.$//')" +host="$(echo "$srv" | sed 's/[[:digit:]]\+[[:space:]]//;s/\.$//')" port="$(echo "$srv" | sed 's/[[:space:]].*//')" authstr="$(printf '\0%s\0%s' "$username" "$password" | base64)" rm -f "$pipename"