Software /
code /
prosody
Comparison
net/server.lua @ 566:c83166927835
Merge
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 05 Dec 2008 19:50:34 +0000 |
parent | 564:779ab5b99e13 |
parent | 565:3a49d85cafbc |
child | 567:ae7f6167d780 |
comparison
equal
deleted
inserted
replaced
564:779ab5b99e13 | 566:c83166927835 |
---|---|
499 local wrote, read | 499 local wrote, read |
500 | 500 |
501 handler.starttls = function (now) | 501 handler.starttls = function (now) |
502 if not now then out_put("server.lua: we need to do tls, but delaying until later"); handler.need_tls = true; return; end | 502 if not now then out_put("server.lua: we need to do tls, but delaying until later"); handler.need_tls = true; return; end |
503 out_put( "server.lua: attempting to start tls on "..tostring(socket) ) | 503 out_put( "server.lua: attempting to start tls on "..tostring(socket) ) |
504 local oldsocket = socket; | |
505 socket, err = ssl_wrap( socket, sslctx ) -- wrap socket | 504 socket, err = ssl_wrap( socket, sslctx ) -- wrap socket |
506 out_put("sslwrapped socket is "..tostring(socket)); | 505 out_put("sslwrapped socket is "..tostring(socket)); |
507 if err then | 506 if err then |
508 out_put( "server.lua: ssl error: ", err ) | 507 out_put( "server.lua: ssl error: ", err ) |
509 return nil, nil, err -- fatal error | 508 return nil, nil, err -- fatal error |
510 end | 509 end |
511 socket:settimeout(0); | 510 socket:settimeout( 1 ) |
512 | |
513 -- Add the new socket to our system | |
514 socketlist[ socket ] = handler | |
515 readlen = readlen + 1 | |
516 readlist[ readlen ] = socket | |
517 | |
518 -- Remove traces of the old socket | |
519 readlen = removesocket( readlist, oldsocket, readlen ) | |
520 socketlist [ oldsocket ] = nil; | |
521 | |
522 send = socket.send | 511 send = socket.send |
523 receive = socket.receive | 512 receive = socket.receive |
524 close = socket.close | 513 close = socket.close |
525 handler.ssl = function( ) | 514 handler.ssl = function( ) |
526 return true | 515 return true |
541 _, err = client:dohandshake( ) | 530 _, err = client:dohandshake( ) |
542 if not err then | 531 if not err then |
543 out_put( "server.lua: ssl handshake done" ) | 532 out_put( "server.lua: ssl handshake done" ) |
544 writelen = ( wrote and removesocket( writelist, socket, writelen ) ) or writelen | 533 writelen = ( wrote and removesocket( writelist, socket, writelen ) ) or writelen |
545 handler.receivedata = handler._receivedata -- when handshake is done, replace the handshake function with regular functions | 534 handler.receivedata = handler._receivedata -- when handshake is done, replace the handshake function with regular functions |
546 handler.dispatchdata = handler._dispatchdata | 535 handler.dispatchdata = handler._dispatchdata; |
547 return true; | 536 return true; |
548 else | 537 else |
549 out_put( "server.lua: error during ssl handshake: ", err ) | 538 out_put( "server.lua: error during ssl handshake: ", err ) |
550 if err == "wantwrite" then | 539 if err == "wantwrite" then |
551 if wrote == nil then | 540 if wrote == nil then |