# HG changeset patch # User Matthew Wild # Date 1368887371 -3600 # Node ID e8a0e545ee05e7d763f11acbdf87235a4ba2554b # Parent f55ab5fa939f9bec08fd51be39b4dd818b9649bc# Parent 34e9f237b915983274bf7a084e771b364ad10055 Merge diff -r f55ab5fa939f -r e8a0e545ee05 plugins/mod_admin_telnet.lua --- a/plugins/mod_admin_telnet.lua Sat May 18 15:29:10 2013 +0100 +++ b/plugins/mod_admin_telnet.lua Sat May 18 15:29:31 2013 +0100 @@ -700,9 +700,9 @@ error("This version of LuaSec does not support certificate viewing"); end else - local certs = conn:getpeerchain(); - local cert = certs[1]; + local cert = conn:getpeercertificate(); if cert then + local certs = conn:getpeerchain(); local digest = cert:digest("sha1"); if not cert_set[digest] then local chain_valid, chain_errors = conn:getpeerverification(); @@ -957,7 +957,9 @@ def_env.user = {}; function def_env.user:create(jid, password) local username, host = jid_split(jid); - if um.user_exists(username, host) then + if not hosts[host] then + return nil, "No such host: "..host; + elseif um.user_exists(username, host) then return nil, "User exists"; end local ok, err = um.create_user(username, password, host); @@ -970,7 +972,9 @@ function def_env.user:delete(jid) local username, host = jid_split(jid); - if not um.user_exists(username, host) then + if not hosts[host] then + return nil, "No such host: "..host; + elseif um.user_exists(username, host) then return nil, "No such user"; end local ok, err = um.delete_user(username, host); @@ -983,7 +987,9 @@ function def_env.user:password(jid, password) local username, host = jid_split(jid); - if not um.user_exists(username, host) then + if not hosts[host] then + return nil, "No such host: "..host; + elseif um.user_exists(username, host) then return nil, "No such user"; end local ok, err = um.set_password(username, password, host); diff -r f55ab5fa939f -r e8a0e545ee05 util/ip.lua --- a/util/ip.lua Sat May 18 15:29:10 2013 +0100 +++ b/util/ip.lua Sat May 18 15:29:31 2013 +0100 @@ -23,6 +23,13 @@ elseif proto ~= "IPv4" and proto ~= "IPv6" then return nil, "invalid protocol"; end + if proto == "IPv6" and ipStr:find('.', 1, true) then + local changed; + ipStr, changed = ipStr:gsub(":(%d+)%.(%d+)%.(%d+)%.(%d+)$", function(a,b,c,d) + return (":%04X:%04X"):format(a*256+b,c*256+d); + end); + if changed ~= 1 then return nil, "invalid-address"; end + end return setmetatable({ addr = ipStr, proto = proto }, ip_mt); end