Software /
code /
prosody
Comparison
net/server.lua @ 564:779ab5b99e13
Don't say we need TLS after we've already started the handshake
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 05 Dec 2008 19:40:46 +0000 |
parent | 563:099d8a102deb |
child | 566:c83166927835 |
comparison
equal
deleted
inserted
replaced
563:099d8a102deb | 564:779ab5b99e13 |
---|---|
468 eol = nil | 468 eol = nil |
469 writelen = removesocket( writelist, socket, writelen ) -- delete socket from writelist | 469 writelen = removesocket( writelist, socket, writelen ) -- delete socket from writelist |
470 if handler.need_tls then | 470 if handler.need_tls then |
471 out_put("server.lua: connection is ready for tls handshake"); | 471 out_put("server.lua: connection is ready for tls handshake"); |
472 handler.starttls(true); | 472 handler.starttls(true); |
473 if handler.need_tls then | |
474 out_put("server.lua: uh-oh... we still want tls, something must be wrong"); | |
475 end | |
476 end | 473 end |
477 return true | 474 return true |
478 elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write | 475 elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write |
479 buffer = string_sub( buffer, byte + 1, -1 ) -- new buffer | 476 buffer = string_sub( buffer, byte + 1, -1 ) -- new buffer |
480 writequeue[ 1 ] = buffer -- insert new buffer in queue | 477 writequeue[ 1 ] = buffer -- insert new buffer in queue |
534 handler.receive = function( pattern, prefix ) | 531 handler.receive = function( pattern, prefix ) |
535 return receive( socket, pattern, prefix ) | 532 return receive( socket, pattern, prefix ) |
536 end | 533 end |
537 | 534 |
538 handler.starttls = nil; | 535 handler.starttls = nil; |
536 handler.need_tls = nil | |
539 | 537 |
540 handler.handshake = coroutine_wrap( function( client ) | 538 handler.handshake = coroutine_wrap( function( client ) |
541 local err | 539 local err |
542 for i = 1, 10 do -- 10 handshake attemps | 540 for i = 1, 10 do -- 10 handshake attemps |
543 _, err = client:dohandshake( ) | 541 _, err = client:dohandshake( ) |
544 if not err then | 542 if not err then |
545 out_put( "server.lua: ssl handshake done" ) | 543 out_put( "server.lua: ssl handshake done" ) |
546 writelen = ( wrote and removesocket( writelist, socket, writelen ) ) or writelen | 544 writelen = ( wrote and removesocket( writelist, socket, writelen ) ) or writelen |
547 handler.receivedata = handler._receivedata -- when handshake is done, replace the handshake function with regular functions | 545 handler.receivedata = handler._receivedata -- when handshake is done, replace the handshake function with regular functions |
548 handler.dispatchdata = handler._dispatchdata | 546 handler.dispatchdata = handler._dispatchdata |
549 handler.need_tls = nil | |
550 return true; | 547 return true; |
551 else | 548 else |
552 out_put( "server.lua: error during ssl handshake: ", err ) | 549 out_put( "server.lua: error during ssl handshake: ", err ) |
553 if err == "wantwrite" then | 550 if err == "wantwrite" then |
554 if wrote == nil then | 551 if wrote == nil then |