Commit Graph

129 Commits

Author SHA1 Message Date
Jeff Becker 4508c59cd3
redo includes to be consistent 2023-01-20 13:26:22 -05:00
Jason Rhinelander b6924f3ef1
Replace duration/timestamp formats with functions
We're defining formats for std::chrono types, which feels wrong (because
fmt itself also has these), so just replace them with functions:

short_time_from_now(...) gives a short "in 14m12s" or "5.123s ago" time
span relative to now, given a time point.  Precision gets reduced for
larger deviations from now (e.g. "4h12m ago").

ToString(Duration_t) gives a string such as "-3h22m02.123s" for a
duration.
2022-10-26 21:20:14 -03:00
Jason Rhinelander d011f8fb4a
Bump clang-format to 14 2022-10-20 19:53:52 -03:00
Jason Rhinelander b81f7025c9
Replace logging with oxen-logger
Replaces custom logging system with spdlog-based oxen logging.  This
commit mainly replaces the backend logging with the spdlog-based system,
but doesn't (yet) convert all the existing LogWarn, etc. to use the new
format-based logging.

New logging statements will look like:

    llarp::log::warning(cat, "blah: {}", val);

where `cat` should be set up in each .cpp or cluster of .cpp files, as
described in the oxen-logging README.

As part of spdlog we get fmt, which gives us nice format strings, where
are applied generously in this commit.

Making types printable now requires two steps:
- add a ToString() method
- add this specialization:

      template <>
      constexpr inline bool llarp::IsToStringFormattable<llarp::Whatever> = true;

This will then allow the type to be printed as a "{}" value in a
fmt::format string.  This is applied to all our printable types here,
and all of the `operator<<` are removed.

This commit also:
- replaces various uses of `operator<<` to ToString()
- replaces various uses of std::stringstream with either fmt::format or
  plain std::string
- Rename some to_string and toString() methods to ToString() for
  consistency (and to work with fmt)
- Replace `stringify(...)` and `make_exception` usage with fmt::format
  (and remove stringify/make_exception from util/str.hpp).
2022-07-15 22:17:59 -03:00
Jeff 1eba0f836e
replace LLARP_PROTO_VERSION macro 2022-05-28 13:18:43 -04:00
Jeff 38a157808e Cache best paths determined by GetPathByRouter to reduce cpu usage 2022-03-30 17:11:04 -04:00
Jeff Becker ea3276333a
on path timeout look up each router, if the lookup fails then we remove it from nodedb and close any connections to it so that bad first hops are rotated off of. 2021-06-08 14:36:33 -04:00
Jeff Becker 6a3dc67e9b
nuke from orbit style router profiling for path build timeouts.
* when a path build times out, shitlist every router in the path except the first hop, this way eventually we get the nodedb pruned to only the routers that are currently actually alive, any ones we nuke that we need later we can always do lookups for.
2021-06-08 14:36:33 -04:00
Jeff Becker e4ed53224c
use weak_ptr on a path to reference its parent pathset instead of a bare pointer so crashes dont happen 2021-06-08 14:36:32 -04:00
Jeff Becker a86152e03c
decay path build limiter per path builder every tick 2021-06-08 14:36:31 -04:00
Jeff Becker 23a82c493f
* don't include failed at when we are the pivot router as that case never happens.
* mark paths as ingored instead of expired when we stop a path builder
* only remove path builder when we have no established paths
2021-06-08 14:36:30 -04:00
Jeff Becker 503db46eca
path and intro selection fixups:
* include stricter router profiling checks in path::Builder hop slection algorithm
* make intro selection function nicer by returning a std::optional instead of a bool with an "out" variable
2021-06-08 14:36:30 -04:00
Jeff Becker b1d30f9803
updates to lokinetmon
* add introset inspector mode
* add required parts for introset insecptor mode to rpc introspection
2021-06-08 14:36:29 -04:00
Jeff Becker 3c2334112c
when we stop a path builder we want to expire all of their paths so they go away 2021-05-12 12:48:24 -04:00
Jeff d53945b011
Merge pull request #1621 from majestrate/path-ptr-leak-2021-05-02
try fixing std::shared_ptr leak with paths
2021-05-06 16:15:27 -04:00
Jeff Becker ec62228149
limit path builds across all builders 2021-05-05 08:21:39 -04:00
Jeff Becker 397d8b01fc
try fixing std::shared_ptr leak with paths 2021-05-02 17:52:29 -04:00
Jeff Becker 545021aa3d
temp commit 2021-04-19 07:02:46 -04:00
Jeff Becker bb7b46c43d
fixes for testnet 2021-04-19 07:02:45 -04:00
Jeff Becker 1677ed40f6
dont persist sessions if we failed to build 2021-04-19 07:02:44 -04:00
Jeff Becker 59c9e997f2
build paths faster and limit path builds at edge router instead of via a time counter for all edges 2021-04-19 06:59:05 -04:00
Thomas Winget 7caa87862e standardize include format and pragma once
All #ifndef guards on headers have been removed, I think,
in favor of #pragma once

Headers are now included as `#include "filename"` if the included file
resides in the same directory as the file including it, or any
subdirectory therein.  Otherwise they are included as
`#include <project/top/dir/relative/path/filename>`

The above does not include system/os headers.
2021-03-09 19:01:41 -05:00
Jason Rhinelander 91d6698a9d Reformat with clang-format-11 2021-03-05 13:36:31 -04:00
Jason Rhinelander ccc7b5c9e9 Merge Logic functions into EventLoop
loop->call(...) is similar to the old logic->Call(...), but is smart
about the current thread: if called from within the event loop it simply
runs the argument directly, otherwise it queues it.

Similarly most of the other event loop calls are also now thread-aware:
for example, `call_later(...)` can queue the job directly when called if
in the event loop rather than having to double-queue through the even
loop (once to call, then inside the call to initiate the time).
2021-03-04 16:51:18 -04:00
Jeff Becker 3425069b41
feedback from jason
* use emplace in PeerSectionConfig::Acceptable use insert everywhere else
* use const l-value references
* fix typos and spelling mistakes
2021-03-02 07:20:29 -05:00
Jeff Becker 9457da27d9
add option to enforce unique netblocks per path. 2021-03-02 07:20:28 -05:00
Jeff Becker 1f1db29816
GetIf -> GetRandom 2021-02-03 16:38:31 -05:00
Jeff Becker f24cdb305b
clean up calls to NodeDB::GetIf to be cleaner and more concise 2021-02-03 14:49:33 -05:00
Jeff Becker d55705362a
use good routers 2021-02-03 13:50:12 -05:00
Jeff Becker b6dbbb4bef
consolidate pathbuilder logic
* deduplicate code for path hops selection
2021-02-03 13:44:43 -05:00
Jeff Becker df4ea34a56
nodedb refactor
* bump zmq static dep
* lokimq -> oxenmq
* llarp_nodedb -> llarp::NodeDB
* remove all crufty api parts of NodeDB
* make NodeDB rc selection api not suck
* make path builder api not suck
* propagate all above changes so that unit tests work and it all compiles
2021-02-02 09:35:40 -05:00
Jeff e66522b9dd
fix path reference leak (#1451) 2020-11-04 11:08:29 -05:00
Jeff 8be7c46531
try fixing memory leak in path builder (#1442) 2020-11-02 08:06:46 -05:00
Jeff dcb48db5fe
enable profiling on clients by default (#1421)
* enable client relay profiling by default

* macos dns fixes

* improve peer profiling algorithm to track timeouts vs failures

* remove debug ioctl call in tuntap code

* use ub_wait instead of ub_process as that was what was there before

* const correctness

* DRY out checking for SIIT

* typofix

* correct name
2020-10-27 17:34:09 -04:00
Jeff 4c7d52ac20
more aggressive path building. (#1423)
* more aggressive path building.

* do more than one in parallel path builds at a time

* correct last commit's logic

* rename numPaths -> numDesiredPaths to clarify intent

* revert string change as it will break a lot

* don't prematurly short circuit on snode builds

Co-authored-by: Thomas Winget <tewinget@gmail.com>
2020-10-27 16:27:14 -04:00
Jeff Becker 0f21eeccb0
* rework exit codepath to allow multiple exits
* rework net code for ip ranges to be cleaner
* clean up endpoint auth code
* refactor config to validate network configs before setting up endpoints
* remove buildone from path/pathbuilder.cpp so we don't spam connection attempts
2020-07-02 11:13:30 -04:00
Jeff Becker f4971a88fd
use lokimq workers instead of llarp:🧵:ThreadPool 2020-07-02 11:07:34 -04:00
Stephen Shelton 273270916e
The Great Wall of Blame
This commit reflects changes to clang-format rules. Unfortunately,
these rule changes create a massive change to the codebase, which
causes an apparent rewrite of git history.

Git blame's --ignore-rev flag can be used to ignore this commit when
attempting to `git blame` some code.
2020-04-07 12:38:56 -06:00
Stephen Shelton ea835405c5
Refactor NotifyRouterEvent() to forward args, event code cleanup
This template-ifies Router::NotifyRouterEvent() up so that it accepts
the arguments to instantiate the specified event type, forwarding them
to std::make_unique. This would allow (in the future) the function to
no-op the call and avoid memory allocation. It also slightly reduces
the amount of code required to fire an event.

This commit also simplifies some of the RouterEvent code to reduce
redundancy.
2020-03-12 11:50:46 -06:00
Thomas Winget 84a1d7dbcc clang format....... 2020-03-06 20:20:11 -05:00
Thomas Winget c8c66f0a5f some refactoring of tooling code, added RCGossipReceivedEvent 2020-03-03 19:57:09 -05:00
Thomas Winget a9882ad475 PathRequestReceivedEvent implemented 2020-03-03 19:57:09 -05:00
Thomas Winget c9a278c0de some more changes to pybind/hive code, read below
hive.py is currently largely for testing the pybind stuff, so changes to it will likely
be frequent and arbitrary for now.

Added pybind for llarp::path::PathHopConfig, but not every member -- just rc and upstream routerID

Hive now uses std::queue with mutex instead of our lockless queue.

Removed some functions from Hive that will not be necessary as things are being handled from python.
2020-03-03 19:57:09 -05:00
Thomas Winget 1e04decb66 can ping on lokinet running in python context! 2020-03-03 19:57:09 -05:00
Jason Rhinelander 76608b6b90 Logic simplification 2020-03-01 11:58:08 -04:00
Jason Rhinelander f1aa27e616 fix speeling mistack 2020-02-25 22:27:34 -04:00
Jeff Becker bf0416cab8
remove Time_t, add operator overload for printing llarp_time_t and add to_json function for serializing llarp_time_t to json 2020-02-25 12:05:13 -05:00
Jeff Becker d2d109e92c
llarp_time_t is now using std::chrono 2020-02-24 15:25:03 -05:00
Jason Rhinelander b4440094b0 De-abseil, part 2: mutex, locks, (most) time
- util::Mutex is now a std::shared_timed_mutex, which is capable of
  exclusive and shared locks.

- util::Lock is still present as a std::lock_guard<util::Mutex>.

- the locking annotations are preserved, but updated to the latest
  supported by clang rather than using abseil's older/deprecated ones.

- ACQUIRE_LOCK macro is gone since we don't pass mutexes by pointer into
  locks anymore (WTF abseil).

- ReleasableLock is gone.  Instead there are now some llarp::util helper
  methods to obtain unique and/or shared locks:
    - `auto lock = util::unique_lock(mutex);` gets an RAII-but-also
      unlockable object (std::unique_lock<T>, with T inferred from
      `mutex`).
    - `auto lock = util::shared_lock(mutex);` gets an RAII shared (i.e.
      "reader") lock of the mutex.
    - `auto lock = util::unique_locks(mutex1, mutex2, mutex3);` can be
      used to atomically lock multiple mutexes at once (returning a
      tuple of the locks).
  This are templated on the mutex which makes them a bit more flexible
  than using a concrete type: they can be used for any type of lockable
  mutex, not only util::Mutex.  (Some of the code here uses them for
  getting locks around a std::mutex).  Until C++17, using the RAII types
  is painfully verbose:

  ```C++
  // pre-C++17 - needing to figure out the mutex type here is annoying:
  std::unique_lock<util::Mutex> lock(mutex);
  // pre-C++17 and even more verbose (but at least the type isn't needed):
  std::unique_lock<decltype(mutex)> lock(mutex);
  // our compromise:
  auto lock = util::unique_lock(mutex);
  // C++17:
  std::unique_lock lock(mutex);
  ```

  All of these functions will also warn (under gcc or clang) if you
  discard the return value.  You can also do fancy things like
  `auto l = util::unique_lock(mutex, std::adopt_lock)` (which lets a
  lock take over an already-locked mutex).

- metrics code is gone, which also removes a big pile of code that was
  only used by metrics:
  - llarp::util::Scheduler
  - llarp:🧵:TimerQueue
  - llarp::util::Stopwatch
2020-02-21 23:22:47 -04:00
Stephen Shelton ea97a8f2ac
Make format 2020-02-21 10:16:45 -07:00