From 686604665395385600ef8f1b5238a775249552a1 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 23 May 2025 10:01:29 +0100 Subject: feat: only try http(s) for ngit-relays otherwise it tries all the protocols and reprots on each --- src/bin/git_remote_nostr/utils.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/bin/git_remote_nostr/utils.rs') diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs index 3a9f07d..2c77baa 100644 --- a/src/bin/git_remote_nostr/utils.rs +++ b/src/bin/git_remote_nostr/utils.rs @@ -216,8 +216,15 @@ pub fn get_read_protocols_to_try( git_repo: &Repo, server_url: &CloneUrl, decoded_nostr_url: &NostrUrlDecoded, + is_ngit_relay: bool, ) -> Vec { - if server_url.protocol() == ServerProtocol::Filesystem { + if is_ngit_relay { + if server_url.protocol() == ServerProtocol::Http { + vec![(ServerProtocol::UnauthHttp)] + } else { + vec![(ServerProtocol::UnauthHttps)] + } + } else if server_url.protocol() == ServerProtocol::Filesystem { vec![(ServerProtocol::Filesystem)] } else if let Some(protocol) = &decoded_nostr_url.protocol { vec![protocol.clone()] @@ -254,8 +261,15 @@ pub fn get_write_protocols_to_try( git_repo: &Repo, server_url: &CloneUrl, decoded_nostr_url: &NostrUrlDecoded, + is_ngit_relay: bool, ) -> Vec { - if server_url.protocol() == ServerProtocol::Filesystem { + if is_ngit_relay { + if server_url.protocol() == ServerProtocol::Http { + vec![(ServerProtocol::UnauthHttp)] + } else { + vec![(ServerProtocol::UnauthHttps)] + } + } else if server_url.protocol() == ServerProtocol::Filesystem { vec![(ServerProtocol::Filesystem)] } else if let Some(protocol) = &decoded_nostr_url.protocol { vec![protocol.clone()] -- cgit v1.2.3