Ncat-Lua/TODO

From SecWiki
Jump to: navigation, search

Socket abstractions

  • Rename all lua_ to ncat_lua to avoid name collisions.
    • Extra points if it's done as a clever Perl one-liner. :>
  • local make_function = function(), to get rid of the ugly function_self thing.
  • ret[m] = function(self, ...) return table.unpack({self.super[m](self.super, ...)}) end
    • return self.super[m](self.super, ...)
    • perhaps just copy the parent's function? explore it.
  • Look into ways of making recv() call self.super:recv() only once, not running send() (and send() not running recv() until it gets figured out).
  • Add way more comments into the coroutine code.
  • Add some error handling for nil returned by the socket methods.
  • What happens if we call recv() inside of recv()?
    • Idea for a solution: set a flag before calling the recv() at the very bottom and return nil if we're already in recv.
    • 19:25:31 yyzfp$ Lua filters should not be scheduling their own next reads.
    • 19:30:34 yyzfp$ Also check nse_yield.
  • Have a look at copas/kepler and luasocket.

Not a priority

  • recv() - add the numbytes argument to that would let you control how much data is read
  • connect() - pass the key to the connections[] global array as an argument
  • close() - try to close cleanly
  • Find a way to rewrite nls->in_send
  • Make lowest-level socket an userdata.
  • Detect when user calls coroutine.resume().
    • nse_main.lua:988
  • See if I can get away without saving the coroutines by not using the main thread in recv handler.