-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: nostr
action: commit
revision:
path_from:
revision_from: 9e8fd8ab2db3355e599429afca61f8d2af6f4b39:
path_to:
revision_to:

git.thebackupbox.net

nostr

git://git.thebackupbox.net/nostr

commit 9e8fd8ab2db3355e599429afca61f8d2af6f4b39
Author: epoch <epoch@thebackupbox.net>
Date:   Fri Dec 15 12:10:20 2023 +0000

    nostr-relay is now open to any IP. actually sends an "OK" repsonse properly, and executes a relay-req for each filter

diff --git a/nostr-relay.sh b/nostr-relay.sh

index 28335e94613d471764e293e8632093073a676cd5..

index ..26310baff5a79201051050cc4339f4fc6ffebb86 100755

--- a/nostr-relay.sh
+++ b/nostr-relay.sh
@@ -3,10 +3,10 @@
 db=/var/db/nostr/relay

 printf '["NOTICE","hello, %s."]\n' "$REMOTE_ADDR"
-if [ "$REMOTE_ADDR" != "21.41.41.4" ];then
-	printf '["NOTICE","PLEASE DO NOT USE THIS SERVER. STILL BEING WORKED ON."]\n'
-	exit 0
-fi
+#if [ "$REMOTE_ADDR" != "21.41.41.4" ];then
+#	printf '["NOTICE","PLEASE DO NOT USE THIS SERVER. STILL BEING WORKED ON."]\n'
+#	exit 0
+#fi

 #i=0
 #while true;do
@@ -17,15 +17,17 @@ fi

 ### w00t. thank you https://stackoverflow.com/questions/41599314/ignore-unparseable-json-with-jq
 jq -Rnc 'inputs | fromjson?' | while read -r msg;do
-	logger -p crit "nostr-relay $$ msg: $msg"
+	logger -p crit "${REMOTE_URL}: nostr-relay $$ msg: $msg"
 	case "$(jq -r '.[0]//""' <<< "$msg")" in
 		EVENT)
-			if [ "$REMOTE_ADDR" != "21.41.41.4" ];then
-				printf '["NOTICE","DO NOT USE THIS SERVER. STILL BEING WORKED ON."]\n'
-				continue
-			fi
+			#if [ "$REMOTE_ADDR" != "21.41.41.4" ];then
+			#	printf '["NOTICE","DO NOT USE THIS SERVER. STILL BEING WORKED ON."]\n'
+			#	continue
+			#fi
                         printf '%s\n' "$msg" >> "${db}"
-			printf '["NOTICE","got an EVENT from you. :)"]\n'
+			### we need to be sending an OK event back.
+			event_id="$(jq -r '.[1].id' <<< "$msg")"
+			printf '["OK","%s",true,"I dunno."]\n' "${subid}"
                         ### TODO: validate event somehow
                         ### store this event somewhere
                 ;;
@@ -33,10 +35,12 @@ jq -Rnc 'inputs | fromjson?' | while read -r msg;do
 			### TODO: make the subid contain
                         subid="$(jq -r '.[1]' <<< "$msg")"
 			printf '["NOTICE","got a REQ from you. :)"]\n'
-			#filter="$(jq -r '.[2]' <<< "$msg")" ## only supporting one filter atm
-                        ### I figure we need to fork off a background process to keep a watch on incoming events from everywhere
-                        ### not sure how well we can CLOSE those though... kill %n based on job id?
-                        stdbuf -o0 /usr/local/libexec/nostr-relay-req.sh "$REMOTE_ADDR" "${subid}" "${filter}" & 2>/dev/null
+			### A REQ message may contain multiple filters.
+			jq -cn 'inputs | .[2:] | .[]' <<< "$msg" | while read -r filter;do
+	                        ### I figure we need to fork off a background process to keep a watch on incoming events from everywhere
+        	                ### not sure how well we can CLOSE those though... kill %n based on job id?
+	                        stdbuf -o0 /usr/local/libexec/nostr-relay-req.sh "$REMOTE_ADDR" "${subid}" "${filter}" & 2>/dev/null
+			done
                         ### oooooh.
                 ;;
 		CLOSE)

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 14:24:21 2024