Why Nostr? What is Njump?
2024-07-03 00:54:12

npub1qz…0pqql on Nostr: commit ce0338a76c70f9d74e496a4a0f14ff81bbb80503 Author: @RandyMcMillan ...

commit ce0338a76c70f9d74e496a4a0f14ff81bbb80503
Author: @RandyMcMillan <[email protected]>
Date: Tue Jan 9 09:32:49 2024 -0500

src/gnostr-set-relays.c:escaped bash -c command

CMakeLists.txt
gnostr.mk
src/gnostr-set-relays.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9936cc7ed..f9d785ef7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -121,8 +121,8 @@ add_dependencies(nostr configurator)

##TODO:rename to gnostr-get-relays
## once tools are stable
-add_executable(gnostr-get-relays-c src/gnostr-get-relays.c)
-add_executable(gnostr-set-relays-c src/gnostr-set-relays.c)
+add_executable(gnostr-get-relays src/gnostr-get-relays.c)
+add_executable(gnostr-set-relays src/gnostr-set-relays.c)

add_executable(gnostr-pi src/gnostr-pi.c)

@@ -152,8 +152,6 @@ install(PROGRAMS template/gnostr-proxy-test DESTINATION bin)
install(PROGRAMS template/gnostr-query DESTINATION bin)
install(PROGRAMS template/gnostr-relays DESTINATION bin)
install(PROGRAMS template/gnostr-send DESTINATION bin)
-install(PROGRAMS template/gnostr-set-relays DESTINATION bin)
-install(PROGRAMS template/gnostr-set-relays.c DESTINATION bin)
install(PROGRAMS template/gnostr-snapshot DESTINATION bin)
install(PROGRAMS template/gnostr-syndication DESTINATION bin)
install(PROGRAMS template/gnostr-syndication-test DESTINATION bin)
@@ -319,17 +317,17 @@ install(TARGETS gnostr-gnode
CONFIGURATIONS Release
RUNTIME DESTINATION /usr/local/bin)

-install(TARGETS gnostr-get-relays-c
+install(TARGETS gnostr-get-relays
CONFIGURATIONS Debug
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin)
-install(TARGETS gnostr-get-relays-c
+install(TARGETS gnostr-get-relays
CONFIGURATIONS Release
RUNTIME DESTINATION /usr/local/bin)

-install(TARGETS gnostr-set-relays-c
+install(TARGETS gnostr-set-relays
CONFIGURATIONS Debug
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin)
-install(TARGETS gnostr-set-relays-c
+install(TARGETS gnostr-set-relays
CONFIGURATIONS Release
RUNTIME DESTINATION /usr/local/bin)

@@ -354,17 +352,17 @@ install(TARGETS gnostr-req
CONFIGURATIONS Release
RUNTIME DESTINATION /usr/local/bin)

-install(TARGETS gnostr-get-relays-c
+install(TARGETS gnostr-get-relays
CONFIGURATIONS Debug
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin)
-install(TARGETS gnostr-get-relays-c
+install(TARGETS gnostr-get-relays
CONFIGURATIONS Release
RUNTIME DESTINATION /usr/local/bin)

-install(TARGETS gnostr-set-relays-c
+install(TARGETS gnostr-set-relays
CONFIGURATIONS Debug
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin)
-install(TARGETS gnostr-set-relays-c
+install(TARGETS gnostr-set-relays
CONFIGURATIONS Release
RUNTIME DESTINATION /usr/local/bin)

diff --git a/gnostr.mk b/gnostr.mk
index 6ca10ebb0..357375050 100644
--- a/gnostr.mk
+++ b/gnostr.mk
@@ -230,11 +230,11 @@ gnostr-git:deps/gnostr-git/gnostr-git## gnostr-git



-gnostr-get-relays:
- $(CC) ./src/gnostr-get-relays.c -o gnostr-get-relays
-
-gnostr-set-relays:
- $(CC) ./src/gnostr-set-relays.c -o gnostr-set-relays
+##gnostr-get-relays:
+## $(CC) ./src/gnostr-get-relays.c -o gnostr-get-relays
+##
+##gnostr-set-relays:
+## $(CC) ./src/gnostr-set-relays.c -o gnostr-set-relays


gnostr-cargo-binstall:
diff --git a/src/gnostr-set-relays.c b/src/gnostr-set-relays.c
index 971d26a48..25fff8cf4 100755
--- a/src/gnostr-set-relays.c
+++ b/src/gnostr-set-relays.c
@@ -3,8 +3,35 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#define QUOTE(name) #name
+#define STR(macro) QUOTE(macro)
+
+#ifndef TEST_FUN
+# define TEST_FUN some_func
+#endif
+
+#define TEST_FUN_NAME STR(TEST_FUN)
+
+void some_func(void)
+{
+ //char command[256];
+ //strcpy(command, "mkdir -p .gnostr && touch .gnostr/gnostr.relays && cat .gnostr/gnostr.relays | sed -e \'s/[{}]//g\' | sed -e \'s/\\[/\'\'/g\' | sed -e \'s/\\]/\'\'/g\' | sed -e \'s/\"//g\'");
+ //system(command);
+}
+
+void another_func(void)
+{
+ printf("do something else\n");
+}
+
+
int main(int argc, const char **argv) {

+
+ TEST_FUN();
+ //printf("TEST_FUN_NAME=%s\n", TEST_FUN_NAME);
+
// RELAYS=$(curl 'https://api.nostr.watch/v1/online'; 2>/dev/null |
// sed -e 's/[{}]/''/g' |
// sed -e 's/\[/''/g' |
@@ -15,17 +42,22 @@ int main(int argc, const char **argv) {


// https://man7.org/linux/man-pages/man3/popen.3.html
- char command[128];
+ char command[256];

strcpy(command, "mkdir -p .gnostr && touch .gnostr/gnostr.relays");
system(command);

- printf("RELAYS=$(curl 'https://api.nostr.watch/v1/online'; 2>/dev/null | sed -e 's/\[{}]/''/g' | sed -e 's/\[/''/g' | sed -e 's/]/''/g' | sed -e 's/\"//g') 2>/dev/null && echo $RELAYS; exit\");");
-
-
- strcpy(command, "curl -sS 'https://api.nostr.watch/v1/online'; > .gnostr/gnostr.relays");
+ strcpy(command, "bash -c \"gnostr-git config --global --replace-all gnostr.relays \'$(gnostr get-relays)\' && git config -l | grep gnostr.relays\"");
system(command);

+ //strcpy(command,"bash -c \"RELAYS=$(curl \'https://api.nostr.watch/v1/online\'; 2>/dev/null | sed -e \'s/[{}]/\'\'/g\' | sed -e \'s/\\[/\'\'/g\' | sed -e \'s/\\]/\'\'/g\' | sed -e \'s/\"//g\') 2>/dev/null && echo $RELAYS;\"");
+ //git config --global --unset-all gnostr.relays
+ //gnostr-git config --global --replace-all gnostr.relays \'\\$(gnostr get-relays)\' && git config -l | grep gnostr.relays
+ //strcpy(command, "curl -sS 'https://api.nostr.watch/v1/online'; > .gnostr/gnostr.relays");
+ //system(command);
+ //strcpy(command, "gnostr-git config --global --replace-all gnostr.relays \'\\$(gnostr get-relays)\' && git config -l | grep gnostr.relays");
+ //system(command);
+
FILE *fpipe;
//char *command = "ls";
char c = 0;
Author Public Key
npub1qzk8vvguukalkfsw4vdey90j25kp7gqgm9v00kwk8za92hg6tqmqx0pqql