mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-05 20:21:19 +02:00
Working on inference resource management
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Client,
|
||||
db,
|
||||
ExitNode,
|
||||
exitNodes,
|
||||
Olm,
|
||||
sites,
|
||||
@@ -48,12 +49,26 @@ export async function sendOlmSyncMessage(olm: Olm, client: Client) {
|
||||
}
|
||||
|
||||
// NOTE: WE ARE HARDCODING THE RELAY PARAMETER TO FALSE HERE BUT IN THE REGISTER MESSAGE ITS DEFINED BY THE CLIENT
|
||||
const siteConfigurations = await buildSiteConfigurationForOlmClient(
|
||||
client,
|
||||
client.pubKey,
|
||||
false,
|
||||
jitMode
|
||||
);
|
||||
const { siteConfigurations, exitNodeAliases } =
|
||||
await buildSiteConfigurationForOlmClient(
|
||||
client,
|
||||
client.pubKey,
|
||||
false,
|
||||
jitMode
|
||||
);
|
||||
|
||||
// The exit node the client itself is assigned to (for site resources hosted
|
||||
// on it, e.g. inference), same as what's sent in the initial olm/wg/connect
|
||||
// message. This is separate from exitNodesData below, which is only the set
|
||||
// of exit nodes used for hole punching to reach site peers.
|
||||
let clientExitNode: ExitNode | null = null;
|
||||
if (client.exitNodeId) {
|
||||
[clientExitNode] = await db
|
||||
.select()
|
||||
.from(exitNodes)
|
||||
.where(eq(exitNodes.exitNodeId, client.exitNodeId))
|
||||
.limit(1);
|
||||
}
|
||||
|
||||
// Get all exit nodes from sites where the client has peers
|
||||
const clientSites = await db
|
||||
@@ -113,11 +128,23 @@ export async function sendOlmSyncMessage(olm: Olm, client: Client) {
|
||||
type: "olm/sync",
|
||||
data: {
|
||||
sites: siteConfigurations,
|
||||
exitNodes: exitNodesData
|
||||
exitNodes: exitNodesData, // this is for the holepunch information
|
||||
// this is for the backhaul connection to the exit node
|
||||
exitNode:
|
||||
clientExitNode && client.exitNodeSubnet
|
||||
? {
|
||||
aliases: exitNodeAliases,
|
||||
connect: exitNodeAliases.length > 0, // we do not need to connect to the exit node if we do not have inference resources and right now all site resources on the exit node have an alias
|
||||
endpoint: `${clientExitNode.endpoint}:${clientExitNode.listenPort}`,
|
||||
publicKey: clientExitNode.publicKey,
|
||||
serverIP: clientExitNode.address.split("/")[0],
|
||||
tunnelIP: client.exitNodeSubnet.split("/")[0]
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
},
|
||||
{
|
||||
compress: canCompress(olm.version, "olm")
|
||||
compress: canCompress(olm.version, "olm") // we dont increment the version here or we could get into a loop!
|
||||
}
|
||||
).catch((error) => {
|
||||
logger.warn(`Error sending olm sync message:`, error);
|
||||
|
||||
Reference in New Issue
Block a user