libunftp icon indicating copy to clipboard operation
libunftp copied to clipboard

potential block when using proxy protocol

Open robklg opened this issue 4 years ago • 0 comments

In the proxy loop (ftpserver.rs), the function get_peer_from_proxy_header is called which blocks until the proxy header has completely been read. When for any reason this happens, new connections can not be accepted.

There are several angles to solve this that I've discussed and came up with together with @hannesdejager :

  • replace incoming connection handler with one that calls get_peer_from_proxy_header as well
  • spawn get_peer_from_proxy_header() in a async task, and use a channel to pass on the connection information + tcp stream back to the proxy loop
  • spawn get_peer_from_proxy_header() in a async task, and add this task to a specific task queue, that can then be watched from within the select!
  • spawn the hole incoming.next() arm in an async task, but that will require a concurrent hashmap to replace the current normal hashmap, including a performance penalty

In addition, a timeout must be introduced to make sure we close the connection if we do not receive the complete proxy header within x amount of time.

robklg avatar May 03 '20 19:05 robklg