Basic relay working!

This commit is contained in:
Owen
2025-02-23 16:49:41 -05:00
parent bebe40c8e8
commit afd87d07a3
8 changed files with 125 additions and 17 deletions

View File

@@ -10,7 +10,6 @@ import config from "@server/lib/config";
const inputSchema = z.object({
publicKey: z.string(),
endpoint: z.string()
});
type Input = z.infer<typeof inputSchema>;
@@ -42,7 +41,7 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
return;
}
const { publicKey, endpoint } = message.data as Input;
const { publicKey } = message.data as Input;
const siteId = newt.siteId;
@@ -66,7 +65,6 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
.update(sites)
.set({
publicKey,
// endpoint,
address,
listenPort
})
@@ -82,7 +80,6 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
.update(sites)
.set({
publicKey
// endpoint
})
.where(eq(sites.siteId, siteId))
.returning();

View File

@@ -2,6 +2,7 @@ import db from '@server/db';
import { newts, sites } from '@server/db/schema';
import { eq } from 'drizzle-orm';
import { sendToClient } from '../ws';
import logger from '@server/logger';
export async function addPeer(siteId: number, peer: {
publicKey: string;
@@ -24,6 +25,8 @@ export async function addPeer(siteId: number, peer: {
type: 'newt/wg/peer/add',
data: peer
});
logger.info(`Added peer ${peer.publicKey} to newt ${newt.newtId}`);
}
export async function deletePeer(siteId: number, publicKey: string) {
@@ -44,4 +47,6 @@ export async function deletePeer(siteId: number, publicKey: string) {
publicKey
}
});
logger.info(`Deleted peer ${publicKey} from newt ${newt.newtId}`);
}