diff --git a/src/features/P2PSync/P2PReplicator/P2PServerStatusCard.svelte b/src/features/P2PSync/P2PReplicator/P2PServerStatusCard.svelte index 4d53651..0d8aad6 100644 --- a/src/features/P2PSync/P2PReplicator/P2PServerStatusCard.svelte +++ b/src/features/P2PSync/P2PReplicator/P2PServerStatusCard.svelte @@ -24,6 +24,7 @@ let serverInfo = $state(undefined); let replicatorStatus = $state(undefined); let roomSuffix = $state(extractP2PRoomSuffix(core?.services.setting.currentSettings()?.P2P_roomID ?? "")); + let useDiagRTC = $state(core?.services.setting.currentSettings()?.P2P_useDiagRTC ?? false); async function requestServerStatus() { await Promise.resolve(liveSyncReplicator.requestStatus()); @@ -48,6 +49,18 @@ } } + async function toggleDiagRTC() { + if (!core) { + return; + } + const next = !useDiagRTC; + await core.services.setting.updateSettings((settings) => { + settings.P2P_useDiagRTC = next; + return settings; + }, true); + useDiagRTC = next; + } + onMount(() => { const unsubscribe = eventHub.onEvent(EVENT_SERVER_STATUS, (status) => { serverInfo = status; @@ -58,6 +71,7 @@ }); const unsubscribeSettings = eventHub.onEvent(EVENT_SETTING_SAVED, (settings) => { roomSuffix = extractP2PRoomSuffix(settings?.P2P_roomID ?? ""); + useDiagRTC = settings?.P2P_useDiagRTC ?? false; }); fireAndForget(async () => { @@ -131,6 +145,48 @@ {/if} + + {#if core} +
+ + +
+ {/if} + + {#if serverInfo} +
+

Stats

+
+
+ Incoming: + {serverInfo.diag.totalNewConnections} +
+
+ Connected: + {serverInfo.diag.totalSuccessfulConnections} +
+
+ Failed: + {serverInfo.diag.totalFailedConnections} +
+
+ Closed: + {serverInfo.diag.totalClosedConnections} +
+
+
+ {/if} \ No newline at end of file diff --git a/src/lib b/src/lib index b9aaf3c..e97ca58 160000 --- a/src/lib +++ b/src/lib @@ -1 +1 @@ -Subproject commit b9aaf3c03a773cf54887da5826e52774239106b9 +Subproject commit e97ca5821c6fd50b22e63acbbc0f936e0ac8391a diff --git a/src/modules/features/SetupManager.ts b/src/modules/features/SetupManager.ts index 1bd40be..3d69968 100644 --- a/src/modules/features/SetupManager.ts +++ b/src/modules/features/SetupManager.ts @@ -7,7 +7,7 @@ import { REMOTE_MINIO, REMOTE_P2P, } from "../../lib/src/common/types.ts"; -import { generatePatchObj, isObjectDifferent } from "../../lib/src/common/utils.ts"; +import { isObjectDifferent } from "@lib/common/utils.ts"; import Intro from "./SetupWizard/dialogs/Intro.svelte"; import SelectMethodNewUser from "./SetupWizard/dialogs/SelectMethodNewUser.svelte"; import SelectMethodExisting from "./SetupWizard/dialogs/SelectMethodExisting.svelte"; @@ -23,6 +23,7 @@ import SetupRemoteP2P from "./SetupWizard/dialogs/SetupRemoteP2P.svelte"; import SetupRemoteE2EE from "./SetupWizard/dialogs/SetupRemoteE2EE.svelte"; import { decodeSettingsFromQRCodeData } from "../../lib/src/API/processSetting.ts"; import { AbstractModule } from "../AbstractModule.ts"; +import { ConnectionStringParser } from "@lib/common/ConnectionString.ts"; /** * User modes for onboarding and setup @@ -194,8 +195,24 @@ export class SetupManager extends AbstractModule { return await this.onOnboard(userMode); } const newSetting = { ...currentSetting, ...p2pConf } as ObsidianLiveSyncSettings; + // Apply remoteConfigurations + if (newSetting.P2P_ActiveRemoteConfigurationId) { + const id = newSetting.P2P_ActiveRemoteConfigurationId; + const merged = { + ...newSetting, + ...p2pConf, + } as ObsidianLiveSyncSettings; + const uri = ConnectionStringParser.serialize({ type: "p2p", settings: merged }); + newSetting.remoteConfigurations[id] = { + ...newSetting.remoteConfigurations[id], + uri, + isEncrypted: false, + }; + newSetting.P2P_ActiveRemoteConfigurationId = id; + } if (activate) { newSetting.remoteType = REMOTE_P2P; + newSetting.activeConfigurationId = newSetting.P2P_ActiveRemoteConfigurationId; } return await this.onConfirmApplySettingsFromWizard(newSetting, userMode, activate); } @@ -285,9 +302,9 @@ export class SetupManager extends AbstractModule { this._log("No changes in settings detected. Skipping applying settings from wizard.", LOG_LEVEL_NOTICE); return true; } - const patch = generatePatchObj(this.settings, newConf); - console.log(`Changes:`); - console.dir(patch); + // const patch = generatePatchObj(this.settings, newConf); + // console.log(`Changes:`); + // console.dir(patch); if (!activate) { extra(); await this.applySetting(newConf, UserMode.ExistingUser); diff --git a/updates.md b/updates.md index 6bedf71..e3d0c62 100644 --- a/updates.md +++ b/updates.md @@ -3,6 +3,18 @@ Since 19th July, 2025 (beta1 in 0.25.0-beta1, 13th July, 2025) The head note of 0.25 is now in [updates_old.md](https://github.com/vrtmrz/obsidian-livesync/blob/main/updates_old.md). Because 0.25 got a lot of updates, thankfully, compatibility is kept and we do not need breaking changes! In other words, when get enough stabled. The next version will be v1.0.0. Even though it my hope. +## Unreleased + +22nd May, 2026 + +### Fixed +- No longer the P2P passphrase mismatch causes a server shutdown. +- Settings related to P2P synchronisation are now correctly applied on start-up and no longer reverted. + +### New features +- Diagnostic P2P connection stats are now available. + - These stats indicate the number of connection trials, successes, and, failures. + ## 0.25.68 22nd May, 2026