mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-04 01:55:10 +02:00
Handle version in db
This commit is contained in:
parent
bd7e96b8af
commit
377eb2b851
1 changed files with 12 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
import { db } from "@server/db";
|
||||
import { db, newts } from "@server/db";
|
||||
import { MessageHandler } from "../ws";
|
||||
import { exitNodes, Newt, resources, sites, Target, targets } from "@server/db";
|
||||
import { eq, and, sql, inArray } from "drizzle-orm";
|
||||
|
@ -38,7 +38,7 @@ export const handleNewtRegisterMessage: MessageHandler = async (context) => {
|
|||
|
||||
const siteId = newt.siteId;
|
||||
|
||||
const { publicKey, pingResults, backwardsCompatible } = message.data;
|
||||
const { publicKey, pingResults, newtVersion, backwardsCompatible } = message.data;
|
||||
if (!publicKey) {
|
||||
logger.warn("Public key not provided");
|
||||
return;
|
||||
|
@ -59,6 +59,16 @@ export const handleNewtRegisterMessage: MessageHandler = async (context) => {
|
|||
exitNodeId = bestPingResult.exitNodeId;
|
||||
}
|
||||
|
||||
if (newtVersion) {
|
||||
// update the newt version in the database
|
||||
await db
|
||||
.update(newts)
|
||||
.set({
|
||||
version: newtVersion as string,
|
||||
})
|
||||
.where(eq(newts.newtId, newt.newtId))
|
||||
}
|
||||
|
||||
const [oldSite] = await db
|
||||
.select()
|
||||
.from(sites)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue