Public Access
Merge origin/main into claude/spelunk-tunnel
Port forwarding took host schema version 8 first, so the Spelunk route moves to 9 and is written after the forwards. A host may carry both.
This commit is contained in:
commit
689ba6c1bf
44 files changed
+3187
-75
No files matched your search
@@ -99,6 +99,8 @@ public static class HostSecretMerge
|
||||
TagIds = MergeTags(ancestor.TagIds, local.TagIds, remote.TagIds, conflicts),
|
||||
PinnedPaths = MergePinnedPaths(
|
||||
ancestor.PinnedPaths, local.PinnedPaths, remote.PinnedPaths, conflicts),
|
||||
PortForwards = MergePortForwards(
|
||||
ancestor.PortForwards, local.PortForwards, remote.PortForwards, conflicts),
|
||||
RelayEnabled = Field(
|
||||
nameof(HostSecret.RelayEnabled),
|
||||
ancestor.RelayEnabled,
|
||||
@@ -354,6 +356,46 @@ public static class HostSecretMerge
|
||||
return PinnedPathList.Create(merge.Merged.Keys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges the forwards per forward, so two people each adding one both keep theirs.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Keyed by id and ordered the way <see cref="MergePinnedPaths"/> is: existing forwards, then this
|
||||
/// machine's additions, then the server's.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <b>Unlike a tag or a pinned path, a conflict is reachable here.</b> The value under a key is the whole
|
||||
/// rule, so two machines changing one forward differently is a genuine clash. The server's version wins,
|
||||
/// as every scalar's does, and the other is recorded in OpenSSH's notation so the user can read what was
|
||||
/// lost. An edit on one side beats a removal on the other, which is the map merge's standing rule.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
private static PortForwardList MergePortForwards(
|
||||
PortForwardList ancestor,
|
||||
PortForwardList local,
|
||||
PortForwardList remote,
|
||||
List<HostFieldConflict> conflicts)
|
||||
{
|
||||
var merge = ThreeWayMerge.Map(
|
||||
ancestor.ToIdMap(),
|
||||
local.ToIdMap(),
|
||||
remote.ToIdMap(),
|
||||
EqualityComparer<Guid>.Default);
|
||||
|
||||
foreach (var conflict in merge.Conflicts)
|
||||
{
|
||||
conflicts.Add(new HostFieldConflict(
|
||||
$"{nameof(HostSecret.PortForwards)}[{conflict.Key}]",
|
||||
conflict.DiscardedSide,
|
||||
conflict.Kept?.Notation ?? "removed",
|
||||
conflict.Discarded?.Notation ?? "removed",
|
||||
conflict.DiscardedWasRemoval));
|
||||
}
|
||||
|
||||
return PortForwardList.Create(merge.Merged.Values);
|
||||
}
|
||||
|
||||
private static string FormatChain(JumpChain chain) =>
|
||||
chain.Count == 0 ? "(none)" : string.Join(" → ", chain);
|
||||
}
|
||||
Reference in new issue
Block a user