Diff

net/server_event.lua @ 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
parent 2236:cf7192f48c56
child 2238:0a6375e9b2e2
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 )