Changeset

2237:63fc3cb50dc8

net.server_event: Hide starttls function when the connection is not SSL-enabled
author Matthew Wild <mwild1@gmail.com>
date Thu, 26 Nov 2009 22:21:12 +0000
parents 2236:cf7192f48c56
children 2238:0a6375e9b2e2
files net/server_event.lua
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_event.lua	Thu Nov 26 22:19:49 2009 +0000
+++ b/net/server_event.lua	Thu Nov 26 22:21:12 2009 +0000
@@ -374,6 +374,12 @@
 	
 	function interface_mt:set_sslctx(sslctx)
 		self._sslctx = sslctx;
+		if sslctx then
+			self.starttls = nil; -- use starttls() of interface_mt
+		else
+			self.starttls = false; -- prevent starttls()
+		end
+	end
 	end
 	
 	function interface_mt:starttls()
@@ -458,6 +464,9 @@
 			_sslctx = sslctx; -- parameters
 			_usingssl = false;  -- client is using ssl;
 		}
+		if not sslctx then
+			interface.starttls = false -- don't allow TLS
+		end
 		interface.id = tostring(interface):match("%x+$");
 		interface.writecallback = function( event )  -- called on write events
 			--vdebug( "new client write event, id/ip/port:", interface, ip, port )