Rediff patches

Drop 0002-Remove-useless-iterator-assignments.patch: <REASON>
Drop 0001-proper-handling-of-public-ips.patch: <REASON>
Drop 0003-Fix-time_delta-seconds-formatting-in-milliseconds.patch: <REASON>
debian/bookworm
Jason Rhinelander 2 years ago
parent 179d36909a
commit 6f8d387103
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262

@ -1,102 +0,0 @@
From: Jeff Becker <jeff@lokinet.io>
Date: Wed, 26 Oct 2022 14:03:30 -0400
Subject: proper handling of public ips
in service node mode make sure that when overriding public ip we only
fail when using 2 different public ip.
---
llarp/router/router.cpp | 14 ++++++++++++--
test/config/test_llarp_config_values.cpp | 27 ++++++++++++++++++++++++---
2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp
index 73e52bf..f11a57b 100644
--- a/llarp/router/router.cpp
+++ b/llarp/router/router.cpp
@@ -1287,8 +1287,18 @@ namespace llarp
// override ip and port as needed
if (_ourAddress)
{
- if (not Net().IsBogon(ai.ip))
- throw std::runtime_error{"cannot override public ip, it is already set"};
+ const auto ai_ip = ai.IP();
+ const auto override_ip = _ourAddress->getIP();
+
+ auto ai_ip_str = var::visit([](auto&& ip) { return ip.ToString(); }, ai_ip);
+ auto override_ip_str = var::visit([](auto&& ip) { return ip.ToString(); }, override_ip);
+
+ if ((not Net().IsBogonIP(ai_ip)) and (not Net().IsBogonIP(override_ip))
+ and ai_ip != override_ip)
+ throw std::runtime_error{
+ "Lokinet is bound to public IP '{}', but public-ip is set to '{}'. Either fix the "
+ "[router]:public-ip setting or set a bind address in the [bind] section of the "
+ "config."_format(ai_ip_str, override_ip_str)};
ai.fromSockAddr(*_ourAddress);
}
if (RouterContact::BlockBogons && Net().IsBogon(ai.ip))
diff --git a/test/config/test_llarp_config_values.cpp b/test/config/test_llarp_config_values.cpp
index 242f5d1..8276cc5 100644
--- a/test/config/test_llarp_config_values.cpp
+++ b/test/config/test_llarp_config_values.cpp
@@ -160,6 +160,26 @@ inbound=127.0.0.1:443
)";
REQUIRE_THROWS(make_config(env, ini_str));
}
+ SECTION("public ip provided but no bind section")
+ {
+ std::string_view ini_str = R"(
+[router]
+public-ip=1.1.1.1
+public-port=443
+)";
+ REQUIRE_NOTHROW(run_config_test(env, ini_str));
+ }
+ SECTION("public ip provided with ip in bind section")
+ {
+ std::string_view ini_str = R"(
+[router]
+public-ip=1.1.1.1
+public-port=443
+[bind]
+1.1.1.1=443
+)";
+ REQUIRE_NOTHROW(run_config_test(env, ini_str));
+ }
}
TEST_CASE("service node bind section on nat network", "[config]")
@@ -212,6 +232,7 @@ inbound=0.0.0.0:443
)";
REQUIRE_THROWS(run_config_test(env, ini_str));
}
+
}
TEST_CASE("service node bind section with multiple public ip", "[config]")
@@ -226,7 +247,7 @@ TEST_CASE("service node bind section with multiple public ip", "[config]")
std::string_view ini_str = "";
REQUIRE_NOTHROW(run_config_test(env, ini_str));
}
- SECTION("with old style wildcard for inbound and no public ip")
+ SECTION("with old style wildcard for inbound and no public ip, fails")
{
std::string_view ini_str = R"(
[bind]
@@ -261,7 +282,7 @@ public-port=443
inbound=0.0.0.0:443
)";
- REQUIRE_THROWS(run_config_test(env, ini_str));
+ REQUIRE_NOTHROW(run_config_test(env, ini_str));
}
SECTION("with wildcard via inbound directive secondary public ip given")
{
@@ -273,7 +294,7 @@ public-port=443
inbound=0.0.0.0:443
)";
- REQUIRE_THROWS(run_config_test(env, ini_str));
+ REQUIRE_NOTHROW(run_config_test(env, ini_str));
}
SECTION("with bind via interface name")
{

@ -1,90 +0,0 @@
From: Jason Rhinelander <jason@imaginary.ca>
Date: Wed, 26 Oct 2022 17:10:54 -0300
Subject: Remove useless iterator assignments
A back_inserter doesn't change when you insert onto it.
---
llarp/router/router.cpp | 18 +++++++++---------
llarp/router_contact.cpp | 6 +++---
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp
index f11a57b..24ad452 100644
--- a/llarp/router/router.cpp
+++ b/llarp/router/router.cpp
@@ -888,32 +888,32 @@ namespace llarp
{
std::string status;
auto out = std::back_inserter(status);
- out = fmt::format_to(out, "WATCHDOG=1\nSTATUS=v{}", llarp::VERSION_STR);
+ fmt::format_to(out, "WATCHDOG=1\nSTATUS=v{}", llarp::VERSION_STR);
if (IsServiceNode())
{
- out = fmt::format_to(
+ fmt::format_to(
out,
" snode | known/svc/clients: {}/{}/{}",
nodedb()->NumLoaded(),
NumberOfConnectedRouters(),
NumberOfConnectedClients());
- out = fmt::format_to(
+ fmt::format_to(
out,
" | {} active paths | block {} ",
pathContext().CurrentTransitPaths(),
(m_lokidRpcClient ? m_lokidRpcClient->BlockHeight() : 0));
- out = fmt::format_to(
+ fmt::format_to(
out,
" | gossip: (next/last) {} / ",
time_delta<std::chrono::seconds>{_rcGossiper.NextGossipAt()});
if (auto maybe = _rcGossiper.LastGossipAt())
- out = fmt::format_to(out, "{}", time_delta<std::chrono::seconds>{*maybe});
+ fmt::format_to(out, "{}", time_delta<std::chrono::seconds>{*maybe});
else
- out = fmt::format_to(out, "never");
+ fmt::format_to(out, "never");
}
else
{
- out = fmt::format_to(
+ fmt::format_to(
out,
" client | known/connected: {}/{}",
nodedb()->NumLoaded(),
@@ -921,7 +921,7 @@ namespace llarp
if (auto ep = hiddenServiceContext().GetDefault())
{
- out = fmt::format_to(
+ fmt::format_to(
out,
" | paths/endpoints {}/{}",
pathContext().CurrentOwnedPaths(),
@@ -929,7 +929,7 @@ namespace llarp
if (auto success_rate = ep->CurrentBuildStats().SuccessRatio(); success_rate < 0.5)
{
- out = fmt::format_to(
+ fmt::format_to(
out, " [ !!! Low Build Success Rate ({:.1f}%) !!! ]", (100.0 * success_rate));
}
};
diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp
index 9004c1c..a0655f1 100644
--- a/llarp/router_contact.cpp
+++ b/llarp/router_contact.cpp
@@ -116,10 +116,10 @@ namespace llarp
std::string result;
auto out = std::back_inserter(result);
for (const auto& addr : addrs)
- out = fmt::format_to(out, "ai_addr={}; ai_pk={}; ", addr.toIpAddress(), addr.pubkey);
- out = fmt::format_to(out, "updated={}; onion_pk={}; ", last_updated.count(), enckey.ToHex());
+ fmt::format_to(out, "ai_addr={}; ai_pk={}; ", addr.toIpAddress(), addr.pubkey);
+ fmt::format_to(out, "updated={}; onion_pk={}; ", last_updated.count(), enckey.ToHex());
if (routerVersion.has_value())
- out = fmt::format_to(out, "router_version={}; ", *routerVersion);
+ fmt::format_to(out, "router_version={}; ", *routerVersion);
return result;
}

@ -1,24 +0,0 @@
From: Jason Rhinelander <jason@imaginary.ca>
Date: Wed, 26 Oct 2022 17:19:00 -0300
Subject: Fix time_delta<seconds> formatting in milliseconds
The time_delta<T> was using the wrong duration type when formatting, so
was outputting millisecond precision in the systemd status string which
is pointless (and unintended).
---
llarp/util/time.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llarp/util/time.hpp b/llarp/util/time.hpp
index fbf9997..c50c28b 100644
--- a/llarp/util/time.hpp
+++ b/llarp/util/time.hpp
@@ -42,7 +42,7 @@ namespace fmt
format(const llarp::time_delta<Time_Duration>& td, FormatContext& ctx)
{
const auto dlt =
- std::chrono::duration_cast<llarp::Duration_t>(llarp::TimePoint_t::clock::now() - td.at);
+ std::chrono::duration_cast<Time_Duration>(llarp::TimePoint_t::clock::now() - td.at);
using Parent = formatter<std::string>;
if (dlt > 0s)
return Parent::format(fmt::format("{} ago", dlt), ctx);

@ -1,3 +0,0 @@
0001-proper-handling-of-public-ips.patch
0002-Remove-useless-iterator-assignments.patch
0003-Fix-time_delta-seconds-formatting-in-milliseconds.patch
Loading…
Cancel
Save