Software /
code /
prosody
Comparison
net/server_event.lua @ 4907:32b638a8da5b
net.server_event: Internal changes to get plain-SSL outgoing connections working (as for HTTPS)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 24 May 2012 03:33:14 +0100 |
parent | 4905:274ef78aa173 |
child | 4962:1d8fb12a9b2d |
comparison
equal
deleted
inserted
replaced
4906:89df1f03546a | 4907:32b638a8da5b |
---|---|
141 self:ontimeout() -- call timeout listener | 141 self:ontimeout() -- call timeout listener |
142 self:_close() | 142 self:_close() |
143 debug( "new connection failed. id:", self.id, "error:", self.fatalerror ) | 143 debug( "new connection failed. id:", self.id, "error:", self.fatalerror ) |
144 else | 144 else |
145 if plainssl and ssl then -- start ssl session | 145 if plainssl and ssl then -- start ssl session |
146 self:starttls(nil, true) | 146 self:starttls(self._sslctx, true) |
147 else -- normal connection | 147 else -- normal connection |
148 self:_start_session(true) | 148 self:_start_session(true) |
149 end | 149 end |
150 debug( "new connection established. id:", self.id ) | 150 debug( "new connection established. id:", self.id ) |
151 end | 151 end |
471 local string_len = string.len | 471 local string_len = string.len |
472 local addevent = base.addevent | 472 local addevent = base.addevent |
473 local coroutine_wrap = coroutine.wrap | 473 local coroutine_wrap = coroutine.wrap |
474 local socket_gettime = socket.gettime | 474 local socket_gettime = socket.gettime |
475 local coroutine_yield = coroutine.yield | 475 local coroutine_yield = coroutine.yield |
476 function handleclient( client, ip, port, server, pattern, listener, _, sslctx ) -- creates an client interface | 476 function handleclient( client, ip, port, server, pattern, listener, sslctx ) -- creates an client interface |
477 --vdebug("creating client interfacce...") | 477 --vdebug("creating client interfacce...") |
478 local interface = { | 478 local interface = { |
479 type = "client"; | 479 type = "client"; |
480 conn = client; | 480 conn = client; |
481 currenttime = socket_gettime( ); -- safe the origin | 481 currenttime = socket_gettime( ); -- safe the origin |
690 debug( "maximal connections reached, refuse client connection; accept delay:", delay ) | 690 debug( "maximal connections reached, refuse client connection; accept delay:", delay ) |
691 return EV_TIMEOUT, delay -- delay for next accept attempt | 691 return EV_TIMEOUT, delay -- delay for next accept attempt |
692 end | 692 end |
693 local client_ip, client_port = client:getpeername( ) | 693 local client_ip, client_port = client:getpeername( ) |
694 interface._connections = interface._connections + 1 -- increase connection count | 694 interface._connections = interface._connections + 1 -- increase connection count |
695 local clientinterface = handleclient( client, client_ip, client_port, interface, pattern, listener, nil, sslctx ) | 695 local clientinterface = handleclient( client, client_ip, client_port, interface, pattern, listener, sslctx ) |
696 --vdebug( "client id:", clientinterface, "startssl:", startssl ) | 696 --vdebug( "client id:", clientinterface, "startssl:", startssl ) |
697 if ssl and sslctx then | 697 if ssl and sslctx then |
698 clientinterface:starttls(sslctx, true) | 698 clientinterface:starttls(sslctx, true) |
699 else | 699 else |
700 clientinterface:_start_session( true ) | 700 clientinterface:_start_session( true ) |