blob: 7b449645f9fd74117dce9274f667c0b896ee3025 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
using Duplicati.Library.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Duplicati.Library.Backend.Storj
{
public class StorjConfig : IWebModule
{
private const ConfigType DEFAULT_CONFIG_TYPE = ConfigType.Satellites;
private const string KEY_CONFIGTYPE = "storj-config";
private static readonly string DEFAULT_CONFIG_TYPE_STR = Enum.GetName(typeof(ConfigType), DEFAULT_CONFIG_TYPE);
public enum ConfigType
{
Satellites,
AuthenticationMethods
}
#region IWebModule implementation
public string Key { get { return "storj-getconfig"; } }
public string DisplayName { get { return "Storj DCS configuration module"; } }
public string Description { get { return "Exposes Storj DCS configuration as a web module"; } }
public IList<ICommandLineArgument> SupportedCommands
{
get
{
return new List<ICommandLineArgument>(new ICommandLineArgument[] {
new CommandLineArgument(KEY_CONFIGTYPE, CommandLineArgument.ArgumentType.Enumeration, "The config to get", "Provides different config values", DEFAULT_CONFIG_TYPE_STR, Enum.GetNames(typeof(ConfigType)))
});
}
}
public IDictionary<string, string> Execute(IDictionary<string, string> options)
{
string k;
options.TryGetValue(KEY_CONFIGTYPE, out k);
if (string.IsNullOrWhiteSpace(k))
{
k = DEFAULT_CONFIG_TYPE_STR;
}
ConfigType ct;
if (!Enum.TryParse<ConfigType>(k, true, out ct))
{
ct = DEFAULT_CONFIG_TYPE;
}
switch (ct)
{
case ConfigType.Satellites:
return Storj.KNOWN_STORJ_SATELLITES;
case ConfigType.AuthenticationMethods:
return Storj.KNOWN_AUTHENTICATION_METHODS;
default:
return Storj.KNOWN_STORJ_SATELLITES;
}
}
#endregion
}
}
|