upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr/utils.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-05-23 10:01:29 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-05-23 10:01:29 +0100
commit686604665395385600ef8f1b5238a775249552a1 (patch)
tree56a4c7a956e14dfbcdd4a518096968abc69583a6 /src/bin/git_remote_nostr/utils.rs
parentcc9a3a1d8526373625246504f72f338fd89c8d8b (diff)
feat: only try http(s) for ngit-relays
otherwise it tries all the protocols and reprots on each
Diffstat (limited to 'src/bin/git_remote_nostr/utils.rs')
-rw-r--r--src/bin/git_remote_nostr/utils.rs18
1 files changed, 16 insertions, 2 deletions
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(
216 git_repo: &Repo, 216 git_repo: &Repo,
217 server_url: &CloneUrl, 217 server_url: &CloneUrl,
218 decoded_nostr_url: &NostrUrlDecoded, 218 decoded_nostr_url: &NostrUrlDecoded,
219 is_ngit_relay: bool,
219) -> Vec<ServerProtocol> { 220) -> Vec<ServerProtocol> {
220 if server_url.protocol() == ServerProtocol::Filesystem { 221 if is_ngit_relay {
222 if server_url.protocol() == ServerProtocol::Http {
223 vec![(ServerProtocol::UnauthHttp)]
224 } else {
225 vec![(ServerProtocol::UnauthHttps)]
226 }
227 } else if server_url.protocol() == ServerProtocol::Filesystem {
221 vec![(ServerProtocol::Filesystem)] 228 vec![(ServerProtocol::Filesystem)]
222 } else if let Some(protocol) = &decoded_nostr_url.protocol { 229 } else if let Some(protocol) = &decoded_nostr_url.protocol {
223 vec![protocol.clone()] 230 vec![protocol.clone()]
@@ -254,8 +261,15 @@ pub fn get_write_protocols_to_try(
254 git_repo: &Repo, 261 git_repo: &Repo,
255 server_url: &CloneUrl, 262 server_url: &CloneUrl,
256 decoded_nostr_url: &NostrUrlDecoded, 263 decoded_nostr_url: &NostrUrlDecoded,
264 is_ngit_relay: bool,
257) -> Vec<ServerProtocol> { 265) -> Vec<ServerProtocol> {
258 if server_url.protocol() == ServerProtocol::Filesystem { 266 if is_ngit_relay {
267 if server_url.protocol() == ServerProtocol::Http {
268 vec![(ServerProtocol::UnauthHttp)]
269 } else {
270 vec![(ServerProtocol::UnauthHttps)]
271 }
272 } else if server_url.protocol() == ServerProtocol::Filesystem {
259 vec![(ServerProtocol::Filesystem)] 273 vec![(ServerProtocol::Filesystem)]
260 } else if let Some(protocol) = &decoded_nostr_url.protocol { 274 } else if let Some(protocol) = &decoded_nostr_url.protocol {
261 vec![protocol.clone()] 275 vec![protocol.clone()]