relay.info.nips config param: lets you override the supported NIPs list in NIP-11 responses and elsewhere

- requested by @ismyhc
This commit is contained in:
Doug Hoyte
2024-09-19 01:27:16 -04:00
parent 980725c2ae
commit 08f06338f3
3 changed files with 20 additions and 3 deletions

View File

@ -48,12 +48,23 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::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<MsgWebsocket>::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();

View File

@ -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)"

View File

@ -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)