diff options
author | Kim Alvefur <zash@zash.se> | 2013-05-18 13:20:46 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-05-18 13:20:46 +0200 |
commit | 2794871c57db8605a99583de29df2168181715c2 (patch) | |
tree | 0f2cb51dea138f8394524c68f5cfb3f876c3e20b | |
parent | 651c67dc6b70b1e0fac99e1f864656d335974f69 (diff) | |
parent | aa4b5036e35c1e60d3eba1fc2eeeaf96ae76ab15 (diff) | |
download | prosody-2794871c57db8605a99583de29df2168181715c2.tar.gz prosody-2794871c57db8605a99583de29df2168181715c2.zip |
Merge 0.9->trunk
-rw-r--r-- | plugins/mod_admin_telnet.lua | 16 | ||||
-rw-r--r-- | util/ip.lua | 7 |
2 files changed, 18 insertions, 5 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua index 2056f1e2..1fd20543 100644 --- a/plugins/mod_admin_telnet.lua +++ b/plugins/mod_admin_telnet.lua @@ -700,9 +700,9 @@ function def_env.s2s:showcert(domain) 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 @@ local um = require"core.usermanager"; 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 @@ end 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 @@ end 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 --git a/util/ip.lua b/util/ip.lua index 6ebc023b..20ea3dd7 100644 --- a/util/ip.lua +++ b/util/ip.lua @@ -23,6 +23,13 @@ local function new_ip(ipStr, proto) 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 |