mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-20 09:50:28 +00:00
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:
@ -48,12 +48,23 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
|
|||||||
tempBuf.reserve(cfg().events__maxEventSize + MAX_SUBID_SIZE + 100);
|
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 {
|
auto getServerInfoHttpResponse = [&supportedNips, ver = uint64_t(0), rendered = std::string("")]() mutable {
|
||||||
if (ver != cfg().version()) {
|
if (ver != cfg().version()) {
|
||||||
tao::json::value nip11 = tao::json::value({
|
tao::json::value nip11 = tao::json::value({
|
||||||
{ "supported_nips", supportedNips },
|
{ "supported_nips", supportedNips() },
|
||||||
{ "software", "git+https://github.com/hoytech/strfry.git" },
|
{ "software", "git+https://github.com/hoytech/strfry.git" },
|
||||||
{ "version", APP_GIT_VERSION },
|
{ "version", APP_GIT_VERSION },
|
||||||
{ "negentropy", negentropy::PROTOCOL_VERSION - 0x60 },
|
{ "negentropy", negentropy::PROTOCOL_VERSION - 0x60 },
|
||||||
@ -83,7 +94,7 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
|
|||||||
std::string supportedNips;
|
std::string supportedNips;
|
||||||
std::string version;
|
std::string version;
|
||||||
uint64_t negentropy;
|
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);
|
rendered = preGenerateHttpResponse("text/html", ::strfrytmpl::landing(ctx).str);
|
||||||
ver = cfg().version();
|
ver = cfg().version();
|
||||||
|
@ -30,6 +30,9 @@ config:
|
|||||||
- name: relay__info__icon
|
- name: relay__info__icon
|
||||||
desc: "NIP-11: URL pointing to an image to be used as an icon for the relay"
|
desc: "NIP-11: URL pointing to an image to be used as an icon for the relay"
|
||||||
default: ""
|
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
|
- name: relay__maxWebsocketPayloadSize
|
||||||
desc: "Maximum accepted incoming websocket frame size (should be larger than max event)"
|
desc: "Maximum accepted incoming websocket frame size (should be larger than max event)"
|
||||||
|
@ -67,6 +67,9 @@ relay {
|
|||||||
|
|
||||||
# NIP-11: URL pointing to an image to be used as an icon for the relay
|
# NIP-11: URL pointing to an image to be used as an icon for the relay
|
||||||
icon = ""
|
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)
|
# Maximum accepted incoming websocket frame size (should be larger than max event) (restart required)
|
||||||
|
Reference in New Issue
Block a user