mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-22 21:06:37 +00:00
Merge dev into fix/log-analytics-adjustments
This commit is contained in:
@@ -24,9 +24,9 @@ export type CreateNewtResponse = {
|
||||
};
|
||||
|
||||
const createNewtSchema = z.strictObject({
|
||||
newtId: z.string(),
|
||||
secret: z.string()
|
||||
});
|
||||
newtId: z.string(),
|
||||
secret: z.string()
|
||||
});
|
||||
|
||||
export async function createNewt(
|
||||
req: Request,
|
||||
@@ -34,7 +34,6 @@ export async function createNewt(
|
||||
next: NextFunction
|
||||
): Promise<any> {
|
||||
try {
|
||||
|
||||
const parsedBody = createNewtSchema.safeParse(req.body);
|
||||
if (!parsedBody.success) {
|
||||
return next(
|
||||
@@ -58,7 +57,7 @@ export async function createNewt(
|
||||
await db.insert(newts).values({
|
||||
newtId: newtId,
|
||||
secretHash,
|
||||
dateCreated: moment().toISOString(),
|
||||
dateCreated: moment().toISOString()
|
||||
});
|
||||
|
||||
// give the newt their default permissions:
|
||||
@@ -75,12 +74,12 @@ export async function createNewt(
|
||||
data: {
|
||||
newtId,
|
||||
secret,
|
||||
token,
|
||||
token
|
||||
},
|
||||
success: true,
|
||||
error: false,
|
||||
message: "Newt created successfully",
|
||||
status: HttpCode.OK,
|
||||
status: HttpCode.OK
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof SqliteError && e.code === "SQLITE_CONSTRAINT_UNIQUE") {
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
import { verifyPassword } from "@server/auth/password";
|
||||
import logger from "@server/logger";
|
||||
import config from "@server/lib/config";
|
||||
import { APP_VERSION } from "@server/lib/consts";
|
||||
|
||||
export const olmGetTokenBodySchema = z.object({
|
||||
olmId: z.string(),
|
||||
@@ -205,10 +206,12 @@ export async function getOlmToken(
|
||||
return response<{
|
||||
token: string;
|
||||
exitNodes: { publicKey: string; endpoint: string }[];
|
||||
serverVersion: string;
|
||||
}>(res, {
|
||||
data: {
|
||||
token: resToken,
|
||||
exitNodes: exitNodesHpData
|
||||
exitNodes: exitNodesHpData,
|
||||
serverVersion: APP_VERSION
|
||||
},
|
||||
success: true,
|
||||
error: false,
|
||||
|
||||
@@ -61,9 +61,12 @@ export const startOlmOfflineChecker = (): void => {
|
||||
|
||||
// Send a disconnect message to the client if connected
|
||||
try {
|
||||
await sendTerminateClient(offlineClient.clientId, offlineClient.olmId); // terminate first
|
||||
await sendTerminateClient(
|
||||
offlineClient.clientId,
|
||||
offlineClient.olmId
|
||||
); // terminate first
|
||||
// wait a moment to ensure the message is sent
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
await disconnectClient(offlineClient.olmId);
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
|
||||
@@ -113,14 +113,14 @@ export const handleOlmServerPeerAddMessage: MessageHandler = async (
|
||||
.select()
|
||||
.from(clientSitesAssociationsCache)
|
||||
.where(
|
||||
and(
|
||||
and(
|
||||
eq(clientSitesAssociationsCache.clientId, client.clientId),
|
||||
isNotNull(clientSitesAssociationsCache.endpoint),
|
||||
eq(clientSitesAssociationsCache.publicKey, client.pubKey) // limit it to the current session its connected with otherwise the endpoint could be stale
|
||||
)
|
||||
);
|
||||
|
||||
// pick an endpoint
|
||||
// pick an endpoint
|
||||
for (const assoc of currentSessionSiteAssociationCaches) {
|
||||
if (assoc.endpoint) {
|
||||
endpoint = assoc.endpoint;
|
||||
|
||||
@@ -8,4 +8,4 @@ export * from "./listUserOlms";
|
||||
export * from "./deleteUserOlm";
|
||||
export * from "./getUserOlm";
|
||||
export * from "./handleOlmServerPeerAddMessage";
|
||||
export * from "./handleOlmUnRelayMessage";
|
||||
export * from "./handleOlmUnRelayMessage";
|
||||
|
||||
Reference in New Issue
Block a user