-
-
Notifications
You must be signed in to change notification settings - Fork 659
FTPS Proxies
-
new FtpClientSocks5Proxy() - Creates a new FTP client to connect to an FTP server using a SOCKS5 proxy.
-
new FtpClientHttp11Proxy() - Creates a new FTP client to connect to an FTP server using an HTTP 1.1 proxy.
-
new FtpClientUserAtHostProxy() - Creates a new FTP client to connect to an FTP server using a User@Host proxy.
-
new FtpClientBlueCoatProxy() - Creates a new FTP client to connect to an FTP server using the BlueCoat proxy.
Create a new instance of one of the proxy classes and then use any of the available API to control the connection. For example:
// create an FTP client connecting through a HTTP 1.1 Proxy
var proxy = new ProxyInfo(){
Address = new Uri("http://myproxy.com/"),
};
FtpClient client = new FtpClientHttp11Proxy(proxy);
client.Host = "123.123.123.123";
client.Credentials = new NetworkCredential("david", "pass123");
// begin connecting to the server
client.Connect();
// get a list of files and directories in the "/htdocs" folder
foreach (FtpListItem item in client.GetListing("/htdocs")) {
// if this is a file
if (item.Type == FtpFileSystemObjectType.File){
// get the file size
long size = client.GetFileSize(item.FullName);
// calculate a hash for the file on the server side (default algorithm)
FtpHash hash = client.GetHash(item.FullName);
}
// get modified date/time of the file or folder
DateTime time = client.GetModifiedTime(item.FullName);
}
// upload a file
client.UploadFile(@"C:\MyVideo.mp4", "/htdocs/MyVideo.mp4");
// rename the uploaded file
client.Rename("/htdocs/MyVideo.mp4", "/htdocs/MyVideo_2.mp4");
// download the file again
client.DownloadFile(@"C:\MyVideo_2.mp4", "/htdocs/MyVideo_2.mp4");
// delete the file
client.DeleteFile("/htdocs/MyVideo_2.mp4");
// disconnect! good bye!
client.Disconnect();
// create an FTP client connecting through a SOCKS5 Proxy
var client = new FtpClientSocks5Proxy(new ProxyInfo(){
Credentials = null,
Host = "http://myproxy.com/",
Port = 12345
});
client.Host = "123.123.123.123";
client.Credentials = new NetworkCredential("david", "pass123");
// begin connecting to the server
client.Connect();
// get a list of files and directories in the "/htdocs" folder
foreach (FtpListItem item in client.GetListing("/htdocs")) {
// if this is a file
if (item.Type == FtpFileSystemObjectType.File){
// get the file size
long size = client.GetFileSize(item.FullName);
// calculate a hash for the file on the server side (default algorithm)
FtpHash hash = client.GetHash(item.FullName);
}
// get modified date/time of the file or folder
DateTime time = client.GetModifiedTime(item.FullName);
}
// upload a file
client.UploadFile(@"C:\MyVideo.mp4", "/htdocs/MyVideo.mp4");
// rename the uploaded file
client.Rename("/htdocs/MyVideo.mp4", "/htdocs/MyVideo_2.mp4");
// download the file again
client.DownloadFile(@"C:\MyVideo_2.mp4", "/htdocs/MyVideo_2.mp4");
// delete the file
client.DeleteFile("/htdocs/MyVideo_2.mp4");
// disconnect! good bye!
client.Disconnect();
The FtpClientSocks5Proxy
supports:
*SOCKS5 protocol as specified in RFC1928 spec *SOCKS5 username/password authentication as specified RFC1929 spec
It has been tested against VSFTPD using Dante as a SOCKS proxy, both locally and against an Azure installation, where the FTP was running on a local address.
You will need to install Docker on your dev machine.
Docker commands to spin up a local copy for testing:
docker run -d --restart=always -p 9020:20 -p 9021:21 -p 9100-9110:9100-9110 -e FTP_USER=ftp -e FTP_PASS=ftp -e PASV_ADDRESS=172.18.144.1 -e PASV_MIN_PORT=9100 -e PASV_MAX_PORT=9110 -v /data/ftp:/home/vsftpd fauria/vsftpd
docker run -d -p 1080:1080 wernight/dante
- Auto Connection
- Auto Reconnection
- FTP(S) Connection
- FTP(S) Connection using GnuTLS
- FTPS Proxies
- Custom Servers
- Custom Commands
- v40 Migration Guide