главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorron42 <51223319+ron42@users.noreply.github.com>2020-07-24 13:33:07 +0530
committerron42 <51223319+ron42@users.noreply.github.com>2020-07-24 13:33:07 +0530
commitf48a01a202ab0fc6cea71dcc3569d4b99d657b98 (patch)
treec2fa8372a273268e8ae93aa698bd90a4472ff009
parent4648d3cd247e89c83829e38009a352f94b0b672d (diff)
Fix handling of multiple SRV records for a single domain
-rwxr-xr-xechoz.sh4
1 files 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"