diff --git a/CHANGES b/CHANGES index feb9717..48c002f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +1.0.2 + * New config param: relay.info.nips which allows you to override the NIPs + that are claimed to be supported (requested by ismyhc) + * New connectionTimeout parameter in router config (thanks Braydon Fuller!) + * Bugfix: IPv4-mapped IPv6 addresses in X-Real-IP headers were not parsed + correctly (reported by Petr KracĂ­k) + 1.0.1 * Prevent exporting a v2 DB using --fried. The packed representation will be corrupted. Instead, you should downgrade to 0.9.7 to do the export, or do diff --git a/docs/router.md b/docs/router.md index b3a55a4..2bfe113 100644 --- a/docs/router.md +++ b/docs/router.md @@ -18,6 +18,8 @@ The config file must have a section `streams`. Within that, you may have as many ### Example + connectionTimeout = 20 + streams { ## Stream down events from our friend relays diff --git a/src/apps/mesh/cmd_router.cpp b/src/apps/mesh/cmd_router.cpp index 2c0cd8d..5d8c46f 100644 --- a/src/apps/mesh/cmd_router.cpp +++ b/src/apps/mesh/cmd_router.cpp @@ -218,7 +218,8 @@ struct Router { }; std::string routerConfigFile; - uint64_t connectionTimeoutUs = 5'000'000; + const uint64_t defaultConnectionTimeoutUs = 20'000'000; + uint64_t connectionTimeoutUs = 0; WriterPipeline writer; Decompressor decomp; @@ -313,6 +314,18 @@ struct Router { for (const auto &[groupName, spec] : routerConfig.at("streams").get_object()) unneededGroups.erase(groupName); for (const auto &groupName : unneededGroups) streamGroups.erase(groupName); } + + // connectionTimeout + + uint64_t newTimeoutUs = defaultConnectionTimeoutUs; + if (routerConfig.get_object().contains("connectionTimeout")) { + newTimeoutUs = routerConfig.at("connectionTimeout").get_unsigned() * 1'000'000; + } + + if (connectionTimeoutUs != newTimeoutUs) { + connectionTimeoutUs = newTimeoutUs; + LI << "Using connection timeout: " << (connectionTimeoutUs / 1'000'000) << " seconds"; + } } catch (std::exception &e) { LE << "Failed to parse router config: " << e.what(); if (!firstConfigLoadSuccess) ::exit(1); diff --git a/src/apps/relay/RelayWebsocket.cpp b/src/apps/relay/RelayWebsocket.cpp index 6ba1503..b87de56 100644 --- a/src/apps/relay/RelayWebsocket.cpp +++ b/src/apps/relay/RelayWebsocket.cpp @@ -197,6 +197,11 @@ void RelayServer::runWebsocket(ThreadPool::Thread &thr) { if (cfg().relay__realIpHeader.size()) { auto header = req.getHeader(cfg().relay__realIpHeader.c_str()).toString(); // not string_view: parseIP needs trailing 0 byte + + // HACK: uWebSockets strips leading : characters, which interferes with IPv6 parsing. + // This fixes it for the common ::1 and ::ffff:1.2.3.4 cases. FIXME: fix the underlying library. + if (header == "1" || header.starts_with("ffff:")) header = std::string("::") + header; + c->ipAddr = parseIP(header); if (c->ipAddr.size() == 0) LW << "Couldn't parse IP from header " << cfg().relay__realIpHeader << ": " << header; } diff --git a/src/apps/relay/golpe.yaml b/src/apps/relay/golpe.yaml index 11b4d5c..e8cbded 100644 --- a/src/apps/relay/golpe.yaml +++ b/src/apps/relay/golpe.yaml @@ -31,7 +31,7 @@ config: 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]" + desc: "List of supported lists as JSON array, or empty string to use default. Example: \"[1,2]\"" default: "" - name: relay__maxWebsocketPayloadSize diff --git a/strfry.conf b/strfry.conf index 8243822..27bdf3b 100644 --- a/strfry.conf +++ b/strfry.conf @@ -68,7 +68,7 @@ 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] + # List of supported lists as JSON array, or empty string to use default. Example: "[1,2]" nips = "" }