mirror of
https://github.com/fosrl/pangolin.git
synced 2026-10-27 05:59:05 +01:00
Merge pull request #3870 from TiltedTeapot/fix-pass-relay-port-to-gerbil
Fix: pass relay port to gerbil
This commit is contained in:
@@ -460,6 +460,7 @@ export const exitNodes = pgTable("exitNodes", {
|
|||||||
endpoint: varchar("endpoint").notNull(),
|
endpoint: varchar("endpoint").notNull(),
|
||||||
publicKey: varchar("publicKey").notNull(),
|
publicKey: varchar("publicKey").notNull(),
|
||||||
listenPort: integer("listenPort").notNull(),
|
listenPort: integer("listenPort").notNull(),
|
||||||
|
relayPort: integer("relayPort").notNull(),
|
||||||
reachableAt: varchar("reachableAt"),
|
reachableAt: varchar("reachableAt"),
|
||||||
maxConnections: integer("maxConnections"),
|
maxConnections: integer("maxConnections"),
|
||||||
online: boolean("online").notNull().default(false),
|
online: boolean("online").notNull().default(false),
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ export const sites = sqliteTable(
|
|||||||
address: text("address"), // this is the address of the wireguard interface in newt
|
address: text("address"), // this is the address of the wireguard interface in newt
|
||||||
endpoint: text("endpoint"), // this is how to reach gerbil externally - gets put into the wireguard config
|
endpoint: text("endpoint"), // this is how to reach gerbil externally - gets put into the wireguard config
|
||||||
localEndpoints: text("localEndpoints"), // JSON encoded list of string ips on the local machine to try to connect to
|
localEndpoints: text("localEndpoints"), // JSON encoded list of string ips on the local machine to try to connect to
|
||||||
publicKey: text("publicKey"), // TODO: Fix typo in publicKey
|
publicKey: text("publicKey"),
|
||||||
lastHolePunch: integer("lastHolePunch"),
|
lastHolePunch: integer("lastHolePunch"),
|
||||||
listenPort: integer("listenPort"),
|
listenPort: integer("listenPort"),
|
||||||
dockerSocketEnabled: integer("dockerSocketEnabled", { mode: "boolean" })
|
dockerSocketEnabled: integer("dockerSocketEnabled", { mode: "boolean" })
|
||||||
@@ -481,6 +481,7 @@ export const exitNodes = sqliteTable("exitNodes", {
|
|||||||
endpoint: text("endpoint").notNull(), // this is how to reach gerbil externally - gets put into the wireguard config
|
endpoint: text("endpoint").notNull(), // this is how to reach gerbil externally - gets put into the wireguard config
|
||||||
publicKey: text("publicKey").notNull(),
|
publicKey: text("publicKey").notNull(),
|
||||||
listenPort: integer("listenPort").notNull(),
|
listenPort: integer("listenPort").notNull(),
|
||||||
|
relayPort: integer("relayPort").notNull(),
|
||||||
reachableAt: text("reachableAt"), // this is the internal address of the gerbil http server for command control
|
reachableAt: text("reachableAt"), // this is the internal address of the gerbil http server for command control
|
||||||
maxConnections: integer("maxConnections"),
|
maxConnections: integer("maxConnections"),
|
||||||
online: integer("online", { mode: "boolean" }).notNull().default(false),
|
online: integer("online", { mode: "boolean" }).notNull().default(false),
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export async function listExitNodes(
|
|||||||
endpoint: exitNodes.endpoint,
|
endpoint: exitNodes.endpoint,
|
||||||
publicKey: exitNodes.publicKey,
|
publicKey: exitNodes.publicKey,
|
||||||
listenPort: exitNodes.listenPort,
|
listenPort: exitNodes.listenPort,
|
||||||
|
relayPort: exitNodes.relayPort,
|
||||||
reachableAt: exitNodes.reachableAt,
|
reachableAt: exitNodes.reachableAt,
|
||||||
maxConnections: exitNodes.maxConnections,
|
maxConnections: exitNodes.maxConnections,
|
||||||
online: exitNodes.online,
|
online: exitNodes.online,
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import {
|
|||||||
import { sendToExitNode } from "#dynamic/lib/exitNodes";
|
import { sendToExitNode } from "#dynamic/lib/exitNodes";
|
||||||
import { sendToClientsBatch } from "#dynamic/routers/ws";
|
import { sendToClientsBatch } from "#dynamic/routers/ws";
|
||||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
import { canCompress } from "@server/lib/clientVersionChecks";
|
||||||
import config from "@server/lib/config";
|
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import {
|
import {
|
||||||
generateAliasConfig,
|
generateAliasConfig,
|
||||||
@@ -816,6 +815,7 @@ async function handleMessagesForSiteClients(
|
|||||||
siteId: number;
|
siteId: number;
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
|
relayPort: number;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -961,6 +961,7 @@ async function handleMessagesForSiteClients(
|
|||||||
siteId,
|
siteId,
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: exitNode.publicKey,
|
publicKey: exitNode.publicKey,
|
||||||
|
relayPort: exitNode.relayPort,
|
||||||
endpoint: exitNode.endpoint
|
endpoint: exitNode.endpoint
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1238,8 +1239,6 @@ async function syncClientExitNodeConnections(
|
|||||||
.map((r) => [r.clientId as number, r])
|
.map((r) => [r.clientId as number, r])
|
||||||
);
|
);
|
||||||
|
|
||||||
const relayPort = config.getRawConfig().gerbil.clients_start_port;
|
|
||||||
|
|
||||||
const connectPayloads: {
|
const connectPayloads: {
|
||||||
clientId: string;
|
clientId: string;
|
||||||
message: { type: string; data: any };
|
message: { type: string; data: any };
|
||||||
@@ -1278,7 +1277,7 @@ async function syncClientExitNodeConnections(
|
|||||||
data: {
|
data: {
|
||||||
connect: true,
|
connect: true,
|
||||||
endpoint: `${exitNode.endpoint}:${exitNode.listenPort}`,
|
endpoint: `${exitNode.endpoint}:${exitNode.listenPort}`,
|
||||||
relayPort,
|
relayPort: exitNode.relayPort,
|
||||||
publicKey: exitNode.publicKey,
|
publicKey: exitNode.publicKey,
|
||||||
serverIP: exitNode.address.split("/")[0],
|
serverIP: exitNode.address.split("/")[0],
|
||||||
tunnelIP: client.exitNodeSubnet.split("/")[0],
|
tunnelIP: client.exitNodeSubnet.split("/")[0],
|
||||||
@@ -2451,6 +2450,7 @@ async function handleMessagesForClientSites(
|
|||||||
siteId: number;
|
siteId: number;
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
|
relayPort: number;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -2550,6 +2550,7 @@ async function handleMessagesForClientSites(
|
|||||||
siteId: site.siteId,
|
siteId: site.siteId,
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: exitNode.publicKey,
|
publicKey: exitNode.publicKey,
|
||||||
|
relayPort: exitNode.relayPort,
|
||||||
endpoint: exitNode.endpoint
|
endpoint: exitNode.endpoint
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export async function createExitNode(
|
|||||||
// TODO: eventually we will want to get the next available port so that we can multiple exit nodes
|
// TODO: eventually we will want to get the next available port so that we can multiple exit nodes
|
||||||
// const listenPort = await getNextAvailablePort();
|
// const listenPort = await getNextAvailablePort();
|
||||||
const listenPort = config.getRawConfig().gerbil.start_port;
|
const listenPort = config.getRawConfig().gerbil.start_port;
|
||||||
|
const relayPort = config.getRawConfig().gerbil.clients_start_port;
|
||||||
|
|
||||||
const exitNodeName =
|
const exitNodeName =
|
||||||
config.getRawConfig().gerbil.exit_node_name ||
|
config.getRawConfig().gerbil.exit_node_name ||
|
||||||
@@ -49,6 +50,7 @@ export async function createExitNode(
|
|||||||
privateConfig.getRawPrivateConfig().app.region || null,
|
privateConfig.getRawPrivateConfig().app.region || null,
|
||||||
address,
|
address,
|
||||||
listenPort,
|
listenPort,
|
||||||
|
relayPort,
|
||||||
online: true,
|
online: true,
|
||||||
reachableAt,
|
reachableAt,
|
||||||
name: exitNodeName
|
name: exitNodeName
|
||||||
|
|||||||
@@ -201,10 +201,7 @@ export async function createRemoteExitNode(
|
|||||||
let releaseSubnetLock: (() => Promise<void>) | null = null;
|
let releaseSubnetLock: (() => Promise<void>) | null = null;
|
||||||
let newExitNodeAddress: string | null = null;
|
let newExitNodeAddress: string | null = null;
|
||||||
if (!existingExitNode) {
|
if (!existingExitNode) {
|
||||||
const { value, release } = await getNextAvailableSubnet(
|
const { value, release } = await getNextAvailableSubnet(db, orgId);
|
||||||
db,
|
|
||||||
orgId
|
|
||||||
);
|
|
||||||
newExitNodeAddress = value;
|
newExitNodeAddress = value;
|
||||||
releaseSubnetLock = release;
|
releaseSubnetLock = release;
|
||||||
}
|
}
|
||||||
@@ -220,6 +217,7 @@ export async function createRemoteExitNode(
|
|||||||
endpoint: "",
|
endpoint: "",
|
||||||
publicKey: "",
|
publicKey: "",
|
||||||
listenPort: 0,
|
listenPort: 0,
|
||||||
|
relayPort: 0,
|
||||||
online: false,
|
online: false,
|
||||||
type: "remoteExitNode"
|
type: "remoteExitNode"
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export async function createExitNode(
|
|||||||
const { value: address, release } = await getNextAvailableSubnet();
|
const { value: address, release } = await getNextAvailableSubnet();
|
||||||
try {
|
try {
|
||||||
const listenPort = config.getRawConfig().gerbil.start_port;
|
const listenPort = config.getRawConfig().gerbil.start_port;
|
||||||
|
const relayPort = config.getRawConfig().gerbil.clients_start_port;
|
||||||
|
|
||||||
const exitNodeName =
|
const exitNodeName =
|
||||||
config.getRawConfig().gerbil.exit_node_name ||
|
config.getRawConfig().gerbil.exit_node_name ||
|
||||||
@@ -30,6 +31,7 @@ export async function createExitNode(
|
|||||||
address,
|
address,
|
||||||
online: true,
|
online: true,
|
||||||
listenPort,
|
listenPort,
|
||||||
|
relayPort,
|
||||||
reachableAt,
|
reachableAt,
|
||||||
name: exitNodeName
|
name: exitNodeName
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const getConfigSchema = z.object({
|
|||||||
|
|
||||||
export type GetConfigResponse = {
|
export type GetConfigResponse = {
|
||||||
listenPort: number;
|
listenPort: number;
|
||||||
|
relayPort: number;
|
||||||
ipAddress: string;
|
ipAddress: string;
|
||||||
peers: {
|
peers: {
|
||||||
publicKey: string | null;
|
publicKey: string | null;
|
||||||
@@ -143,6 +144,7 @@ export async function generateGerbilConfig(exitNode: ExitNode) {
|
|||||||
|
|
||||||
const configResponse: GetConfigResponse = {
|
const configResponse: GetConfigResponse = {
|
||||||
listenPort: exitNode.listenPort || 51820,
|
listenPort: exitNode.listenPort || 51820,
|
||||||
|
relayPort: exitNode.relayPort || 21820,
|
||||||
ipAddress: exitNode.address,
|
ipAddress: exitNode.address,
|
||||||
peers
|
peers
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -96,7 +96,10 @@ export async function buildClientConfigurationForNewtClient(
|
|||||||
await updatePeer(client.clients.clientId, {
|
await updatePeer(client.clients.clientId, {
|
||||||
siteId: site.siteId,
|
siteId: site.siteId,
|
||||||
endpoint: site.endpoint!,
|
endpoint: site.endpoint!,
|
||||||
relayEndpoint: formatEndpoint(exitNode.endpoint, config.getRawConfig().gerbil.clients_start_port),
|
relayEndpoint: formatEndpoint(
|
||||||
|
exitNode.endpoint,
|
||||||
|
exitNode.relayPort
|
||||||
|
),
|
||||||
publicKey: site.publicKey!,
|
publicKey: site.publicKey!,
|
||||||
serverIP: site.address,
|
serverIP: site.address,
|
||||||
serverPort: site.listenPort
|
serverPort: site.listenPort
|
||||||
@@ -121,6 +124,7 @@ export async function buildClientConfigurationForNewtClient(
|
|||||||
siteId,
|
siteId,
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: exitNode.publicKey,
|
publicKey: exitNode.publicKey,
|
||||||
|
relayPort: exitNode.relayPort,
|
||||||
endpoint: exitNode.endpoint
|
endpoint: exitNode.endpoint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import {
|
|||||||
supportsCertReferences
|
supportsCertReferences
|
||||||
} from "@server/lib/clientVersionChecks";
|
} from "@server/lib/clientVersionChecks";
|
||||||
import { dedupeCertsForTargets } from "@server/lib/ip";
|
import { dedupeCertsForTargets } from "@server/lib/ip";
|
||||||
import config from "@server/lib/config";
|
|
||||||
import { waitForSiteRebuildIdle } from "@server/lib/rebuildClientAssociations";
|
import { waitForSiteRebuildIdle } from "@server/lib/rebuildClientAssociations";
|
||||||
|
|
||||||
export const handleNewtGetConfigMessage: MessageHandler = async (context) => {
|
export const handleNewtGetConfigMessage: MessageHandler = async (context) => {
|
||||||
@@ -61,7 +60,7 @@ export const handleNewtGetConfigMessage: MessageHandler = async (context) => {
|
|||||||
|
|
||||||
if (existingSite.lastHolePunch && now - existingSite.lastHolePunch > 12) {
|
if (existingSite.lastHolePunch && now - existingSite.lastHolePunch > 12) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Site last hole punch is too old; skipping this register. The site is failing to hole punch and identify its network address with the server. Can the site reach the server on UDP port ${config.getRawConfig().gerbil.clients_start_port}?`
|
`Site last hole punch is too old; skipping this register. The site is failing to hole punch and identify its network address with the server. Can the site reach the server on its Relay UDP port?`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {
|
|||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { and, eq, inArray } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
import { addPeer, deletePeer } from "../newt/peers";
|
import { addPeer, deletePeer } from "../newt/peers";
|
||||||
import config from "@server/lib/config";
|
|
||||||
import { SiR } from "react-icons/si";
|
import { SiR } from "react-icons/si";
|
||||||
|
|
||||||
export async function buildSiteConfigurationForOlmClient(
|
export async function buildSiteConfigurationForOlmClient(
|
||||||
@@ -129,7 +128,6 @@ export async function buildSiteConfigurationForOlmClient(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const clientsStartPort = config.getRawConfig().gerbil.clients_start_port;
|
|
||||||
const peerOps: Promise<unknown>[] = [];
|
const peerOps: Promise<unknown>[] = [];
|
||||||
|
|
||||||
// Process each site
|
// Process each site
|
||||||
@@ -216,7 +214,7 @@ export async function buildSiteConfigurationForOlmClient(
|
|||||||
logger.warn(`Exit node not found for site ${site.siteId}`);
|
logger.warn(`Exit node not found for site ${site.siteId}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
relayEndpoint = `${exitNode.endpoint}:${clientsStartPort}`;
|
relayEndpoint = `${exitNode.endpoint}:${exitNode.relayPort}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add site configuration to the array
|
// Add site configuration to the array
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import { sendToClient } from "#dynamic/routers/ws";
|
import { sendToClient } from "#dynamic/routers/ws";
|
||||||
import config from "@server/lib/config";
|
|
||||||
|
|
||||||
const udpPort = config.getRawConfig().gerbil.clients_start_port;
|
|
||||||
|
|
||||||
// Error codes for registration failures
|
// Error codes for registration failures
|
||||||
export const OlmErrorCodes = {
|
export const OlmErrorCodes = {
|
||||||
@@ -93,7 +90,7 @@ export const OlmErrorCodes = {
|
|||||||
},
|
},
|
||||||
HOLEPUNCH_MISSING: {
|
HOLEPUNCH_MISSING: {
|
||||||
code: "HOLEPUNCH_MISSING",
|
code: "HOLEPUNCH_MISSING",
|
||||||
message: `Unable to coordinate client P2P connection. Please ensure your client can reach the server on UDP port ${udpPort} and try registering again.`
|
message: `Unable to coordinate client P2P connection. Please ensure your client can reach the server on its relay UDP port and try registering again.`
|
||||||
},
|
},
|
||||||
NO_AVAILABLE_SUBNET: {
|
NO_AVAILABLE_SUBNET: {
|
||||||
code: "NO_AVAILABLE_SUBNET",
|
code: "NO_AVAILABLE_SUBNET",
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ export async function getOlmToken(
|
|||||||
let exitNodesHpData = allExitNodes.map((exitNode: ExitNode) => {
|
let exitNodesHpData = allExitNodes.map((exitNode: ExitNode) => {
|
||||||
return {
|
return {
|
||||||
publicKey: exitNode.publicKey,
|
publicKey: exitNode.publicKey,
|
||||||
relayPort: config.getRawConfig().gerbil.clients_start_port,
|
relayPort: exitNode.relayPort,
|
||||||
endpoint: exitNode.endpoint,
|
endpoint: exitNode.endpoint,
|
||||||
siteIds: exitNodeIdToSiteIds[exitNode.exitNodeId] ?? []
|
siteIds: exitNodeIdToSiteIds[exitNode.exitNodeId] ?? []
|
||||||
};
|
};
|
||||||
@@ -347,8 +347,7 @@ export async function getOlmToken(
|
|||||||
exitNodesHpData = [
|
exitNodesHpData = [
|
||||||
{
|
{
|
||||||
publicKey: best.publicKey,
|
publicKey: best.publicKey,
|
||||||
relayPort:
|
relayPort: best.relayPort,
|
||||||
config.getRawConfig().gerbil.clients_start_port,
|
|
||||||
endpoint: best.endpoint,
|
endpoint: best.endpoint,
|
||||||
siteIds: []
|
siteIds: []
|
||||||
// it should still HP without the site ids but it will get stuck in the client
|
// it should still HP without the site ids but it will get stuck in the client
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import { OlmErrorCodes, sendOlmError } from "./error";
|
|||||||
import { handleFingerprintInsertion } from "./fingerprintingUtils";
|
import { handleFingerprintInsertion } from "./fingerprintingUtils";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
import { canCompress } from "@server/lib/clientVersionChecks";
|
||||||
import config from "@server/lib/config";
|
|
||||||
import cache from "#dynamic/lib/cache"; // not using regional here because we need this in the register message handler before we know where the client is
|
import cache from "#dynamic/lib/cache"; // not using regional here because we need this in the register message handler before we know where the client is
|
||||||
import { waitForClientRebuildIdle } from "@server/lib/rebuildClientAssociations";
|
import { waitForClientRebuildIdle } from "@server/lib/rebuildClientAssociations";
|
||||||
import {
|
import {
|
||||||
@@ -438,7 +437,7 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => {
|
|||||||
// TODO: I still think there is a better way to do this rather than locking it out here but ???
|
// TODO: I still think there is a better way to do this rather than locking it out here but ???
|
||||||
if (now - (client.lastHolePunch || 0) > 12 && sitesCount > 0) {
|
if (now - (client.lastHolePunch || 0) > 12 && sitesCount > 0) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`[handleOlmRegisterMessage] Client last hole punch is too old and we have sites to send; skipping this register. The client is failing to hole punch and identify its network address with the server. Can the client reach the server on UDP port ${config.getRawConfig().gerbil.clients_start_port}?`,
|
`[handleOlmRegisterMessage] Client last hole punch is too old and we have sites to send; skipping this register. The client is failing to hole punch and identify its network address with the server. Can the client reach the server on its relay UDP port?`,
|
||||||
{ orgId: client.orgId, clientId: client.clientId }
|
{ orgId: client.orgId, clientId: client.clientId }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { clients, clientSitesAssociationsCache, Olm } from "@server/db";
|
|||||||
import { and, eq, inArray } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
import { updatePeersBatch } from "../newt/peers";
|
import { updatePeersBatch } from "../newt/peers";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import config from "@server/lib/config";
|
|
||||||
import { parseSiteChainBatch, resolveNewtIdsBySite } from "./batchUtils";
|
import { parseSiteChainBatch, resolveNewtIdsBySite } from "./batchUtils";
|
||||||
|
|
||||||
export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
||||||
@@ -77,6 +76,7 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
|||||||
siteId: number;
|
siteId: number;
|
||||||
chainId?: string;
|
chainId?: string;
|
||||||
relayEndpoint: string;
|
relayEndpoint: string;
|
||||||
|
relayPort: number;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
for (let i = 0; i < siteIds.length; i++) {
|
for (let i = 0; i < siteIds.length; i++) {
|
||||||
@@ -97,7 +97,8 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
|||||||
valid.push({
|
valid.push({
|
||||||
siteId,
|
siteId,
|
||||||
chainId: chainIds[i],
|
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
|
// 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) => {
|
const pushable = valid.filter((v) => {
|
||||||
if (!newtIdBySiteId.has(v.siteId)) {
|
if (!newtIdBySiteId.has(v.siteId)) {
|
||||||
logger.warn(`Newt not found for site ${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) {
|
if (isBatch) {
|
||||||
return {
|
return {
|
||||||
message: {
|
message: {
|
||||||
@@ -153,7 +154,7 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
|||||||
data: {
|
data: {
|
||||||
siteIds: pushable.map((v) => v.siteId),
|
siteIds: pushable.map((v) => v.siteId),
|
||||||
relayEndpoints: pushable.map((v) => v.relayEndpoint),
|
relayEndpoints: pushable.map((v) => v.relayEndpoint),
|
||||||
relayPort,
|
relayPort: pushable.map((v) => v.relayPort),
|
||||||
chainIds: pushable.map((v) => v.chainId)
|
chainIds: pushable.map((v) => v.chainId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -169,7 +170,7 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
|||||||
data: {
|
data: {
|
||||||
siteId: single.siteId,
|
siteId: single.siteId,
|
||||||
relayEndpoint: single.relayEndpoint,
|
relayEndpoint: single.relayEndpoint,
|
||||||
relayPort,
|
relayPort: single.relayPort,
|
||||||
chainId: single.chainId
|
chainId: single.chainId
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ export const handleOlmServerInitAddPeerHandshake: MessageHandler = async (
|
|||||||
siteId: site.siteId,
|
siteId: site.siteId,
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: exitNode.publicKey,
|
publicKey: exitNode.publicKey,
|
||||||
|
relayPort: exitNode.relayPort,
|
||||||
endpoint: exitNode.endpoint
|
endpoint: exitNode.endpoint
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { sendToClient, sendToClientsBatch } from "#dynamic/routers/ws";
|
import { sendToClient, sendToClientsBatch } from "#dynamic/routers/ws";
|
||||||
import { clientSitesAssociationsCache, db, olms } from "@server/db";
|
import { clientSitesAssociationsCache, db, olms } from "@server/db";
|
||||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
import { canCompress } from "@server/lib/clientVersionChecks";
|
||||||
import config from "@server/lib/config";
|
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { and, eq, inArray } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
import { Alias } from "yaml";
|
import { Alias } from "yaml";
|
||||||
@@ -155,6 +154,7 @@ export async function initPeerAddHandshake(
|
|||||||
siteId: number;
|
siteId: number;
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
|
relayPort: number;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -181,7 +181,7 @@ export async function initPeerAddHandshake(
|
|||||||
siteId: peer.siteId,
|
siteId: peer.siteId,
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: peer.exitNode.publicKey,
|
publicKey: peer.exitNode.publicKey,
|
||||||
relayPort: config.getRawConfig().gerbil.clients_start_port,
|
relayPort: peer.exitNode.relayPort,
|
||||||
endpoint: peer.exitNode.endpoint
|
endpoint: peer.exitNode.endpoint
|
||||||
},
|
},
|
||||||
chainId
|
chainId
|
||||||
@@ -297,6 +297,7 @@ export async function initPeerAddHandshakeBatch(
|
|||||||
siteId: number;
|
siteId: number;
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: string;
|
publicKey: string;
|
||||||
|
relayPort: number;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -317,8 +318,7 @@ export async function initPeerAddHandshakeBatch(
|
|||||||
siteId: item.peer.siteId,
|
siteId: item.peer.siteId,
|
||||||
exitNode: {
|
exitNode: {
|
||||||
publicKey: item.peer.exitNode.publicKey,
|
publicKey: item.peer.exitNode.publicKey,
|
||||||
relayPort:
|
relayPort: item.peer.exitNode.relayPort,
|
||||||
config.getRawConfig().gerbil.clients_start_port,
|
|
||||||
endpoint: item.peer.exitNode.endpoint
|
endpoint: item.peer.exitNode.endpoint
|
||||||
},
|
},
|
||||||
chainId: item.chainId
|
chainId: item.chainId
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import { buildSiteConfigurationForOlmClient } from "./buildConfiguration";
|
|||||||
import { sendToClient } from "#dynamic/routers/ws";
|
import { sendToClient } from "#dynamic/routers/ws";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { count, eq, inArray } from "drizzle-orm";
|
import { count, eq, inArray } from "drizzle-orm";
|
||||||
import config from "@server/lib/config";
|
|
||||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
import { canCompress } from "@server/lib/clientVersionChecks";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
|
|
||||||
@@ -125,7 +124,7 @@ export async function sendOlmSyncMessage(olm: Olm, client: Client) {
|
|||||||
exitNodesData = allExitNodes.map((exitNode) => {
|
exitNodesData = allExitNodes.map((exitNode) => {
|
||||||
return {
|
return {
|
||||||
publicKey: exitNode.publicKey,
|
publicKey: exitNode.publicKey,
|
||||||
relayPort: config.getRawConfig().gerbil.clients_start_port,
|
relayPort: exitNode.relayPort,
|
||||||
endpoint: exitNode.endpoint,
|
endpoint: exitNode.endpoint,
|
||||||
siteIds: exitNodeIdToSiteIds[exitNode.exitNodeId] ?? []
|
siteIds: exitNodeIdToSiteIds[exitNode.exitNodeId] ?? []
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export async function copyInConfig() {
|
|||||||
|
|
||||||
const endpoint = config.getRawConfig().gerbil.base_endpoint;
|
const endpoint = config.getRawConfig().gerbil.base_endpoint;
|
||||||
const listenPort = config.getRawConfig().gerbil.start_port;
|
const listenPort = config.getRawConfig().gerbil.start_port;
|
||||||
|
const relayPort = config.getRawConfig().gerbil.clients_start_port;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!config.getRawConfig().flags?.disable_config_managed_domains &&
|
!config.getRawConfig().flags?.disable_config_managed_domains &&
|
||||||
@@ -23,7 +24,7 @@ export async function copyInConfig() {
|
|||||||
if (exitNodeName) {
|
if (exitNodeName) {
|
||||||
await db
|
await db
|
||||||
.update(exitNodes)
|
.update(exitNodes)
|
||||||
.set({ endpoint, listenPort })
|
.set({ endpoint, listenPort, relayPort })
|
||||||
.where(eq(exitNodes.name, exitNodeName));
|
.where(eq(exitNodes.name, exitNodeName));
|
||||||
} else {
|
} else {
|
||||||
await db
|
await db
|
||||||
@@ -34,6 +35,10 @@ export async function copyInConfig() {
|
|||||||
.update(exitNodes)
|
.update(exitNodes)
|
||||||
.set({ listenPort })
|
.set({ listenPort })
|
||||||
.where(ne(exitNodes.listenPort, listenPort));
|
.where(ne(exitNodes.listenPort, listenPort));
|
||||||
|
await db
|
||||||
|
.update(exitNodes)
|
||||||
|
.set({ relayPort })
|
||||||
|
.where(ne(exitNodes.relayPort, relayPort));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user