149 lines
4.1 KiB
Diff
149 lines
4.1 KiB
Diff
diff --git a/api/src/backendimpl/passyfire-reimpl/routes.ts b/api/src/backendimpl/passyfire-reimpl/routes.ts
|
|
index 2961483..4519a87 100644
|
|
--- a/api/src/backendimpl/passyfire-reimpl/routes.ts
|
|
+++ b/api/src/backendimpl/passyfire-reimpl/routes.ts
|
|
@@ -47,25 +47,6 @@ export function route(instance: PassyFireBackendProvider) {
|
|
|
|
for (const spoofedRoute of unsupportedSpoofedRoutes) {
|
|
fastify.post(spoofedRoute, (req, res) => {
|
|
- if (typeof req.body != "string")
|
|
- return res.status(400).send({
|
|
- error: "Invalid token",
|
|
- });
|
|
-
|
|
- try {
|
|
- JSON.parse(req.body);
|
|
- } catch (e) {
|
|
- return res.status(400).send({
|
|
- error: "Invalid token",
|
|
- });
|
|
- }
|
|
-
|
|
- // @ts-expect-error
|
|
- if (!req.body.token)
|
|
- return res.status(400).send({
|
|
- error: "Invalid token",
|
|
- });
|
|
-
|
|
return res.status(403).send({
|
|
error: "Invalid scope(s)",
|
|
});
|
|
diff --git a/lom/src/commands/backends.ts b/lom/src/commands/backends.ts
|
|
index baba3d1..d16cac1 100644
|
|
--- a/lom/src/commands/backends.ts
|
|
+++ b/lom/src/commands/backends.ts
|
|
@@ -16,6 +16,18 @@ type BackendLookupSuccess = {
|
|
}[];
|
|
};
|
|
|
|
+const addRequiredOptions = {
|
|
+ ssh: [
|
|
+ "sshKey",
|
|
+ "username",
|
|
+ "host",
|
|
+ ],
|
|
+
|
|
+ passyfire: [
|
|
+ "host"
|
|
+ ]
|
|
+};
|
|
+
|
|
export async function run(
|
|
argv: string[],
|
|
println: PrintLine,
|
|
@@ -58,12 +70,12 @@ export async function run(
|
|
);
|
|
|
|
addBackend.option(
|
|
- "-u, --username",
|
|
+ "-u, --username <user>",
|
|
"(SSH, PassyFire) Username to authenticate with. With PassyFire, it's the username you create",
|
|
);
|
|
|
|
addBackend.option(
|
|
- "-h, --host",
|
|
+ "-h, --host <host>",
|
|
"(SSH, PassyFire) Host to connect to. With PassyFire, it's what you listen on",
|
|
);
|
|
|
|
@@ -86,10 +98,70 @@ export async function run(
|
|
);
|
|
|
|
addBackend.option(
|
|
- "-p, --password",
|
|
+ "-p, --password <password>",
|
|
"(PassyFire) What password you want to use for the primary user",
|
|
);
|
|
|
|
+ addBackend.action(async(name: string, provider: string, options: {
|
|
+ description?: string,
|
|
+ forceCustomParameters?: boolean,
|
|
+ customParameters?: string,
|
|
+
|
|
+ // SSH (mostly)
|
|
+ sshKey?: string,
|
|
+ username?: string,
|
|
+ host?: string,
|
|
+
|
|
+ // PassyFire (mostly)
|
|
+ isProxied?: boolean,
|
|
+ proxiedPortStr?: number,
|
|
+ guest?: boolean,
|
|
+ userAsk?: boolean,
|
|
+ password?: string
|
|
+ }) => {
|
|
+ // Yes it can index for what we need it to do.
|
|
+ // @ts-expect-error
|
|
+ const isUnsupportedPlatform: boolean = !addRequiredOptions[provider];
|
|
+
|
|
+ if (isUnsupportedPlatform) {
|
|
+ println("WARNING: Platform is not natively supported by the LOM yet!\n");
|
|
+ }
|
|
+
|
|
+ let connectionDetails: string = "";
|
|
+
|
|
+ if (options.forceCustomParameters || isUnsupportedPlatform) {
|
|
+ if (typeof options.customParameters != "string") {
|
|
+ return println("ERROR: You are missing the custom parameters option!\n");
|
|
+ }
|
|
+
|
|
+ connectionDetails = options.customParameters;
|
|
+ } else if (provider == "ssh") {
|
|
+ for (const argument of addRequiredOptions["ssh"]) {
|
|
+ // No.
|
|
+ // @ts-expect-error
|
|
+ const hasArgument = options[argument] as any;
|
|
+
|
|
+ if (!hasArgument) {
|
|
+ return println("ERROR: Missing argument '%s'\n", hasArgument);
|
|
+ };
|
|
+ };
|
|
+
|
|
+ // todo!
|
|
+ } else if (provider == "passyfire") {
|
|
+ for (const argument of addRequiredOptions["passyfire"]) {
|
|
+ // No.
|
|
+ // @ts-expect-error
|
|
+ const hasArgument = options[argument];
|
|
+
|
|
+ if (!hasArgument) {
|
|
+ return println("ERROR: Missing argument '%s'\n", hasArgument);
|
|
+ };
|
|
+ };
|
|
+
|
|
+ // todo!
|
|
+ }
|
|
+ });
|
|
+
|
|
const removeBackend = new SSHCommand(println, "rm");
|
|
removeBackend.description("Removes a backend");
|
|
removeBackend.argument("<id>", "ID of the backend");
|
|
@@ -269,7 +341,7 @@ export async function run(
|
|
|
|
// It would make sense to check this, then parse argv, however this causes issues with
|
|
// the application name not displaying correctly.
|
|
-
|
|
+
|
|
if (argv.length == 1) {
|
|
println("No arguments specified!\n\n");
|
|
program.help();
|