Add increment options and slight cleanup

This commit is contained in:
Owen
2026-01-12 20:48:18 -08:00
parent 0ccd5714f9
commit eba25fcc4d
14 changed files with 92 additions and 53 deletions

View File

@@ -153,6 +153,6 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
}
},
broadcast: false,
excludeSender: false,
excludeSender: false
};
};

View File

@@ -110,7 +110,9 @@ export const handleNewtPingMessage: MessageHandler = async (context) => {
const configVersion = await getClientConfigVersion(newt.newtId);
if (message.configVersion && configVersion != message.configVersion) {
logger.warn(`Newt ping with outdated config version: ${message.configVersion} (current: ${configVersion})`);
logger.warn(
`Newt ping with outdated config version: ${message.configVersion} (current: ${configVersion})`
);
// TODO: sync the client
}

View File

@@ -39,7 +39,7 @@ export async function addPeer(
await sendToClient(newtId, {
type: "newt/wg/peer/add",
data: peer
}).catch((error) => {
}, { incrementConfigVersion: true }).catch((error) => {
logger.warn(`Error sending message:`, error);
});
@@ -81,7 +81,7 @@ export async function deletePeer(
data: {
publicKey
}
}).catch((error) => {
}, { incrementConfigVersion: true }).catch((error) => {
logger.warn(`Error sending message:`, error);
});
@@ -128,7 +128,7 @@ export async function updatePeer(
publicKey,
...peer
}
}).catch((error) => {
}, { incrementConfigVersion: true }).catch((error) => {
logger.warn(`Error sending message:`, error);
});

View File

@@ -5,7 +5,11 @@ import logger from "@server/logger";
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);
const siteConfigurations = await buildSiteConfigurationForOlmClient(
client,
client.pubKey,
false
);
await sendToClient(olm.olmId, {
type: "olm/sync",

View File

@@ -22,7 +22,7 @@ export async function addTargets(
data: {
targets: payloadTargets
}
});
}, { incrementConfigVersion: true });
// Create a map for quick lookup
const healthCheckMap = new Map<number, TargetHealthCheck>();
@@ -103,7 +103,7 @@ export async function addTargets(
data: {
targets: validHealthCheckTargets
}
});
}, { incrementConfigVersion: true });
}
export async function removeTargets(
@@ -124,7 +124,7 @@ export async function removeTargets(
data: {
targets: payloadTargets
}
});
}, { incrementConfigVersion: true });
const healthCheckTargets = targets.map((target) => {
return target.targetId;
@@ -135,5 +135,5 @@ export async function removeTargets(
data: {
ids: healthCheckTargets
}
});
}, { incrementConfigVersion: true });
}