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