Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
2236:cf7192f48c56 | 2237:63fc3cb50dc8 |
---|---|
372 return self.addr | 372 return self.addr |
373 end | 373 end |
374 | 374 |
375 function interface_mt:set_sslctx(sslctx) | 375 function interface_mt:set_sslctx(sslctx) |
376 self._sslctx = sslctx; | 376 self._sslctx = sslctx; |
377 if sslctx then | |
378 self.starttls = nil; -- use starttls() of interface_mt | |
379 else | |
380 self.starttls = false; -- prevent starttls() | |
381 end | |
382 end | |
377 end | 383 end |
378 | 384 |
379 function interface_mt:starttls() | 385 function interface_mt:starttls() |
380 debug( "try to start ssl at client id:", self.id ) | 386 debug( "try to start ssl at client id:", self.id ) |
381 local err | 387 local err |
456 -- Properties | 462 -- Properties |
457 _ip = ip, _port = port, _server = server, _pattern = pattern, | 463 _ip = ip, _port = port, _server = server, _pattern = pattern, |
458 _sslctx = sslctx; -- parameters | 464 _sslctx = sslctx; -- parameters |
459 _usingssl = false; -- client is using ssl; | 465 _usingssl = false; -- client is using ssl; |
460 } | 466 } |
467 if not sslctx then | |
468 interface.starttls = false -- don't allow TLS | |
469 end | |
461 interface.id = tostring(interface):match("%x+$"); | 470 interface.id = tostring(interface):match("%x+$"); |
462 interface.writecallback = function( event ) -- called on write events | 471 interface.writecallback = function( event ) -- called on write events |
463 --vdebug( "new client write event, id/ip/port:", interface, ip, port ) | 472 --vdebug( "new client write event, id/ip/port:", interface, ip, port ) |
464 if interface.nowriting or ( interface.fatalerror and ( "client to close" ~= interface.fatalerror ) ) then -- leave this event | 473 if interface.nowriting or ( interface.fatalerror and ( "client to close" ~= interface.fatalerror ) ) then -- leave this event |
465 --vdebug( "leaving this event because:", interface.nowriting or interface.fatalerror ) | 474 --vdebug( "leaving this event because:", interface.nowriting or interface.fatalerror ) |