public FTP(string url, Dictionary<string, string> options) { //This can be made better by keeping a single ftp stream open, //unfortunately the .Net model does not allow this as the request is //bound to a single url (path+file). // //To fix this, a thirdparty FTP library is required, //this would also allow a fix for the FTP servers //that only support SSL during authentication, not during transfers // //If you have experience with a stable open source .Net FTP library, //please let the Duplicati authors know var u = new Utility.Uri(url); u.RequireHost(); if (!string.IsNullOrEmpty(u.Username)) { m_userInfo = new System.Net.NetworkCredential(); m_userInfo.UserName = u.Username; if (!string.IsNullOrEmpty(u.Password)) m_userInfo.Password = u.Password; else if (options.ContainsKey("auth-password")) m_userInfo.Password = options["auth-password"]; } else { if (options.ContainsKey("auth-username")) { m_userInfo = new System.Net.NetworkCredential(); m_userInfo.UserName = options["auth-username"]; if (options.ContainsKey("auth-password")) m_userInfo.Password = options["auth-password"]; } } //Bugfix, see http://connect.microsoft.com/VisualStudio/feedback/details/695227/networkcredential-default-constructor-leaves-domain-null-leading-to-null-object-reference-exceptions-in-framework-code if (m_userInfo != null) m_userInfo.Domain = ""; m_url = u.SetScheme("ftp").SetQuery(null).SetCredentials(null, null).ToString(); if (!m_url.EndsWith("/")) m_url += "/"; m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl"); m_listVerify = !Utility.Utility.ParseBoolOption(options, "disable-upload-verify"); if (Utility.Utility.ParseBoolOption(options, "ftp-passive")) { m_defaultPassive = false; m_passive = true; } if (Utility.Utility.ParseBoolOption(options, "ftp-regular")) { m_defaultPassive = false; m_passive = false; } }
public TahoeBackend(string url, Dictionary<string, string> options) { //Validate URL var u = new Utility.Uri(url); u.RequireHost(); if (!u.Path.StartsWith("uri/URI:DIR2:") && !u.Path.StartsWith("uri/URI%3ADIR2%3A")) throw new Exception(Strings.TahoeBackend.UnrecognizedUriError); m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl"); m_url = u.SetScheme(m_useSSL ? "https" : "http").SetQuery(null).SetCredentials(null, null).ToString(); if (!m_url.EndsWith("/")) m_url += "/"; }
public TahoeBackend(string url, Dictionary <string, string> options) { //Validate URL var u = new Utility.Uri(url); u.RequireHost(); if (!u.Path.StartsWith("uri/URI:DIR2:", StringComparison.Ordinal) && !u.Path.StartsWith("uri/URI%3ADIR2%3A", StringComparison.Ordinal)) { throw new UserInformationException(Strings.TahoeBackend.UnrecognizedUriError, "TahoeInvalidUri"); } m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl"); m_url = u.SetScheme(m_useSSL ? "https" : "http").SetQuery(null).SetCredentials(null, null).ToString(); m_url = Util.AppendDirSeparator(m_url, "/"); }
public TahoeBackend(string url, Dictionary <string, string> options) { //Validate URL var u = new Utility.Uri(url); u.RequireHost(); if (!u.Path.StartsWith("uri/URI:DIR2:") && !u.Path.StartsWith("uri/URI%3ADIR2%3A")) { throw new UserInformationException(Strings.TahoeBackend.UnrecognizedUriError); } m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl"); m_url = u.SetScheme(m_useSSL ? "https" : "http").SetQuery(null).SetCredentials(null, null).ToString(); if (!m_url.EndsWith("/")) { m_url += "/"; } }
public WEBDAV(string url, Dictionary <string, string> options) { var u = new Utility.Uri(url); u.RequireHost(); m_dnsName = u.Host; if (!string.IsNullOrEmpty(u.Username)) { m_userInfo = new System.Net.NetworkCredential(); m_userInfo.UserName = u.Username; if (!string.IsNullOrEmpty(u.Password)) { m_userInfo.Password = u.Password; } else if (options.ContainsKey("auth-password")) { m_userInfo.Password = options["auth-password"]; } } else { if (options.ContainsKey("auth-username")) { m_userInfo = new System.Net.NetworkCredential(); m_userInfo.UserName = options["auth-username"]; if (options.ContainsKey("auth-password")) { m_userInfo.Password = options["auth-password"]; } } } //Bugfix, see http://connect.microsoft.com/VisualStudio/feedback/details/695227/networkcredential-default-constructor-leaves-domain-null-leading-to-null-object-reference-exceptions-in-framework-code if (m_userInfo != null) { m_userInfo.Domain = ""; } m_useIntegratedAuthentication = Utility.Utility.ParseBoolOption(options, "integrated-authentication"); m_forceDigestAuthentication = Utility.Utility.ParseBoolOption(options, "force-digest-authentication"); m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl"); m_url = u.SetScheme(m_useSSL ? "https" : "http").SetCredentials(null, null).SetQuery(null).ToString(); if (!m_url.EndsWith("/", StringComparison.Ordinal)) { m_url += "/"; } m_path = u.Path; if (!m_path.StartsWith("/", StringComparison.Ordinal)) { m_path = "/" + m_path; } if (!m_path.EndsWith("/", StringComparison.Ordinal)) { m_path += "/"; } m_path = Library.Utility.Uri.UrlDecode(m_path); m_rawurl = new Utility.Uri(m_useSSL ? "https" : "http", u.Host, m_path).ToString(); int port = u.Port; if (port <= 0) { port = m_useSSL ? 443 : 80; } m_rawurlPort = new Utility.Uri(m_useSSL ? "https" : "http", u.Host, m_path, null, null, null, port).ToString(); m_sanitizedUrl = new Utility.Uri(m_useSSL ? "https" : "http", u.Host, m_path).ToString(); m_reverseProtocolUrl = new Utility.Uri(m_useSSL ? "http" : "https", u.Host, m_path).ToString(); options.TryGetValue("debug-propfind-file", out m_debugPropfindFile); }
public FTP(string url, Dictionary <string, string> options) { //This can be made better by keeping a single ftp stream open, //unfortunately the .Net model does not allow this as the request is //bound to a single url (path+file). // //To fix this, a thirdparty FTP library is required, //this would also allow a fix for the FTP servers //that only support SSL during authentication, not during transfers // //If you have experience with a stable open source .Net FTP library, //please let the Duplicati authors know var u = new Utility.Uri(url); u.RequireHost(); if (!string.IsNullOrEmpty(u.Username)) { m_userInfo = new System.Net.NetworkCredential(); m_userInfo.UserName = u.Username; if (!string.IsNullOrEmpty(u.Password)) { m_userInfo.Password = u.Password; } else if (options.ContainsKey("auth-password")) { m_userInfo.Password = options["auth-password"]; } } else { if (options.ContainsKey("auth-username")) { m_userInfo = new System.Net.NetworkCredential(); m_userInfo.UserName = options["auth-username"]; if (options.ContainsKey("auth-password")) { m_userInfo.Password = options["auth-password"]; } } } //Bugfix, see http://connect.microsoft.com/VisualStudio/feedback/details/695227/networkcredential-default-constructor-leaves-domain-null-leading-to-null-object-reference-exceptions-in-framework-code if (m_userInfo != null) { m_userInfo.Domain = ""; } m_url = u.SetScheme("ftp").SetQuery(null).SetCredentials(null, null).ToString(); if (!m_url.EndsWith("/")) { m_url += "/"; } m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl"); m_listVerify = !Utility.Utility.ParseBoolOption(options, "disable-upload-verify"); if (Utility.Utility.ParseBoolOption(options, "ftp-passive")) { m_defaultPassive = false; m_passive = true; } if (Utility.Utility.ParseBoolOption(options, "ftp-regular")) { m_defaultPassive = false; m_passive = false; } }
public WEBDAV(string url, Dictionary<string, string> options) { var u = new Utility.Uri(url); u.RequireHost(); if (!string.IsNullOrEmpty(u.Username)) { m_userInfo = new System.Net.NetworkCredential(); m_userInfo.UserName = u.Username; if (!string.IsNullOrEmpty(u.Password)) m_userInfo.Password = u.Password; else if (options.ContainsKey("auth-password")) m_userInfo.Password = options["auth-password"]; } else { if (options.ContainsKey("auth-username")) { m_userInfo = new System.Net.NetworkCredential(); m_userInfo.UserName = options["auth-username"]; if (options.ContainsKey("auth-password")) m_userInfo.Password = options["auth-password"]; } } //Bugfix, see http://connect.microsoft.com/VisualStudio/feedback/details/695227/networkcredential-default-constructor-leaves-domain-null-leading-to-null-object-reference-exceptions-in-framework-code if (m_userInfo != null) m_userInfo.Domain = ""; m_useIntegratedAuthentication = Utility.Utility.ParseBoolOption(options, "integrated-authentication"); m_forceDigestAuthentication = Utility.Utility.ParseBoolOption(options, "force-digest-authentication"); m_useSSL = Utility.Utility.ParseBoolOption(options, "use-ssl"); m_url = u.SetScheme(m_useSSL ? "https" : "http").SetCredentials(null, null).SetQuery(null).ToString(); if (!m_url.EndsWith("/")) m_url += "/"; m_path = u.Path; if (!m_path.StartsWith("/")) m_path = "/" + m_path; if (!m_path.EndsWith("/")) m_path += "/"; m_path = System.Web.HttpUtility.UrlDecode(m_path); m_rawurl = new Utility.Uri(m_useSSL ? "https" : "http", u.Host, m_path).ToString(); int port = u.Port; if (port <= 0) port = m_useSSL ? 443 : 80; m_rawurlPort = new Utility.Uri(m_useSSL ? "https" : "http", u.Host, m_path, null, null, null, port).ToString(); m_sanitizedUrl = new Utility.Uri(m_useSSL ? "https" : "http", u.Host, m_path).ToString(); m_reverseProtocolUrl = new Utility.Uri(m_useSSL ? "http" : "https", u.Host, m_path).ToString(); options.TryGetValue("debug-propfind-file", out m_debugPropfindFile); }