mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-04 09:46:40 +00:00
Basic relay working!
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
Reference in New Issue
Block a user