Commit Graph

59 Commits (d011f8fb4a14b1f724fc1f15b532c5f97512babf)

Author SHA1 Message Date
Jason Rhinelander d011f8fb4a
Bump clang-format to 14 2 years ago
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).
2 years ago
Jeff 38a157808e Cache best paths determined by GetPathByRouter to reduce cpu usage 2 years ago
Jeff Becker e4ed53224c
use weak_ptr on a path to reference its parent pathset instead of a bare pointer so crashes dont happen 3 years ago
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
3 years ago
Jeff Becker 2e8f47a7fa
various cleanups 3 years ago
Jeff Becker 59c9e997f2
build paths faster and limit path builds at edge router instead of via a time counter for all edges 3 years ago
Jeff Becker 9d483a12db
* add protocol type to snode traffic
* make path::PathSet::SendPacketToRemote know about protocol type
3 years ago
Jason Rhinelander 181953b4a6 Replace ::Hash nested structs with std::hash specializations 3 years ago
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.
3 years ago
Jason Rhinelander 89b582bf60 Modernize [[maybe_unused]] attribute 3 years ago
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
3 years ago
Jeff 5f0f4e0c70
prevent crash by removing duplicate logic (#1515)
when a path expires or fails or something causes its lifecycle to end we have cleanup
logic that handles clean up for it. this removes a code path that was crashing that
is duplicated elsewhere and is thus probably safe to bin. yolo.
3 years ago
Jeff e66522b9dd
fix path reference leak (#1451) 4 years ago
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>
4 years ago
Jeff 21930cf667
LNS (#1342)
* initial relay side lns

* fix typo

* add reserved names and refactor test for dns

* lns name decryption

* all wired up (allegedly)

* refact to use service::EncryptedName for LNS responses to include nonce with ciphertext

* fully rwemove tag_lookup_job

* replace lns cache with DecayingHashTable

* check for lns name validity against the following rules:

* not localhost.loki, loki.loki, or snode.loki

* if it contains no dash then max 32 characters long, not including the .loki tld (and also assuming a leading subdomain has been stripped)

* These are from general DNS requirements, and also enforced in
registrations:

* Must be all [A-Za-z0-9-]. (A-Z will be lower-cased by the RPC call).

* cannot start or end with a -

* max 63 characters long if it does contain a dash

* cannot contain -- in the third and fourth characters unless it starts with xn--

* handle timeout in name lookup job by calling the right handler with std::nullopt
4 years ago
Jeff Becker a45f92dca7
use random good path for outbound traffic so that it uses an even spread accross
all paths
4 years ago
Jeff Becker 6af498092b
exit traffic via loki addresses 4 years ago
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.
4 years ago
Jason Rhinelander f1aa27e616 fix speeling mistack 4 years ago
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
4 years ago
Jeff Becker 99eb7726ff
initial dht key blinding 4 years ago
Jeff Becker 8b8d636ded
make format 4 years ago
Thomas Winget 71bb0dd520 implement timers using libuv
So far only a bit of the code using timers has been modified to use
the new libuv-based timers.  Also only the non-Windows case has been
implemented.  Seems to be working though, so it's a good time to commit.
4 years ago
Jeff Becker 1a864832c8
make format 5 years ago
Thomas Winget 23a9773e1e
remove our paths from outbound queues 5 years ago
Thomas Winget ef1a5652ef
remove our paths from outbound queues 5 years ago
Jeff Becker 7ee026fa50
make path builds work again 5 years ago
Jeff Becker 327c545530
finish multithread cryptography first pass 5 years ago
jeff 14c9ef15ed try calling stuff in logic thread from event loop 5 years ago
Jeff Becker 4bf6882c8a
more async cryptography 5 years ago
Michael edd0ec398f
Move thread stuff to subdirectory 5 years ago
Jeff Becker aa0a795689
call path build fail stuff in logic thread 5 years ago
Thomas Winget 38fd0552d3 Adds Link-Relay Status Messages
Success case:
  - the path endpoint creates and sends a LR_StatusMessage upon
    successful path creation

Failure case:
  - an intermediate hop creates and sends a LR_StatusMessage upon
    failure to forward the path to the next hop for any reason

Both cases:
  - transit hops receive LR_StatusMessages and add a frame
    to them reflecting their "status" with respect to that path
  - the path creator receives LR_StatusMessages and decrypts/parses
    the LR_StatusRecord frames from the path hops.  If all is good,
    the Path does as it would when receiving a PathConfirmMessage.
    If not, the Path marks the new path as failed.

LR_StatusMessage is now used/sent in place of PathConfirmMessage
5 years ago
Jeff Becker 7a3c8e5ca0
set limits correctly 5 years ago
Jeff Becker f48754c45d
make hop count and length configurable 5 years ago
Jeff Becker 64e9622270
start seperating tun and endpoint 5 years ago
Michael b6b400baef
Tidy up pathbuilder code 5 years ago
Jeff Becker 9ea13a9ee3
ingore paths that drop exit traffic 5 years ago
Jeff Becker df322e1149
don't include duplicate hops in paths 5 years ago
Jeff Becker a53da68700
start work on sighup 5 years ago
Jeff Becker 34533db620
add urgent build that builds over an existing path for an endpoint 5 years ago
Jeff Becker 5fa85acaf7
rebuild exit paths if they die 5 years ago
Jeff Becker d423ee02d2
use shared_ptr 5 years ago
Jeff Becker 6711296b26
finish converting to shared_ptr 5 years ago
Jeff Becker 99c29cf05a
prepare for ios/android jazz
move to use std::shared_ptr instead of bare pointers so we can
multithread everything.
5 years ago
Michael 98e691f315
Tidy up more parts of the service/ directory 5 years ago
Jeff Becker b849ff9a94
handle path death better 5 years ago
Jeff Becker ce126166af
more logging info 5 years ago
Jeff Becker 6489ea2152
make it work 5 years ago