mirror of
https://github.com/fosrl/pangolin.git
synced 2026-10-15 00:59:04 +02:00
Propogated Changes. listen port is now accessed from db instead of config
This commit is contained in:
@@ -96,7 +96,10 @@ export async function buildClientConfigurationForNewtClient(
|
||||
await updatePeer(client.clients.clientId, {
|
||||
siteId: site.siteId,
|
||||
endpoint: site.endpoint!,
|
||||
relayEndpoint: formatEndpoint(exitNode.endpoint, config.getRawConfig().gerbil.clients_start_port),
|
||||
relayEndpoint: formatEndpoint(
|
||||
exitNode.endpoint,
|
||||
exitNode.relayPort
|
||||
),
|
||||
publicKey: site.publicKey!,
|
||||
serverIP: site.address,
|
||||
serverPort: site.listenPort
|
||||
@@ -121,6 +124,7 @@ export async function buildClientConfigurationForNewtClient(
|
||||
siteId,
|
||||
exitNode: {
|
||||
publicKey: exitNode.publicKey,
|
||||
relayPort: exitNode.relayPort,
|
||||
endpoint: exitNode.endpoint
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
import logger from "@server/logger";
|
||||
import { and, eq, inArray } from "drizzle-orm";
|
||||
import { addPeer, deletePeer } from "../newt/peers";
|
||||
import config from "@server/lib/config";
|
||||
import { SiR } from "react-icons/si";
|
||||
|
||||
export async function buildSiteConfigurationForOlmClient(
|
||||
@@ -129,7 +128,6 @@ export async function buildSiteConfigurationForOlmClient(
|
||||
}
|
||||
}
|
||||
|
||||
const clientsStartPort = config.getRawConfig().gerbil.clients_start_port;
|
||||
const peerOps: Promise<unknown>[] = [];
|
||||
|
||||
// Process each site
|
||||
@@ -216,7 +214,7 @@ export async function buildSiteConfigurationForOlmClient(
|
||||
logger.warn(`Exit node not found for site ${site.siteId}`);
|
||||
continue;
|
||||
}
|
||||
relayEndpoint = `${exitNode.endpoint}:${clientsStartPort}`;
|
||||
relayEndpoint = `${exitNode.endpoint}:${exitNode.relayPort}`;
|
||||
}
|
||||
|
||||
// Add site configuration to the array
|
||||
|
||||
@@ -289,7 +289,7 @@ export async function getOlmToken(
|
||||
let exitNodesHpData = allExitNodes.map((exitNode: ExitNode) => {
|
||||
return {
|
||||
publicKey: exitNode.publicKey,
|
||||
relayPort: config.getRawConfig().gerbil.clients_start_port,
|
||||
relayPort: exitNode.relayPort,
|
||||
endpoint: exitNode.endpoint,
|
||||
siteIds: exitNodeIdToSiteIds[exitNode.exitNodeId] ?? []
|
||||
};
|
||||
@@ -347,8 +347,7 @@ export async function getOlmToken(
|
||||
exitNodesHpData = [
|
||||
{
|
||||
publicKey: best.publicKey,
|
||||
relayPort:
|
||||
config.getRawConfig().gerbil.clients_start_port,
|
||||
relayPort: best.relayPort,
|
||||
endpoint: best.endpoint,
|
||||
siteIds: []
|
||||
// it should still HP without the site ids but it will get stuck in the client
|
||||
|
||||
@@ -4,7 +4,6 @@ import { clients, clientSitesAssociationsCache, Olm } from "@server/db";
|
||||
import { and, eq, inArray } from "drizzle-orm";
|
||||
import { updatePeersBatch } from "../newt/peers";
|
||||
import logger from "@server/logger";
|
||||
import config from "@server/lib/config";
|
||||
import { parseSiteChainBatch, resolveNewtIdsBySite } from "./batchUtils";
|
||||
|
||||
export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
||||
@@ -77,6 +76,7 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
||||
siteId: number;
|
||||
chainId?: string;
|
||||
relayEndpoint: string;
|
||||
relayPort: number;
|
||||
}[] = [];
|
||||
|
||||
for (let i = 0; i < siteIds.length; i++) {
|
||||
@@ -97,7 +97,8 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
||||
valid.push({
|
||||
siteId,
|
||||
chainId: chainIds[i],
|
||||
relayEndpoint: exitNode.endpoint
|
||||
relayEndpoint: exitNode.endpoint,
|
||||
relayPort: exitNode.relayPort
|
||||
});
|
||||
}
|
||||
|
||||
@@ -121,7 +122,9 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
||||
);
|
||||
|
||||
// Only ack sites we can actually tell their newt to relay for
|
||||
const newtIdBySiteId = await resolveNewtIdsBySite(valid.map((v) => v.siteId));
|
||||
const newtIdBySiteId = await resolveNewtIdsBySite(
|
||||
valid.map((v) => v.siteId)
|
||||
);
|
||||
const pushable = valid.filter((v) => {
|
||||
if (!newtIdBySiteId.has(v.siteId)) {
|
||||
logger.warn(`Newt not found for site ${v.siteId}`);
|
||||
@@ -144,8 +147,6 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
||||
}))
|
||||
);
|
||||
|
||||
const relayPort = config.getRawConfig().gerbil.clients_start_port;
|
||||
|
||||
if (isBatch) {
|
||||
return {
|
||||
message: {
|
||||
@@ -153,7 +154,7 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
||||
data: {
|
||||
siteIds: pushable.map((v) => v.siteId),
|
||||
relayEndpoints: pushable.map((v) => v.relayEndpoint),
|
||||
relayPort,
|
||||
relayPort: pushable.map((v) => v.relayPort),
|
||||
chainIds: pushable.map((v) => v.chainId)
|
||||
}
|
||||
},
|
||||
@@ -169,7 +170,7 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
||||
data: {
|
||||
siteId: single.siteId,
|
||||
relayEndpoint: single.relayEndpoint,
|
||||
relayPort,
|
||||
relayPort: single.relayPort,
|
||||
chainId: single.chainId
|
||||
}
|
||||
},
|
||||
|
||||
@@ -216,6 +216,7 @@ export const handleOlmServerInitAddPeerHandshake: MessageHandler = async (
|
||||
siteId: site.siteId,
|
||||
exitNode: {
|
||||
publicKey: exitNode.publicKey,
|
||||
relayPort: exitNode.relayPort,
|
||||
endpoint: exitNode.endpoint
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { sendToClient, sendToClientsBatch } from "#dynamic/routers/ws";
|
||||
import { clientSitesAssociationsCache, db, olms } from "@server/db";
|
||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
||||
import config from "@server/lib/config";
|
||||
import logger from "@server/logger";
|
||||
import { and, eq, inArray } from "drizzle-orm";
|
||||
import { Alias } from "yaml";
|
||||
@@ -155,6 +154,7 @@ export async function initPeerAddHandshake(
|
||||
siteId: number;
|
||||
exitNode: {
|
||||
publicKey: string;
|
||||
relayPort: number;
|
||||
endpoint: string;
|
||||
};
|
||||
},
|
||||
@@ -181,7 +181,7 @@ export async function initPeerAddHandshake(
|
||||
siteId: peer.siteId,
|
||||
exitNode: {
|
||||
publicKey: peer.exitNode.publicKey,
|
||||
relayPort: config.getRawConfig().gerbil.clients_start_port,
|
||||
relayPort: peer.exitNode.relayPort,
|
||||
endpoint: peer.exitNode.endpoint
|
||||
},
|
||||
chainId
|
||||
@@ -297,6 +297,7 @@ export async function initPeerAddHandshakeBatch(
|
||||
siteId: number;
|
||||
exitNode: {
|
||||
publicKey: string;
|
||||
relayPort: number;
|
||||
endpoint: string;
|
||||
};
|
||||
};
|
||||
@@ -317,8 +318,7 @@ export async function initPeerAddHandshakeBatch(
|
||||
siteId: item.peer.siteId,
|
||||
exitNode: {
|
||||
publicKey: item.peer.exitNode.publicKey,
|
||||
relayPort:
|
||||
config.getRawConfig().gerbil.clients_start_port,
|
||||
relayPort: item.peer.exitNode.relayPort,
|
||||
endpoint: item.peer.exitNode.endpoint
|
||||
},
|
||||
chainId: item.chainId
|
||||
|
||||
@@ -12,7 +12,6 @@ import { buildSiteConfigurationForOlmClient } from "./buildConfiguration";
|
||||
import { sendToClient } from "#dynamic/routers/ws";
|
||||
import logger from "@server/logger";
|
||||
import { count, eq, inArray } from "drizzle-orm";
|
||||
import config from "@server/lib/config";
|
||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
||||
import { build } from "@server/build";
|
||||
|
||||
@@ -125,7 +124,7 @@ export async function sendOlmSyncMessage(olm: Olm, client: Client) {
|
||||
exitNodesData = allExitNodes.map((exitNode) => {
|
||||
return {
|
||||
publicKey: exitNode.publicKey,
|
||||
relayPort: config.getRawConfig().gerbil.clients_start_port,
|
||||
relayPort: exitNode.relayPort,
|
||||
endpoint: exitNode.endpoint,
|
||||
siteIds: exitNodeIdToSiteIds[exitNode.exitNodeId] ?? []
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user