diff --git a/README.md b/README.md index 4166274..08a9da7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ A relay based on [Khatru](https://github.com/fiatjaf/khatru) with a invite hiera ### Deploy with docker -1. create and manually add a pubkey to users.json: `touch users.json && echo '{"your nostr hex pubkey":""}' > users.json` -2. deploy with docker: `docker run -p 3334:3334 -v ./users.json:/app/users.json -v ./db:/app/db -e DOMAIN=yourdomain.example.com -e RELAY_NAME="your relay name" -e RELAY_PUBKEY="your nostr hex pubkey" tijlxyz/khatru-pyramid:latest` +``` +docker run \ + -p 3334:3334 \ + -v ./users.json:/app/users.json \ + -v ./db:/app/db \ + -e DOMAIN=yourdomain.example.com \ + -e RELAY_NAME="your relay name" \ + -e RELAY_PUBKEY="your nostr hex pubkey" \ + tijlxyz/khatru-pyramid:latest +``` diff --git a/example.env b/example.env index a2bf629..6817aa3 100644 --- a/example.env +++ b/example.env @@ -1,4 +1,3 @@ - # Server Settings DOMAIN="example.com" PORT="3334" # optional diff --git a/whitelist.go b/whitelist.go index b445525..607f333 100644 --- a/whitelist.go +++ b/whitelist.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "errors" "fmt" "os" @@ -89,7 +90,20 @@ func removeDescendantsFromWhitelist(ancestor string) { func loadWhitelist() error { b, err := os.ReadFile(s.UserdataPath) if err != nil { - return err + // If the whitelist file does not exist, with RELAY_PUBKEY + if errors.Is(err, os.ErrNotExist) { + whitelist[s.RelayPubkey] = "" + jsonBytes, err := json.Marshal(&whitelist) + if err != nil { + return err + } + if err := os.WriteFile(s.UserdataPath, jsonBytes, 0644); err != nil { + return err + } + return nil + } else { + return err + } } if err := json.Unmarshal(b, &whitelist); err != nil {