mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-19 09:36:43 +00:00
Warn when NIP-11 pubkey is in incorrect format (#52)
This commit is contained in:
@ -52,15 +52,18 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
|
||||
|
||||
auto getServerInfoHttpResponse = [&supportedNips, ver = uint64_t(0), rendered = std::string("")]() mutable {
|
||||
if (ver != cfg().version()) {
|
||||
rendered = preGenerateHttpResponse("application/json", tao::json::to_string(tao::json::value({
|
||||
{ "name", cfg().relay__info__name },
|
||||
{ "description", cfg().relay__info__description },
|
||||
{ "pubkey", cfg().relay__info__pubkey },
|
||||
{ "contact", cfg().relay__info__contact },
|
||||
tao::json::value nip11 = tao::json::value({
|
||||
{ "supported_nips", supportedNips },
|
||||
{ "software", "git+https://github.com/hoytech/strfry.git" },
|
||||
{ "version", APP_GIT_VERSION },
|
||||
})));
|
||||
});
|
||||
|
||||
if (cfg().relay__info__name.size()) nip11["name"] = cfg().relay__info__name;
|
||||
if (cfg().relay__info__description.size()) nip11["description"] = cfg().relay__info__description;
|
||||
if (cfg().relay__info__contact.size()) nip11["contact"] = cfg().relay__info__contact;
|
||||
if (cfg().relay__info__pubkey.size()) nip11["pubkey"] = cfg().relay__info__pubkey;
|
||||
|
||||
rendered = preGenerateHttpResponse("application/json", tao::json::to_string(nip11));
|
||||
ver = cfg().version();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,18 @@
|
||||
|
||||
|
||||
|
||||
static void checkConfig() {
|
||||
if (cfg().relay__info__pubkey.size()) {
|
||||
try {
|
||||
auto p = from_hex(cfg().relay__info__pubkey);
|
||||
if (p.size() != 32) throw herr("bad size");
|
||||
} catch (std::exception &e) {
|
||||
LW << "Your relay.info.pubkey is incorrectly formatted. It should be 64 hex digits.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cmd_relay(const std::vector<std::string> &subArgs) {
|
||||
RelayServer s;
|
||||
s.run();
|
||||
@ -53,12 +65,15 @@ void RelayServer::run() {
|
||||
|
||||
// Monitor for config file reloads
|
||||
|
||||
checkConfig();
|
||||
|
||||
auto configFileChangeWatcher = hoytech::file_change_monitor(configFile);
|
||||
|
||||
configFileChangeWatcher.setDebounce(100);
|
||||
|
||||
configFileChangeWatcher.run([&](){
|
||||
loadConfig(configFile);
|
||||
checkConfig();
|
||||
});
|
||||
|
||||
|
||||
|
@ -57,10 +57,10 @@ relay {
|
||||
description = "This is a strfry instance."
|
||||
|
||||
# NIP-11: Administrative nostr pubkey, for contact purposes
|
||||
pubkey = "unset"
|
||||
pubkey = ""
|
||||
|
||||
# NIP-11: Alternative administrative contact (email, website, etc)
|
||||
contact = "unset"
|
||||
contact = ""
|
||||
}
|
||||
|
||||
# Maximum accepted incoming websocket frame size (should be larger than max event) (restart required)
|
||||
|
Reference in New Issue
Block a user