Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to specifiy a list of allowed ports for passive data connections. #8

Closed
fubar-coder opened this issue Apr 19, 2016 · 2 comments
Assignees

Comments

@fubar-coder
Copy link
Contributor

This seems to be required when the FTP server is used as Azure service with public/accessible end points.

@fubar-coder
Copy link
Contributor Author

There is a Gist with changes made by Guillaume Pelletier (dotvision.com): https://gist.github.com/fubar-coder/32a1a6d859d12a9961e1a7e897a27900

@chaseaucoin
Copy link

chaseaucoin commented Nov 14, 2018

Okay so this and #43 were blocking my ability to deploy via containers but I have resolved this as well. Looks like the way PASV is handled has shifted somewhat since the proposed GIST

Not sure how you want to pass the pasv port array to the handler but I did this hard coded just to get me by for right now.

public class PasvCommandHandler : FtpCommandHandler { static ConcurrentQueue<int> _portQueue = new ConcurrentQueue<int>(Enumerable.Range(8000, 30)); }

        int dequeuedPort;
        while (!_portQueue.TryDequeue(out dequeuedPort)) { }
        
        int port;

        var isEpsv = string.Equals(command.Name, "EPSV", StringComparison.OrdinalIgnoreCase);
        if (isEpsv)
        {
            if (string.IsNullOrEmpty(command.Argument) || string.Equals(command.Argument, "ALL", StringComparison.OrdinalIgnoreCase))
            {
                port = dequeuedPort;
            }
            else
            {
                port = Convert.ToInt32(command.Argument, 10);
            }
        }
        else
        {
            port = dequeuedPort;
        }

`

finally { listener.Stop(); _portQueue.Enqueue(dequeuedPort); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants