diff --git a/external/oxen-libquic b/external/oxen-libquic index 6ee6ed398..3ced484e8 160000 --- a/external/oxen-libquic +++ b/external/oxen-libquic @@ -1 +1 @@ -Subproject commit 6ee6ed398d00043d862466a56279b5c502513bff +Subproject commit 3ced484e8cc543b90c5fc554ccc0ea2e54ec8d37 diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 1dc41aa95..06e95594a 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -961,9 +961,8 @@ namespace llarp maybe = oxen::quic::Address{std::string{h}, p}; - // TODO: unfuck llarp/net - // if (net_ptr->IsLoopbackAddress(addr->port())) - // throw std::invalid_argument{fmt::format("{} is a loopback address", arg)}; + if (maybe->is_loopback()) + throw std::invalid_argument{fmt::format("{} is a loopback address", arg)}; } if (not maybe) { @@ -1103,34 +1102,40 @@ namespace llarp }); conf.add_undeclared_handler( - "bind", [this, net_ptr](std::string_view, std::string_view key, std::string_view val) { + "bind", [this](std::string_view, std::string_view key, std::string_view val) { if (using_new_api) throw std::runtime_error{"USE THE NEW API -- SPECIFY LOCAL ADDRESS UNDER [LISTEN]"}; - log::warning( - logcat, "Using the [bind] section is beyond deprecated; use [listen] instead"); + log::warning(logcat, "Please update your config to use [bind]:listen instead"); + + uint16_t port{0}; + + if (auto rv = llarp::parse_int(val, port); not rv) + throw std::runtime_error{"Could not parse port; stop using this deprecated handler"}; + + port = port == 0 ? DEFAULT_LISTEN_PORT : port; // special case: wildcard for outbound if (key == "*") { - uint16_t port{0}; - - if (auto rv = llarp::parse_int(val, port); not rv) - log::warning( - logcat, "Could not parse port; stop using this deprecated handler you nonce"); - - addr = oxen::quic::Address{"", port}; // TODO: drop the "" after bumping libquic + addr = oxen::quic::Address{port}; return; } oxen::quic::Address temp; - // try as interface name first - auto saddr = net_ptr->GetInterfaceAddr(key, AF_INET); - - if (saddr and net_ptr->IsLoopbackAddress(saddr->getIP())) - throw std::invalid_argument{fmt::format("{} is a loopback interface", key)}; - temp = oxen::quic::Address{saddr->in()}; + try + { + temp = oxen::quic::Address{std::string{key}, port}; + } + catch (const std::exception& e) + { + throw std::runtime_error{fmt::format( + "Could not parse address {}; please update your config to use [bind]:listen " + "instead: {}", + key, + e.what())}; + } if (temp.is_addressable()) { @@ -1138,10 +1143,10 @@ namespace llarp return; } - log::warning( - logcat, - "Could not parse address values; stop using this deprecated handler you nonce"); - addr = oxen::quic::Address{""s, DEFAULT_LISTEN_PORT}; + throw std::runtime_error{fmt::format( + "Invalid address: {}; stop using this deprecated handler, update your config to use " + "[bind]:listen instead PLEASE", + temp)}; }); } diff --git a/llarp/link/link_manager.cpp b/llarp/link/link_manager.cpp index caa004a4e..7380a2655 100644 --- a/llarp/link/link_manager.cpp +++ b/llarp/link/link_manager.cpp @@ -314,7 +314,9 @@ namespace llarp // TODO: confirm remote end is using the expected pubkey (RouterID). // TODO: ALPN for "client" vs "relay" (could just be set on endpoint creation) - if (auto rv = ep.establish_connection(remote_addr, rc); rv) + if (auto rv = ep.establish_connection( + oxen::quic::RemoteAddress{rc.router_id().ToView(), remote_addr}, rc); + rv) { log::info(quic_cat, "Connection to {} successfully established!", remote_addr); return; diff --git a/llarp/link/link_manager.hpp b/llarp/link/link_manager.hpp index d99e2face..b9a599727 100644 --- a/llarp/link/link_manager.hpp +++ b/llarp/link/link_manager.hpp @@ -71,7 +71,8 @@ namespace llarp template bool - establish_connection(const oxen::quic::Address& remote, const RemoteRC& rc, Opt&&... opts); + establish_connection( + const oxen::quic::RemoteAddress& remote, const RemoteRC& rc, Opt&&... opts); void for_each_connection(std::function func); @@ -364,7 +365,7 @@ namespace llarp template bool Endpoint::establish_connection( - const oxen::quic::Address& remote, const RemoteRC& rc, Opt&&... opts) + const oxen::quic::RemoteAddress& remote, const RemoteRC& rc, Opt&&... opts) { try { diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index 68b8fcd90..ab13328ca 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -12,32 +12,6 @@ namespace llarp { - - // RouterContact::RouterContact(std::string buf) - // { - // try - // { - // oxenc::bt_list_consumer btlc{buf}; - - // // signature.from_string(btlc.consume_string()); - // signed_bt_dict = btlc.consume_string(); - - // // TODO: parse bt dict - // } - // catch (...) - // { - // log::warning(llarp_cat, "Error: RouterContact failed to populate bt encoded contents!"); - // } - // } - - // std::string - // RouterContact::bt_encode() const - // { - // oxenc::bt_dict_producer btdp; - // bt_encode(btdp); - // return std::move(btdp).str(); - // } - void RouterContact::bt_load(oxenc::bt_dict_consumer& data) { diff --git a/llarp/router_contact.hpp b/llarp/router_contact.hpp index f863bbd67..49aa96cce 100644 --- a/llarp/router_contact.hpp +++ b/llarp/router_contact.hpp @@ -244,7 +244,7 @@ namespace llarp void clear() override { - _addr = {}; + _addr = oxen::quic::Address{}; _addr6.reset(); _router_id.Zero(); _timestamp = {}; @@ -338,7 +338,7 @@ namespace llarp void clear() override { - _addr = {}; + _addr = oxen::quic::Address{}; _addr6.reset(); _router_id.Zero(); _timestamp = {};