Software /
code /
prosody
Comparison
net/server.lua @ 1884:6eaa440bc9fc
net.server: Increase SSL handshake round-trip limit, and make it configurable
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 04 Oct 2009 16:03:53 +0100 |
parent | 1883:6866cf298701 |
child | 1885:1fde15a415e6 |
comparison
equal
deleted
inserted
replaced
1883:6866cf298701 | 1884:6eaa440bc9fc |
---|---|
155 | 155 |
156 _cleanqueue = false -- clean bufferqueue after using | 156 _cleanqueue = false -- clean bufferqueue after using |
157 | 157 |
158 _maxclientsperserver = 1000 | 158 _maxclientsperserver = 1000 |
159 | 159 |
160 _maxsslhandshake = 30 -- max handshake round-trips | |
160 ----------------------------------// PRIVATE //-- | 161 ----------------------------------// PRIVATE //-- |
161 | 162 |
162 wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx, maxconnections, startssl ) -- this function wraps a server | 163 wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx, maxconnections, startssl ) -- this function wraps a server |
163 | 164 |
164 maxconnections = maxconnections or _maxclientsperserver | 165 maxconnections = maxconnections or _maxclientsperserver |
532 ssl = true | 533 ssl = true |
533 local wrote | 534 local wrote |
534 local read | 535 local read |
535 local handshake = coroutine_wrap( function( client ) -- create handshake coroutine | 536 local handshake = coroutine_wrap( function( client ) -- create handshake coroutine |
536 local err | 537 local err |
537 for i = 1, 10 do -- 10 handshake attemps | 538 for i = 1, _maxsslhandshake do |
538 _sendlistlen = ( wrote and removesocket( _sendlist, socket, _sendlistlen ) ) or _sendlistlen | 539 _sendlistlen = ( wrote and removesocket( _sendlist, socket, _sendlistlen ) ) or _sendlistlen |
539 _readlistlen = ( read and removesocket( _readlist, socket, _readlistlen ) ) or _readlistlen | 540 _readlistlen = ( read and removesocket( _readlist, socket, _readlistlen ) ) or _readlistlen |
540 read, wrote = nil, nil | 541 read, wrote = nil, nil |
541 _, err = client:dohandshake( ) | 542 _, err = client:dohandshake( ) |
542 if not err then | 543 if not err then |
749 _socketlist = { } | 750 _socketlist = { } |
750 --mem_free( ) | 751 --mem_free( ) |
751 end | 752 end |
752 | 753 |
753 getsettings = function( ) | 754 getsettings = function( ) |
754 return _selecttimeout, _sleeptime, _maxsendlen, _maxreadlen, _checkinterval, _sendtimeout, _readtimeout, _cleanqueue, _maxclientsperserver | 755 return _selecttimeout, _sleeptime, _maxsendlen, _maxreadlen, _checkinterval, _sendtimeout, _readtimeout, _cleanqueue, _maxclientsperserver, _maxsslhandshake |
755 end | 756 end |
756 | 757 |
757 changesettings = function( new ) | 758 changesettings = function( new ) |
758 if type( new ) ~= "table" then | 759 if type( new ) ~= "table" then |
759 return nil, "invalid settings table" | 760 return nil, "invalid settings table" |
765 _checkinterval = tonumber( new.checkinterval ) or _checkinterval | 766 _checkinterval = tonumber( new.checkinterval ) or _checkinterval |
766 _sendtimeout = tonumber( new.sendtimeout ) or _sendtimeout | 767 _sendtimeout = tonumber( new.sendtimeout ) or _sendtimeout |
767 _readtimeout = tonumber( new.readtimeout ) or _readtimeout | 768 _readtimeout = tonumber( new.readtimeout ) or _readtimeout |
768 _cleanqueue = new.cleanqueue | 769 _cleanqueue = new.cleanqueue |
769 _maxclientsperserver = new._maxclientsperserver or _maxclientsperserver | 770 _maxclientsperserver = new._maxclientsperserver or _maxclientsperserver |
771 _maxsslhandshake = new._maxsslhandshake or _maxsslhandshake | |
770 return true | 772 return true |
771 end | 773 end |
772 | 774 |
773 addtimer = function( listener ) | 775 addtimer = function( listener ) |
774 if type( listener ) ~= "function" then | 776 if type( listener ) ~= "function" then |