RemoteFileLocation
using System;
using System.Net;
using System.Net.Sockets;
namespace Aspera.Transfer
{
public class RemoteFileLocation : FileLocation
{
protected string host;
protected string identity;
protected string password;
protected string user;
private long end;
private long start;
public RemoteFileLocation(string host, string user, string password)
{
if (host == null || host == string.Empty)
throw new ArgumentException("Null or zero-length string invalid", "host");
if (user == null || user == string.Empty)
throw new ArgumentException("Null or zero-length string invalid", "user");
if (password == null || password == string.Empty)
throw new ArgumentException("Null or zero-length string invalid", "password");
this.host = host.Replace("[", "").Replace("]", "");
this.user = user;
this.password = password;
}
public RemoteFileLocation(string host, string user, string identity, string passphrase)
{
if (host == null || host == string.Empty)
throw new ArgumentException("Null or zero-length string invalid", "host");
if (user == null || user == string.Empty)
throw new ArgumentException("Null or zero-length string invalid", "user");
if (identity == null || identity == string.Empty)
throw new ArgumentException("Null or zero-length string invalid", "identity");
this.host = host;
this.user = user;
this.identity = identity;
password = passphrase;
}
public bool IsHostIPv6()
{
if (IPAddress.TryParse(host, out IPAddress address) && address.AddressFamily == AddressFamily.InterNetworkV6)
return true;
return false;
}
public string getHost()
{
return host;
}
public string getUser()
{
return user;
}
public string getIdentity()
{
return identity;
}
public string getPassword()
{
return password;
}
public void setByteRange(long start, long end)
{
this.start = start;
this.end = end;
}
protected internal string getRangeCmdString()
{
return "-@" + start.ToString() + ":" + end.ToString();
}
public bool IsPartialFileTransfer()
{
if (start == 0)
return end != 0;
return true;
}
}
}