bolcom / libunftp

Extensible, async, cloud orientated FTP(S) server library and the core of unFTP: https://github.com/bolcom/unFTP. Follow up and talk to us on https://t.me/unftp
Apache License 2.0
182 stars 33 forks source link

Proxy protocol port removed inadvertedly #494

Closed robklg closed 7 months ago

robklg commented 9 months ago

Proxy protocol code (correctly) tries to remove stale ports. But there's a bug that when the same port is selected twice in a row within the same session, it removes the port from the switchboard where it shouldn't. proxy_protocol.rs:274:

                match &self.try_and_claim(hash.clone(), session_arc.clone()).await {
[..]
                    Ok(_) => {
                        // Remove and disassociate existing passive channels
                        if let Some(active_datachan_hash) = &session.proxy_active_datachan {
                            slog::info!(self.logger, "Removing stale session data channel {:?}", &active_datachan_hash);
                            self.unregister_hash(active_datachan_hash);
                        }

So, if the claimed port happens to be the same as the last one, the port is unintentionally regarded as stale and therefore unregistered.