diff --git a/src/apps/relay/RelayWebsocket.cpp b/src/apps/relay/RelayWebsocket.cpp index d28e5bf..6ba1503 100644 --- a/src/apps/relay/RelayWebsocket.cpp +++ b/src/apps/relay/RelayWebsocket.cpp @@ -48,12 +48,23 @@ void RelayServer::runWebsocket(ThreadPool::Thread &thr) { tempBuf.reserve(cfg().events__maxEventSize + MAX_SUBID_SIZE + 100); - tao::json::value supportedNips = tao::json::value::array({ 1, 2, 4, 9, 11, 22, 28, 40, 70, 77 }); + auto supportedNips = []{ + tao::json::value output = tao::json::value::array({ 1, 2, 4, 9, 11, 22, 28, 40, 70, 77 }); + if (cfg().relay__info__nips.size() == 0) return output; + + try { + output = tao::json::from_string(cfg().relay__info__nips); + } catch (std::exception &e) { + LE << "Unable to parse config param relay.info.nips: " << e.what(); + } + + return output; + }; auto getServerInfoHttpResponse = [&supportedNips, ver = uint64_t(0), rendered = std::string("")]() mutable { if (ver != cfg().version()) { tao::json::value nip11 = tao::json::value({ - { "supported_nips", supportedNips }, + { "supported_nips", supportedNips() }, { "software", "git+https://github.com/hoytech/strfry.git" }, { "version", APP_GIT_VERSION }, { "negentropy", negentropy::PROTOCOL_VERSION - 0x60 }, @@ -83,7 +94,7 @@ void RelayServer::runWebsocket(ThreadPool::Thread &thr) { std::string supportedNips; std::string version; uint64_t negentropy; - } ctx = { tao::json::to_string(supportedNips), APP_GIT_VERSION, negentropy::PROTOCOL_VERSION - 0x60 }; + } ctx = { tao::json::to_string(supportedNips()), APP_GIT_VERSION, negentropy::PROTOCOL_VERSION - 0x60 }; rendered = preGenerateHttpResponse("text/html", ::strfrytmpl::landing(ctx).str); ver = cfg().version(); diff --git a/src/apps/relay/golpe.yaml b/src/apps/relay/golpe.yaml index 9eab478..11b4d5c 100644 --- a/src/apps/relay/golpe.yaml +++ b/src/apps/relay/golpe.yaml @@ -30,6 +30,9 @@ config: - name: relay__info__icon desc: "NIP-11: URL pointing to an image to be used as an icon for the relay" default: "" + - name: relay__info__nips + desc: "List of supported lists as JSON array, or empty string to use default. Example: [1,2]" + default: "" - name: relay__maxWebsocketPayloadSize desc: "Maximum accepted incoming websocket frame size (should be larger than max event)" diff --git a/strfry.conf b/strfry.conf index b59e1ec..d05ee77 100644 --- a/strfry.conf +++ b/strfry.conf @@ -67,6 +67,9 @@ relay { # NIP-11: URL pointing to an image to be used as an icon for the relay icon = "" + + # List of supported lists as JSON array, or empty string to use default. Example: [1,2] + nips = "" } # Maximum accepted incoming websocket frame size (should be larger than max event) (restart required)