using System;
using System.IO;
using EnterpriseDT.Net.Ftp;
using EnterpriseDT.Net.Ftp.Pro;
using EnterpriseDT.Util.Debug;
using EnterpriseDT.Util.Socks;
public class Socks4Client
{
public static void Main(string[] args)
{
if (args.Length < 6)
{
Console.WriteLine("Usage: Socks4Client remote-host username password filename proxy-server proxy-user");
Environment.Exit(1);
}
string remoteHost = args[0];
string user = args[1];
string password = args[2];
string filename = args[3];
string proxyServer = args[4];
string proxyUser = args[5];
Logger log = Logger.GetLogger(typeof(Socks4Client));
Logger.CurrentLevel = Level.INFO;
try
{
log.Info("Creating FTP-via-SOCKS4 client");
ProFTPClient ftp = new ProFTPClient();
log.Info("Setting FTP server address");
ftp.RemoteHost = remoteHost;
log.Info("Setting SOCKS4 context");
ftp.SocksContext = new Socks4Context(proxyServer, proxyUser, true);
log.Info("Connecting to server " + remoteHost);
ftp.Connect();
log.Info("Logging in with username=" + user + " and password=" + password);
ftp.Login(user, password);
log.Info("Setting up passive, ASCII transfers");
ftp.TransferType = FTPTransferType.ASCII;
ftp.ConnectMode = FTPConnectMode.PASV;
log.Info("Directory before put:");
foreach (string fileName in ftp.Dir(".", true))
log.Info(fileName);
log.Info("Putting " + filename + " to server");
ftp.Put(filename, Path.GetFileName(filename));
log.Info("Directory after put:");
foreach (string fileName in ftp.Dir(".", true))
log.Info(fileName);
log.Info("Getting " + Path.GetFileName(filename) + " from server and saving as " + filename + ".copy");
ftp.Get(filename + ".copy", Path.GetFileName(filename));
log.Info("Deleting " + Path.GetFileName(filename));
ftp.Delete(Path.GetFileName(filename));
log.Info("Directory after delete:");
foreach (string fileName in ftp.Dir(".", true))
log.Info(fileName);
log.Info("Quitting client");
}
catch (Exception e)
{
log.Error("Caught exception " + e.GetType().FullName + " " + e.Message, e);
}
}
}