Kim Alvefur
577c21a269
net.server_epoll: Process all queued events from epoll before timers
...
Should call timers less frequently when many sockets are waiting for
processing. May help under heavy load.
Requested by Ge0rG
Backport of 2bcd84123eba requested by Roi
2021-10-21 15:59:16 +02:00
Kim Alvefur
24111569bb
net.server_epoll: Add a hard deadline on shutdown to extra-fix #1670
...
Should ensure shutdown even if sockets somehow take a very long to get closed.
2021-09-20 14:38:08 +02:00
Kim Alvefur
6d5ff6d2be
net.server_epoll: Close sockets added after shutdown signal ( fixes #1670 )
...
This should ensure that sockets get closed even if they are added after
the quit signal. Otherwise they may keep the server alive.
2021-09-20 14:42:18 +02:00
Kim Alvefur
6be7cf935f
net.server_epoll: Fix to preserve ids of readded timers
...
Likely affected rescheduling but have no reports of this.
After readding a timer, it would have been issued a new id. Rescheduling
would use the previous id, thus not working.
2021-08-31 12:58:38 +02:00
Kim Alvefur
f36531b53a
net.adns: Prevent empty packets from being sent on "connect" ( fix #1619 )
...
Thanks Ge0rG for testing
2021-01-12 13:25:08 +01:00
Kim Alvefur
5cf3eea245
net.server_epoll: Fix off-by-one in 2c559953ad41
...
Thanks tmolitor
2021-01-10 14:54:03 +01:00
Kim Alvefur
861e5125c7
net.server_epoll: Ensure timers can't run more than once per tick
...
This makes sure that a timer that returns 0 (or less) does not prevent
runtimers() from completing, as well as making sure a timer added with
zero timeout from within a timer does not run until the next tick.
Thanks tmolitor
2021-01-08 21:57:19 +01:00
Kim Alvefur
00bad1a9fe
net.websocket.frames: Use C string XOR implementation
2020-10-14 19:41:42 +02:00
Matthew Wild
518904b66c
net.http.server: Don't send Content-Length on 1xx/204 responses, per RFC ( fixes #1596 )
2020-10-13 11:55:28 +01:00
Kim Alvefur
fb63187afc
net.websocket.frames: Read buffer length correctly in Lua 5.1 ( fix #1598 )
...
COMPAT: The __len metamethod does not work with tables in Lua 5.1.
Both strings and util.dbuffer now expose their length as a :len()
method.
2020-10-12 20:21:18 +02:00
Matthew Wild
a0fb8d876f
net.websocket.frames: Additionally return partial frame if there is one
2020-09-29 13:58:32 +01:00
Matthew Wild
5a1c206ece
mod_websocket: Switch partial frame buffering to util.dbuffer
...
This improves performance and enforces stanza size limits earlier
in the pipeline.
2020-09-17 13:04:46 +01:00
Matthew Wild
3989ff2ddc
net.websocket.frames: Allow all methods to work on non-string objects
...
Instead of using the string library, use methods from the passed object,
which are assumed to be equivalent.
This provides compatibility with objects from util.ringbuffer and
util.dbuffer, for example.
2020-09-17 13:00:19 +01:00
Matthew Wild
047f03ec09
net.http: Add feature discovery (currently just contains SNI)
2020-09-15 09:08:21 +01:00
Kim Alvefur
93d0d13fbb
net.server: Backport client parts of SNI support from trunk ( #409 )
...
Partial backports of the following commits from trunk:
6c804b6b2ca2 net.http: Pass server name along for SNI (fixes #1408 )
75d2874502c3 net.server_select: SNI support (#409 )
9a905888b96c net.server_event: Add SNI support (#409 )
adc0672b700e net.server_epoll: Add support for SNI (#409 )
d4390c427a66 net.server: Handle server name (SNI) as extra argument
2020-08-17 23:01:14 +02:00
Matthew Wild
dc206f0ff4
net.http: Add request:cancel() method
...
This is a new API that should be used in preference to http.destroy_request()
when possible, as it ensures the callback is always called (with an error of
course).
APIs that have edge-cases where they don't call callbacks have, from experience,
shown to be difficult to work with and often lead to unintentional leaks when
the callback was expected to free up certain resources.
2020-08-08 13:13:50 +01:00
Matthew Wild
11e49af5e8
net.http: Re-expose destroy_request() function
...
This was accidentally turned private in 647adfd8f738 as part of refactoring
for Lua 5.2+.
2020-08-08 13:11:11 +01:00
Matthew Wild
a80cdecc46
net.resolvers.basic: Default conn_type to 'tcp' consistently if unspecified (thanks marc0s)
...
Fixes a traceback when passed an IP address with no conn_type.
2020-07-10 13:00:02 +01:00
Matthew Wild
bfd9789cb1
net.http: Fix traceback on invalid URL passed to request()
2020-07-07 13:52:25 +01:00
Kim Alvefur
540be50a3c
net.http.server: Fix reporting of missing Host header
...
The "Missing or invalid 'Host' header" case was dead code previously
because `host` was always at least an empty string.
2020-06-23 15:43:57 +02:00
Kim Alvefur
48c9a60d19
net.http.server: Strip port from Host header in IPv6 friendly way ( fix #1302 )
...
E.g. given `[::1]:5280` it would previously result in only `[` instead
of the correct `[::1]`
2020-06-23 15:39:31 +02:00
Kim Alvefur
e59b70638c
net.server_epoll: Fix indentation
...
Some lines seem to have gotten the wrong indentation, possibly caused by
Meld which often ignores lines with only whitespace changes and leaves
their previous indentation.
2020-03-11 18:07:03 +01:00
Kim Alvefur
c3581958f7
net.resolvers.basic: Normalise IP literals, ensures net.server is happy
2019-11-24 04:41:07 +01:00
Kim Alvefur
9c9722935a
net.resolvers.basic: Fix resolution of IPv6 literals (in brackets) ( fixes #1459 )
2019-11-24 04:26:44 +01:00
Kim Alvefur
7c056be161
net.resolvers.basic: Move IP literal check to constructor
...
This is to prepare for fixing #1459 . An IPv6 literal in [ ] brackets
does not pass IDNA and resolving it fails there.
2019-11-24 04:23:51 +01:00
Kim Alvefur
2a8b031b75
net.resolvers: Fix traceback from hostname failing IDNA
...
Related to #1426
2019-11-08 00:54:56 +01:00
Kim Alvefur
9c2a74d09c
net.resolvers: Abort on hostnames not passing IDNA validation
...
Prevents error on trying to use nil.
Needs better error reporting in the future.
2019-11-02 19:36:19 +01:00
Kim Alvefur
ba431b5efc
net.resolvers: Apply IDNA conversion to ascii for DNS lookups ( fixes #1426 )
2019-11-02 19:24:26 +01:00
Kim Alvefur
70e3e96c02
net.server_epoll: Backport timer optimization 6c2370f17027 from trunk (see #1388 )
...
The previous timer handling did not scale well and led to high CPU usage
with many connections (each with at least an read timeout).
2019-07-08 01:17:34 +02:00
Kim Alvefur
d2d042186f
net.server_epoll: Restore wantread flag after pause ( fixes #1354 )
...
If a chunk of data has been received that is larger than the amount read
at a time, then the connection is paused for a short time after which it
tries to read some more. If, after that, there is still more data to
read, it should do the same thing. However, because the "want read" flag
is removed and was restored after the delayed reading, it would not
schedule another delayed read.
2019-05-04 04:23:35 +02:00
Kim Alvefur
94880142e9
net.dns: Close resolv.conf handle when done ( fixes #1342 )
2019-04-13 18:16:28 +02:00
Kim Alvefur
c422e8f134
net.server_epoll: Skip delayed continuation read on paused connections
...
This should prevent #1333 in cases where LuaSockets buffer is "dirty",
i.e. contains more data after a read, where it gets resumed with a
short delay.
2019-03-28 12:52:55 +01:00
Kim Alvefur
e34e8e845d
net.server_epoll: Handle LuaSec wantread/wantwrite conditions before callbacks ( fixes #1333 )
...
This prevents the :set(true) call from resuming a connection that was
paused in the onincoming callback.
2019-03-28 12:31:14 +01:00
Kim Alvefur
66d2e6adc3
net.server_epoll: Rename handshake_timeout to ssl_handshake_timeout ( fixes #1319 )
...
This is to match server_event, see 430797a8fc81
2019-02-09 19:28:24 +01:00
Kim Alvefur
8732027944
net.server_epoll: Use send_timeout for write timout like other implementations ( fixes #1316 )
2019-02-07 14:02:15 +01:00
Kim Alvefur
6176e9ff1b
server_epoll: Add comments describing config options
2018-11-30 19:40:39 +01:00
Kim Alvefur
448257af39
net.server_epoll: Remove unused config option
2018-11-30 18:23:43 +01:00
Kim Alvefur
160fd37742
server_epoll: Increase write timeout
...
7 may be too low for some slow machines and/or networks
2018-11-30 18:11:36 +01:00
Kim Alvefur
589010b407
net.server_select: Fix IP validation to use correct variable (thanks quest)
...
Copy-paste mistake most likely. Not caught because server_select is ignored by luacheck.
2018-11-17 16:26:40 +01:00
Matthew Wild
8ebaee9c3d
net.http.server: Move event formation to avoid traceback on missing Host header
2018-11-13 15:03:24 +00:00
Kim Alvefur
8226d6de4c
net.http: Manually merge settings ( fixes #1231 )
...
Metatable table indexing is done raw, so metatables can't be chained
2018-11-09 15:59:32 +01:00
Kim Alvefur
84c8383fb6
net.server_epoll: Shuffle variables earlier to improve readability
2018-10-27 20:44:53 +02:00
Matthew Wild
f5f6460b2e
Many things: switch from hacky multi-arg xpcall implementations to a standard util.xpcall
2018-10-26 19:32:00 +01:00
Kim Alvefur
2bb3772374
net.server_epoll: Special handling of signal interrupts
2018-10-12 03:22:09 +02:00
Kim Alvefur
afeb1f6f02
net.server_epoll: Ignore ENOENT when deregitering socket
...
It should not really happen
2018-10-12 03:21:11 +02:00
Kim Alvefur
bbf669b2c5
net.server_epoll: Graceful handling of registering already added socket
2018-10-12 03:20:09 +02:00
Kim Alvefur
0ac9ea3a74
net.server: Swich method for connecting sockets with remotes
...
LuaSocket TCP sockets have have both :connect and :setpeername, which
are the exact same function, however UDP sockets only have :setpeername.
Switching to :setpeername allows most of this code to be generic wrt
TCP/UDP.
2018-10-12 17:36:34 +02:00
Kim Alvefur
e1aa03deaa
net.server_epoll: Check return conditions of early socket setup
2018-10-12 17:28:08 +02:00
Kim Alvefur
f2d9638627
net.server_epoll: Add support for the conn_type argument to addclient
2018-10-12 16:26:19 +02:00
Kim Alvefur
83e1a2af50
net.resolvers.basic: Suffix IPv4 TCP socket types with '4' to match eg 'tcp6'
2018-10-12 16:25:30 +02:00