forked from BornToBeRoot/NETworkManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunCommandManager.cs
More file actions
82 lines (76 loc) · 3.25 KB
/
Copy pathRunCommandManager.cs
File metadata and controls
82 lines (76 loc) · 3.25 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System.Collections.Generic;
using System.Linq;
using NETworkManager.Localization;
using NETworkManager.Models;
namespace NETworkManager;
public static class RunCommandManager
{
private const string DefaultArguments = "<SERVER-01|10.0.0.10>";
public static IEnumerable<RunCommandInfo> GetList()
{
return GetApplicationList().Concat(GetSettingsList());
}
private static IEnumerable<RunCommandInfo> GetSettingsList()
{
return new List<RunCommandInfo>
{
new()
{
Type = RunCommandType.Setting,
Name = "Settings",
TranslatedName = Localization.Resources.Strings.Settings,
Command = "settings",
CanHandleArguments = false,
ExampleArguments = string.Empty
}
};
}
private static IEnumerable<RunCommandInfo> GetApplicationList()
{
return ApplicationManager.GetNames().Where(name => name != ApplicationName.None).Select(name =>
new RunCommandInfo
{
Type = RunCommandType.Application,
Name = name.ToString(),
TranslatedName = ResourceTranslator.Translate(ResourceIdentifier.ApplicationName, name),
Command = name switch
{
_ => name.ToString().ToLower()
},
CanHandleArguments = name switch
{
ApplicationName.IPScanner => true,
ApplicationName.PortScanner => true,
ApplicationName.PingMonitor => true,
ApplicationName.Traceroute => true,
ApplicationName.DNSLookup => true,
ApplicationName.RemoteDesktop => true,
ApplicationName.PowerShell => true,
ApplicationName.PuTTY => true,
ApplicationName.AWSSessionManager => true,
ApplicationName.TigerVNC => true,
ApplicationName.WebConsole => true,
ApplicationName.SNMP => true,
ApplicationName.Whois => true,
_ => false
},
ExampleArguments = name switch
{
ApplicationName.IPScanner => "<10.0.0.0/24>",
ApplicationName.PortScanner => "<10.0.0.10;10.0.0.20> <1-1024>",
ApplicationName.PingMonitor => DefaultArguments,
ApplicationName.Traceroute => DefaultArguments,
ApplicationName.DNSLookup => "<SERVER-01|10.0.0.10> <A|CNAME>",
ApplicationName.RemoteDesktop => DefaultArguments,
ApplicationName.PowerShell => DefaultArguments,
ApplicationName.PuTTY => DefaultArguments,
ApplicationName.AWSSessionManager => "<i-1234567890abcdef0>",
ApplicationName.TigerVNC => DefaultArguments,
ApplicationName.WebConsole => "<https://borntoberoot.net>",
ApplicationName.SNMP => DefaultArguments,
ApplicationName.Whois => "<borntoberoot.net>",
_ => string.Empty
}
}).ToList();
}
}