diff options
author | Kim Alvefur <zash@zash.se> | 2022-06-03 17:51:42 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2022-06-03 17:51:42 +0200 |
commit | 88a2c1ffe029818288cc86afd48d791f2b86f5ad (patch) | |
tree | 41c0e2395e8121532ffbd877ead8724236a094ed | |
parent | 2048a7a762e619974557c4015429626443835b4c (diff) | |
download | prosody-88a2c1ffe029818288cc86afd48d791f2b86f5ad.tar.gz prosody-88a2c1ffe029818288cc86afd48d791f2b86f5ad.zip |
net.server: Fix multiple return values
return foo and foo() crops multiple return values to a single one, so
any second return values etc were last, mostly error details.
Introduced in 7e9ebdc75ce4
-rw-r--r-- | net/server_epoll.lua | 12 | ||||
-rw-r--r-- | net/server_event.lua | 16 | ||||
-rw-r--r-- | net/server_select.lua | 9 |
3 files changed, 26 insertions, 11 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index d0ca3125..a546e1e3 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -627,22 +627,26 @@ end function interface:ssl_info() local sock = self.conn; - return sock.info and sock:info(); + if not sock.info then return nil, "not-implemented"; end + return sock:info(); end function interface:ssl_peercertificate() local sock = self.conn; - return sock.getpeercertificate and sock:getpeercertificate(); + if not sock.getpeercertificate then return nil, "not-implemented"; end + return sock:getpeercertificate(); end function interface:ssl_peerverification() local sock = self.conn; - return sock.getpeerverification and sock:getpeerverification(); + if not sock.getpeerverification then return nil, { { "Chain verification not supported" } }; end + return sock:getpeerverification(); end function interface:ssl_peerfinished() local sock = self.conn; - return sock.getpeerfinished and sock:getpeerfinished(); + if not sock.getpeerfinished then return nil, "not-implemented"; end + return sock:getpeerfinished(); end function interface:starttls(tls_ctx) diff --git a/net/server_event.lua b/net/server_event.lua index 313ba981..d8f08c8d 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -281,19 +281,27 @@ function interface_mt:sslctx() end function interface_mt:ssl_info() - return self.conn.info and self.conn:info() + local sock = self.conn; + if not sock.info then return nil, "not-implemented"; end + return sock:info(); end function interface_mt:ssl_peercertificate() - return self.conn.getpeercertificate and self.conn:getpeercertificate() + local sock = self.conn; + if not sock.getpeercertificate then return nil, "not-implemented"; end + return sock:getpeercertificate(); end function interface_mt:ssl_peerverification() - return self.conn.getpeerverification and self.conn:getpeerverification() + local sock = self.conn; + if not sock.getpeerverification then return nil, { { "Chain verification not supported" } }; end + return sock:getpeerverification(); end function interface_mt:ssl_peerfinished() - return self.conn.getpeerfinished and self.conn:getpeerfinished() + local sock = self.conn; + if not sock.getpeerfinished then return nil, "not-implemented"; end + return sock:getpeerfinished(); end function interface_mt:resume() diff --git a/net/server_select.lua b/net/server_select.lua index 80f5f590..651bdfde 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -363,13 +363,16 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport return socket.info and socket:info() end handler.ssl_peercertificate = function( ) - return socket.getpeercertificate and socket:getpeercertificate() + if not socket.getpeercertificate then return nil, "not-implemented"; end + return socket:getpeercertificate() end handler.ssl_peerverification = function( ) - return socket.getpeerverification and socket:getpeerverification() + if not socket.getpeerverification then return nil, { { "Chain verification not supported" } }; end + return socket:getpeerverification(); end handler.ssl_peerfinished = function( ) - return socket.getpeerfinished and socket:getpeerfinished() + if not socket.getpeerfinished then return nil, "not-implemented"; end + return socket:getpeerfinished(); end handler.send = function( _, data, i, j ) return send( socket, data, i, j ) |