From ae6c55bb2cc5f7d9f56ca288363167ca8df557d0 Mon Sep 17 00:00:00 2001 From: Roland Bewick Date: Wed, 15 Nov 2023 18:29:55 +0700 Subject: [PATCH] feat: add support both internal and public relay URL --- .env.example | 1 + README.md | 1 + config.go | 1 + echo_handlers.go | 7 ++++--- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 49d5e24d..db1e3049 100644 --- a/.env.example +++ b/.env.example @@ -6,4 +6,5 @@ ALBY_CLIENT_ID= OAUTH_REDIRECT_URL=http://localhost:8080/alby/callback COOKIE_SECRET=secretsecret RELAY=wss://relay.getalby.com/v1 +PUBLIC_RELAY= PORT=8080 diff --git a/README.md b/README.md index 4b15441b..38458b27 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ To build the CSS run: - `NOSTR_PRIVKEY`: the private key of this service. Should be a securely randomly generated 32 byte hex string. - `CLIENT_NOSTR_PUBKEY`: if set, this service will only listen to events authored by this public key. You can set this to your own nostr public key. - `RELAY`: default: "wss://relay.getalby.com/v1" +- `PUBLIC_RELAY`: optional relay URL to be used in connection strings if `RELAY` is an internal URL - `LN_BACKEND_TYPE`: ALBY or LND - `ALBY_CLIENT_SECRET`= Alby OAuth client secret (used with the Alby backend) - `ALBY_CLIENT_ID`= Alby OAuth client ID (used with the Alby backend) diff --git a/config.go b/config.go index 69878dcb..0567f780 100644 --- a/config.go +++ b/config.go @@ -12,6 +12,7 @@ type Config struct { CookieDomain string `envconfig:"COOKIE_DOMAIN"` ClientPubkey string `envconfig:"CLIENT_NOSTR_PUBKEY"` Relay string `envconfig:"RELAY" default:"wss://relay.getalby.com/v1"` + PublicRelay string `envconfig:"PUBLIC_RELAY"` LNBackendType string `envconfig:"LN_BACKEND_TYPE" default:"ALBY"` LNDAddress string `envconfig:"LND_ADDRESS"` LNDCertFile string `envconfig:"LND_CERT_FILE"` diff --git a/echo_handlers.go b/echo_handlers.go index f4452d24..1ec4eecc 100644 --- a/echo_handlers.go +++ b/echo_handlers.go @@ -405,9 +405,10 @@ func (svc *Service) AppsCreateHandler(c echo.Context) error { return c.Redirect(302, "/apps") } - // FIXME: need a public-facing relay URL env variable - // and fallback to svc.cfg.Relay (hosted instance uses an internal URL) - publicRelayUrl := "wss://relay.getalby.com/v1"; + publicRelayUrl := svc.cfg.PublicRelay; + if (publicRelayUrl == "") { + publicRelayUrl = svc.cfg.Relay; + } if c.FormValue("returnTo") != "" { returnToUrl, err := url.Parse(c.FormValue("returnTo"))