Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Skovhede <kenneth@hexad.dk>2013-05-06 01:46:00 +0400
committerKenneth Skovhede <kenneth@hexad.dk>2013-05-06 01:46:00 +0400
commite5b3f0ea9376392837a6c8074e3e39822198fed3 (patch)
treec013640c0063ea8b4a642b78359b58fa766803ea /Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
parent86b52d364d7613a7ecfda746952c0d64afd3dbb0 (diff)
Rewrote all backends to use the new Uri parser.
Updated the regex to be a little more forgiving. Does not handle paths with @, like "ftp://server/@folder"
Diffstat (limited to 'Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs')
-rw-r--r--Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs49
1 files changed, 17 insertions, 32 deletions
diff --git a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
index 2a6c66557..05396ceb1 100644
--- a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
+++ b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
@@ -50,44 +50,29 @@ namespace Duplicati.Library.Backend
: this()
{
m_options = options;
- Uri u = new Uri(url);
- if (!string.IsNullOrEmpty(u.UserInfo))
- {
- if (u.UserInfo.IndexOf(":") >= 0)
- {
- m_username = u.UserInfo.Substring(0, u.UserInfo.IndexOf(":"));
- m_password = u.UserInfo.Substring(u.UserInfo.IndexOf(":") + 1);
- }
- else
- {
- m_username = u.UserInfo;
- if (options.ContainsKey("auth-password"))
- m_password = options["auth-password"];
- }
- }
- else
- {
- if (options.ContainsKey("auth-username"))
- m_username = options["auth-username"];
- if (options.ContainsKey("auth-password"))
- m_password = options["auth-password"];
- }
-
- m_path = u.AbsolutePath;
-
- //Remove 1 leading slash so server/path is mapped to "path",
- // and server//path is mapped to "/path"
- m_path = m_path.Substring(1);
+ var uri = new Utility.Uri(url);
+ uri.RequireHost();
+
+ if (options.ContainsKey("auth-username"))
+ m_username = options["auth-username"];
+ if (options.ContainsKey("auth-password"))
+ m_password = options["auth-password"];
+ if (!string.IsNullOrEmpty(uri .Username))
+ m_username = uri.Username;
+ if (!string.IsNullOrEmpty(uri .Password))
+ m_password = uri.Password;
+
+ m_path = uri.Path;
if (!m_path.EndsWith("/"))
m_path += "/";
- m_server = u.Host;
+ m_server = uri.Host;
- if (!u.IsDefaultPort)
+ if (uri.Port > 0 && uri.Port != m_port)
{
- m_ssh_options += " -P " + u.Port;
- m_port = u.Port;
+ m_ssh_options += " -P " + uri.Port;
+ m_port = uri.Port;
}
}