Skip to content

Commit

Permalink
Merge branch 'hoytech:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Oct 19, 2024
2 parents 996f464 + 8aa79e4 commit e75f35a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 14 additions & 1 deletion src/apps/mesh/cmd_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/apps/relay/RelayWebsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/relay/golpe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion strfry.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
}

Expand Down

0 comments on commit e75f35a

Please sign in to comment.