mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using FluentFTP;
|
|
using Wabbajack.Common;
|
|
|
|
namespace Wabbajack.Server.DTOs
|
|
{
|
|
public enum StorageSpace
|
|
{
|
|
AuthoredFiles,
|
|
Patches,
|
|
Mirrors
|
|
}
|
|
|
|
public class BunnyCdnFtpInfo
|
|
{
|
|
public string Username { get; set; }
|
|
public string Password { get; set; }
|
|
public string Hostname { get; set; }
|
|
|
|
public static async Task<BunnyCdnFtpInfo> GetCreds(StorageSpace space)
|
|
{
|
|
return (await Utils.FromEncryptedJson<Dictionary<string, BunnyCdnFtpInfo>>("bunnycdn"))[space.ToString()];
|
|
}
|
|
|
|
public async Task<FtpClient> GetClient()
|
|
{
|
|
return await CircuitBreaker.WithAutoRetryAllAsync(async () =>
|
|
{
|
|
var ftpClient = new FtpClient(Hostname, new NetworkCredential(Username, Password));
|
|
await ftpClient.ConnectAsync();
|
|
return ftpClient;
|
|
});
|
|
}
|
|
}
|
|
}
|