avoid loop between cluster gateways

The VIA extension is still needed to avoid some extra work and ugly
messages, but this is enough that it actually works.

This filters out the RemoteSides that are a proxied connection via a
remote gateway to the cluster.

The VIA extension will not filter those out, but will send VIA to them
on connect, which will cause the ones that are accessed via the listed
gateways to be filtered out.
This commit is contained in:
Joey Hess 2024-06-26 15:27:16 -04:00
parent 4172109c8d
commit effaf51b1f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 12 additions and 7 deletions

View file

@ -96,8 +96,8 @@ clusterProxySelector clusteruuid protocolversion = do
where
-- Nodes of the cluster have remote.name.annex-cluster-node
-- containing its name. Or they are proxied by a remote
-- that has remote.name.annex-cluster-node containing the cluster's
-- UUID.
-- that has remote.name.annex-cluster-gateway
-- containing the cluster's UUID.
isnode rs nodeuuids clusternames r =
case remoteAnnexClusterNode (Remote.gitconfig r) of
Just names
@ -106,11 +106,13 @@ clusterProxySelector clusteruuid protocolversion = do
ClusterNodeUUID $ Remote.uuid r
| otherwise -> False
Nothing -> case remoteAnnexProxiedBy (Remote.gitconfig r) of
Just proxyuuid -> not $ null $
filter (== clusteruuid) $
concatMap (remoteAnnexClusterGateway . Remote.gitconfig) $
filter (\p -> Remote.uuid p == proxyuuid) rs
Nothing -> False
Just proxyuuid
| Remote.uuid r /= fromClusterUUID clusteruuid ->
not $ null $
filter (== clusteruuid) $
concatMap (remoteAnnexClusterGateway . Remote.gitconfig) $
filter (\p -> Remote.uuid p == proxyuuid) rs
_ -> False
isclustername clusternames name =
M.lookup name clusternames == Just clusteruuid