Changeset

166:b0c586241224

clix: Support SCRAM hashes stored as hex in config
author Kim Alvefur <zash@zash.se>
date Wed, 03 Aug 2022 03:02:12 +0200
parents 165:e4391832be1e
children 167:57bb6e03d239
files clix.lua
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/clix.lua	Wed Aug 03 03:01:26 2022 +0200
+++ b/clix.lua	Wed Aug 03 03:02:12 2022 +0200
@@ -111,12 +111,22 @@
 	conn.connect_host = account.address;
 	conn.connect_port = account.port;
 
-	if not account.password and opts.interactive then
+	if not account.password and not (account.clientkey and account.serverkey) and opts.interactive then
 		account.password = read_password()
 	end
+
+	local clientkey, serverkey = account.clientkey, account.serverkey;
+	if clientkey and serverkey then
+		local hex = require "util.hex";
+		clientkey = hex.from(clientkey);
+		serverkey = hex.from(serverkey);
+	elseif clientkey or serverkey then
+		conn:warn("Only one of 'clientkey' and 'serverkey' available, both reqired for SCRAM")
+		clientkey, serverkey = nil, nil;
+	end
 	
 	-- Connect!
-	conn:connect_client(account.jid, account.password);
+	conn:connect_client(account.jid, account.password, clientkey, serverkey);
 	
 	-- COMPAT: Tigase discards stanzas sent at the same time as </stream:stream>
 	local _real_close = conn.close;