lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


If you really need to limit the amount of input

I can't write a safe (DoS-resistant) line-oriented server
without it, esp.  for SMTP, not least because there are
still SMTP clients which send large emails as one huge
line of text. I want to be able to detect that the amount
of SMTP data has exceeded some user-defined maximum _as it
exceeds_ that maximum, rather than (possily long) after
having already received (possibly much) more than the

With a timeout of zero, you can't read more than what fits
in the LuaSocket input buffer. Should be something like 4k.

Thanks. Is it better to use select() than to use
receive(1) with a timeout followed by receive(bytesleft)
without one? Errr, yes. I think it is. Much clearer,

Yes. Much, better. :) Better yet would be to use something
similar to copas or dispatch.lua. Shouldn't be impossible to
implement the limit of input size on top of that. Though to
be honest I don't have a good idea of how hard it would be.