mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-16 15:32:19 +02:00
Send down gerbil pub so it can encrypt
This commit is contained in:
parent
1f11a1df02
commit
14e6136683
1 changed files with 14 additions and 9 deletions
|
@ -1,12 +1,7 @@
|
||||||
import db from "@server/db";
|
import db from "@server/db";
|
||||||
import { MessageHandler } from "../ws";
|
import { MessageHandler } from "../ws";
|
||||||
import {
|
import { clients, Olm, olms, sites } from "@server/db/schema";
|
||||||
clients,
|
import { eq } from "drizzle-orm";
|
||||||
Olm,
|
|
||||||
olms,
|
|
||||||
sites,
|
|
||||||
} from "@server/db/schema";
|
|
||||||
import { eq, } from "drizzle-orm";
|
|
||||||
import { addPeer, deletePeer } from "../newt/peers";
|
import { addPeer, deletePeer } from "../newt/peers";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
|
|
||||||
|
@ -62,6 +57,16 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendToClient(olm.olmId, {
|
||||||
|
type: "olm/wg/holepunch",
|
||||||
|
data: {
|
||||||
|
endpoint: site.endpoint,
|
||||||
|
publicKey: site.publicKey,
|
||||||
|
serverIP: site.address!.split("/")[0],
|
||||||
|
tunnelIP: `${client.subnet.split("/")[0]}/${site.address!.split("/")[1]}` // put the client ip in the same subnet as the site. TODO: Is this right? Maybe we need th make .subnet work properly!
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const now = new Date().getTime() / 1000;
|
const now = new Date().getTime() / 1000;
|
||||||
if (site.lastHolePunch && now - site.lastHolePunch > 6) {
|
if (site.lastHolePunch && now - site.lastHolePunch > 6) {
|
||||||
logger.warn("Site last hole punch is too old");
|
logger.warn("Site last hole punch is too old");
|
||||||
|
@ -90,7 +95,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
|
||||||
logger.warn("Site has no subnet");
|
logger.warn("Site has no subnet");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the peer to the exit node
|
// add the peer to the exit node
|
||||||
await addPeer(site.siteId, {
|
await addPeer(site.siteId, {
|
||||||
publicKey: publicKey,
|
publicKey: publicKey,
|
||||||
|
@ -105,7 +110,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
|
||||||
endpoint: site.endpoint,
|
endpoint: site.endpoint,
|
||||||
publicKey: site.publicKey,
|
publicKey: site.publicKey,
|
||||||
serverIP: site.address!.split("/")[0],
|
serverIP: site.address!.split("/")[0],
|
||||||
tunnelIP: `${client.subnet.split("/")[0]}/${site.address!.split("/")[1]}`, // put the client ip in the same subnet as the site. TODO: Is this right? Maybe we need th make .subnet work properly!
|
tunnelIP: `${client.subnet.split("/")[0]}/${site.address!.split("/")[1]}` // put the client ip in the same subnet as the site. TODO: Is this right? Maybe we need th make .subnet work properly!
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
broadcast: false, // Send to all olms
|
broadcast: false, // Send to all olms
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue