mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-25 03:56:38 +00:00
Clean up
This commit is contained in:
@@ -19,14 +19,9 @@ import { Socket } from "net";
|
||||
import {
|
||||
Newt,
|
||||
newts,
|
||||
NewtSession,
|
||||
olms,
|
||||
Olm,
|
||||
OlmSession,
|
||||
RemoteExitNode,
|
||||
RemoteExitNodeSession,
|
||||
remoteExitNodes,
|
||||
sites
|
||||
} from "@server/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "@server/db";
|
||||
|
||||
@@ -92,25 +92,6 @@ export async function getNewtToken(
|
||||
);
|
||||
}
|
||||
|
||||
const [existingSession] = await db
|
||||
.select()
|
||||
.from(newtSessions)
|
||||
.where(eq(newtSessions.newtId, existingNewt.newtId));
|
||||
|
||||
// if the session still has time in the expires, reuse it
|
||||
if (existingSession && (existingSession.expiresAt + 30 * 60 * 1000) > Date.now()) {
|
||||
return response<{ token: string; serverVersion: string }>(res, {
|
||||
data: {
|
||||
token: existingSession.sessionId,
|
||||
serverVersion: APP_VERSION
|
||||
},
|
||||
success: true,
|
||||
error: false,
|
||||
message: "Token created successfully",
|
||||
status: HttpCode.OK
|
||||
});
|
||||
}
|
||||
|
||||
// otherwise generate a new one
|
||||
const resToken = generateSessionToken();
|
||||
await createNewtSession(resToken, existingNewt.newtId);
|
||||
|
||||
@@ -9,8 +9,6 @@ import {
|
||||
exitNodes,
|
||||
sites,
|
||||
clientSitesAssociationsCache,
|
||||
olmSessions,
|
||||
olmSessions
|
||||
} from "@server/db";
|
||||
import { olms } from "@server/db";
|
||||
import HttpCode from "@server/types/HttpCode";
|
||||
|
||||
Reference in New Issue
Block a user