From 949d158c07bd4ef595876725a509f0f71b3a5f10 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 27 Jun 2021 12:04:48 -0500 Subject: add FTP options --- src/slskd/Options.cs | 75 ++++++++++++++++++++++++++++++++++++++++++ src/slskd/Properties/slskd.yml | 10 +++++- 2 files changed, 84 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 485619bc..73678df0 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -21,6 +21,7 @@ namespace slskd using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Diagnostics; + using FluentFTP; using slskd.Validation; using Soulseek.Diagnostics; using Utility.CommandLine; @@ -121,6 +122,12 @@ namespace slskd [Validate] public SoulseekOptions Soulseek { get; private set; } = new SoulseekOptions(); + /// + /// Gets options for external integrations. + /// + [Validate] + public IntegrationOptions Integration { get; private set; } = new IntegrationOptions(); + /// /// Directory options. /// @@ -547,5 +554,73 @@ namespace slskd } } } + + /// + /// Options for external integrations. + /// + public class IntegrationOptions + { + /// + /// Gets FTP options. + /// + [Validate] + public FTPOptions FTP { get; private set; } = new FTPOptions(); + + /// + /// FTP options. + /// + public class FTPOptions + { + /// + /// Gets the FTP address. + /// + [Argument(default, "ftp-address")] + [EnvironmentVariable("FTP_ADDRESS")] + [Description("FTP address")] + public string Address { get; private set; } + + /// + /// Gets the FTP port. + /// + [Argument(default, "ftp-port")] + [EnvironmentVariable("FTP_PORT")] + [Description("FTP port")] + [Range(1, 65535)] + public int Port { get; private set; } = 21; + + /// + /// Gets the FTP encryption mode. + /// + [Argument(default, "ftp-encryption-mode")] + [EnvironmentVariable("FTP_ENCRYPTION_MODE")] + [Description("FTP encryption mode; none, implicit, explicit, auto")] + [Enum(typeof(FtpEncryptionMode))] + public string EncryptionMode { get; private set; } = "auto"; + + /// + /// Gets the FTP username. + /// + [Argument(default, "ftp-username")] + [EnvironmentVariable("FTP_USERNAME")] + [Description("FTP username")] + public string Username { get; private set; } + + /// + /// Gets the FTP password. + /// + [Argument(default, "ftp-password")] + [EnvironmentVariable("FTP_PASSWORD")] + [Description("FTP password")] + public string Password { get; private set; } + + /// + /// Gets the number of times failing uploads will be retried. + /// + [Argument(default, "ftp-retry-attempts")] + [EnvironmentVariable("FTP_RETRY_ATTEMPTS")] + [Description("The number of times failing uploads will be retried")] + public int RetryAttempts { get; private set; } = 5; + } + } } } \ No newline at end of file diff --git a/src/slskd/Properties/slskd.yml b/src/slskd/Properties/slskd.yml index ccfe60f9..492fb01c 100644 --- a/src/slskd/Properties/slskd.yml +++ b/src/slskd/Properties/slskd.yml @@ -48,4 +48,12 @@ # address: ~ # port: ~ # username: ~ -# password: ~ \ No newline at end of file +# password: ~ +# integration: +# ftp: +# address: ~ +# port: ~ +# encryption_mode: auto +# username: ~ +# password: ~ +# retry_attempts: 5 \ No newline at end of file -- cgit v1.2.3