Commit Graph

508 Commits (4103908a8da9fa315ffa1762f94ff39e4ad772e8)

Author SHA1 Message Date
Jeff 45cda241f0
Merge pull request #1272 from majestrate/exit-nodes-2020-05-16
exit traffic via snapps
4 years ago
Jeff Becker acecb23eb3
make libuv event loop logic queue size configurable.
remove logic constructor that is no-op.
add constant for default logic queue size
add constant for transit hop queue size
4 years ago
Rick V 1340cd0dce remove some string conversions entirely 4 years ago
Rick V f62214cf8c
first pass fix wstring path conversions 4 years ago
Jeff Becker 403bc74493
unbreak unit tests 4 years ago
Jeff Becker f0eca908a4
use static_assert instead 4 years ago
Jeff Becker 4ad8ae253d
align to either 64bit or max_align_t which ever is smaller, for 32 bit. 4 years ago
Jeff Becker 7a5c193e4f
remove unused member 4 years ago
Jeff Becker 4a378ae934
remove logic thread from logic as it is now a thin wrapper arround the event loop 4 years ago
Jeff Becker eb0abbf1ff
add eraseif to decaying hashset 4 years ago
Jeff Becker b8da447053
use const iterators explicitly 4 years ago
Jeff Becker 3a776b3ed1
bounds checks and such 4 years ago
Jeff Becker 00143e63f4
put replay filters on transit hops to reduce retransmissions. 4 years ago
Jeff Becker 6af498092b
exit traffic via loki addresses 4 years ago
Jason Rhinelander d05e6716cb Remove llarp::str(string_view)
It was a workaround for pre-C++17 std::string which didn't support
passing a string_view to various functions/operators.  There's only one
place left that needs an explicit conversion, and that's where it is
used as a map key; so just be explicit there and remove llarp::str()
everywhere else.
4 years ago
Jason Rhinelander 3bb24580a4 make format 4 years ago
Jason Rhinelander ebd2142114 Don't use std::optional::value() because f u macos
This replaces all use of std::optional's `opt.value()` with `*opt`
because macOS is great and the ghost of Steve Jobs says that actually
supporting std::optional's value() method is not for chumps before macOS
10.14.  So don't use it because Apple is great.

Pretty much all of our use of it actually is done better with operator*
anyway (since operator* doesn't do a check that the optional has a
value).

Also replaced *most* of the `has_value()` calls with direct bool
context, except for one in the config section which looked really
confusing at a glance without a has_value().
4 years ago
Jason Rhinelander be9ddf2ae1 Bring back ghc::filesystem for broke AF macos
macOS doesn't provide `<filesystem>` support when targetting anything
earlier than 10.15.
4 years ago
Jason Rhinelander a45bec7c4f Removed RPI definition
This was a long-obsolete fix for things that don't matter anymore.
4 years ago
Jason Rhinelander dccc663f31 Miss Match demands her name be removed from the code
(i.e. fix speeling mistack: missmatch -> mismatch)
4 years ago
Jason Rhinelander e470a6d73e C++17 niceties
- class template argument deduction lets us write `std::unique_lock
  foo{mutex}` instead of `std::unique_lock<mutex_type> foo{mutex}` which
  makes the `unique_lock` and `shared_lock` functions unnecessary.

- Replace GNU-specific warn_unused_result attribute with C++17-standard
  [[nodiscard]]

- Remove pre-C++17 workaround code for fold expressions, void_t
4 years ago
Jason Rhinelander 5cf2126bb9 make format 4 years ago
Jason Rhinelander 1697bf90fe C++17
Compiles with C++17, replaces ghc::filesystem with std::filesystem,
nonstd::optional with std::optional, and llarp::string_view with
std::string_view.
4 years ago
Stephen Shelton ca24f25665
Make fewer assumptions about config state
This handles values missing when config is created through RouterHive.
4 years ago
Stephen Shelton de8e44ba21
Re-apply clang-format rules after rebasing 4 years ago
Stephen Shelton be014175e9
Consolidate logging initialization logic 4 years ago
Stephen Shelton 6909e20588
Fix logging initialization and flush at program exit 4 years ago
Stephen Shelton 2479049876
Remove dead code 4 years ago
Stephen Shelton e9708a5d1c
Add split(string_view, char) util function 4 years ago
Stephen Shelton 858e252820
Add stringify() to util/str 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
Jeff d3091cf9fc
Merge pull request #1167 from tewinget/tooling
RouterHive initial PR
4 years ago
Thomas Winget 84a1d7dbcc clang format....... 4 years ago
Rick V 26d1001e53
fix logging 4 years ago
Rick V b449e03f43
So as of GCC 9.2, std::random_device on Windows is RtlGenRandom()
....which is precisely the thing i patch out in libsodium to use CryptoAPI
documented interfaces instead (which fall through to RtlGenRandom() on
such devices _anyway_)
we can just use libsodium directly, i happened to patch it out in libstdc++
as a side effect (since my local toolchain can target any version of windows)
4 years ago
Thomas Winget 68c1ae52b3 add ShortHex function to AlignedBuffer 4 years ago
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.
4 years ago
Jeff Becker 32dbe6b1ad more shiz 4 years ago
Thomas Winget 1e04decb66 can ping on lokinet running in python context! 4 years ago
Thomas Winget 9b3bf833e0 revert nop logging -- un-revert later 4 years ago
Thomas Winget a5c2b369b7 nop logging on hive build for now
a bunch of routers logging to stdout at the same time is a complete
charlie foxtrot.  until we take the time to make logger not a singleton
(and probably make each router able to log to its own file rather than stdout)
just make it not log.

Note: this is very temporary, as the logs will be annoying for testing the
pybind stuff and shouldn't be necessary for debugging it
4 years ago
Rick V 4cd7a22ca3
fix libsodium cross compile 4 years ago
Jeff a8a6c175fc
Merge pull request #1128 from majestrate/use-std-chrono-2020-02-24
make llarp_time_t use std::chrono::milliseconds
4 years ago
Jeff Becker 368acec485
fix last commit 4 years ago
Jeff Becker b2181f2449
reduce code use 4 years ago
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 4 years ago
Jason Rhinelander 3bd400f6fe Fix string_view C++17 compatibility
string_view was implicitly convertible to std::string, but
std::string_view is only explicitly convertible.  This makes the
`operator std::string` explicit to be more compatible, and re-adds a
bunch of explicit string casts to the code where needed.

(This also fixes the build if changing the standard to c++17)
4 years ago
Jeff Becker d2d109e92c
llarp_time_t is now using std::chrono 4 years ago
Jeff Becker f4520ac920
make decaying hashset use llarp::Time_t and move unit tests to use catch2 4 years ago
Jason Rhinelander f976ebbe49 make format 🤦 4 years ago
Jason Rhinelander 55acec80ec Disable thread annotation when not under libc++
They are fairly useless under stdlibc++ because it doesn't have the
required annotations on stl mutexes and locks, so we just get tons of
useless warnings.
4 years ago
Jason Rhinelander 27025030ce Renamed uint128.h -> uint128.hpp 4 years ago
Jason Rhinelander 2093f94244 Make uint128_t use big/little endian layout internally
Thus if someone wants to memcpy out of it it will have the expected
endianness of the internal data.
4 years ago
Jason Rhinelander dba3ff7fd3 gcc 5.x string_view workaround 4 years ago
Jason Rhinelander 0839c16f19 Final abseil purge
Bye-bye Google Boost.
4 years ago
Jason Rhinelander 5ce6c01476 Don't use double-underscores
double-underscore names are reserved for the compiler/STL.
4 years ago
Jason Rhinelander 5fcc11f2bf Fix format 4 years ago
Jason Rhinelander 5d1230d7c9 constexpr string_view fixes
Pre-C++17 char_traits::compare isn't constexpr so we can't constexpr the
find/rfind methods that use it.

begin() etc, however, can be constexpr (and need to be for some of the
other constexpr methods here that use them).
4 years ago
Jason Rhinelander 46242ba69b TrimWhiteSpace -> TrimWhitespace
Fix my dumb initial capitalization choice.
4 years ago
Jason Rhinelander 54186c4a89 Replace absl string_view with string_view from lokimq
When we add loki-mq has a dependency we can just alias it, but for now
it's easier to copy the header than add the whole submodule library.
4 years ago
Jason Rhinelander 5fd830bc36 Prettify uptime duration in log lines
Produces strings such as:

    [+1h09m12.475s]

instead of:

    [+4152475 ms]
4 years ago
Jason Rhinelander 2e9840ea39 Replace abseil date code with Hinnart's date.h
Howard Hinnart's date.h is the library that was accepted as C++20
date/calendar support, so this is essentially a backport of C++20 date
time support.

(It does support timezone support, but requires more of the library and
that seems like overkill for what we need; this just prints UTC
timestamps instead, which need only a header-only include).
4 years ago
Jason Rhinelander ba1b20153e Miscellaneous small absl removals 4 years ago
Jason Rhinelander 5c95971335 Make C++ literals available everywhere in `llarp` 4 years ago
Jason Rhinelander 98c34d995b De-abseil: Add our own llarp::TrimWhiteSpace
Adds a TrimWhiteSpace instead of using abseil's.

Adds Catch2 tests for it, and also converts the existing str tests to
catch (which look much, much nicer than the gtest ones).
4 years ago
Jason Rhinelander 00a624ab40 Fix and rename CaselessCmp -> CaselessLessThan
The comparison done here was really weird: by comparing lengths *before*
contents "zz" would sort before "aaa".  It wasn't invalid for the
specific purpose being used here (looking for true/false values), but
would be highly broken if someone tried to use it elsewhere.

Also renamed it because it really is just a `<` implementation, not a
full cmp implementation.
4 years ago
Jason Rhinelander 7d167d3fe4 Add return types to lambda
Without these the return type could be wrong (e.g. supposed to return a
reference but returns a value).
4 years ago
Jason Rhinelander f84ce61d66 Removed empty cpp files
These aren't needed: CMake already knows how to follow #includes and
rebuild when headers change as long as the headers are included
*somewhere*.  The extra .cpp files here just require building a bunch of
.cpp files with just header content that we just end up throw away
during linking (since the same things will also be compiled in whatever
other compilation units include the same headers).
4 years ago
Jason Rhinelander fe61367a87 Vastly simplified llarp::util::memFn
There is a huge pile of unnecessary machinery here that can be solved
with a few lambdas and some member function pointer type deduction.
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
Jason Rhinelander 05a2e961e6 Add missing header 4 years ago
Jason Rhinelander ac1486d0be Replace absl::optional with optional-lite
Step 1 of removing abseil from lokinet.

For the most part this is a drop-in replacement, but there are also a
few changes here to the JSONRPC layer that were needed to work around
current gcc 10 dev snapshot:

- JSONRPC returns a json now instead of an optional<json>.  It doesn't
  make any sense to have a json rpc call that just closes the connection
  with returning anything.  Invoked functions can return a null (default
  constructed) result now if they don't have anything to return (such a
  null value won't be added as "result").
4 years ago
Jason Rhinelander c522bc0537 ghc::filesystem devendor to submodule
Also removed some unused/old options for conditionally not using
ghc::filesystem and a sodium option that wasn't used anywhere.
4 years ago
Stephen Shelton 68d0cabcc5
Print an error when BDecodeReadFromFile() fails before calling DumpBuffer() 4 years ago
Jeff Becker 7ad47f2dba
* get rid of dht explore for service nodes
* add Time_t using std::chrono for future uses
* make decaying hashset constructor with llarp_time_t explicit
* add decaying hashset implicit constructor using Time_t
* add timeouts for gossiper replay
* allow regossip of our RC
4 years ago
Jason Rhinelander 3be7eb789b Endian defines fix for macOS
It seems `__BYTE_ORDER`/`__LITTLE_ENDIAN`/`__BIG_ENDIAN` aren't defined
on macOS, so `if __BYTE_ORDER == __BIG_ENDIAN` was true which made macOS
take the big endian path *twice* (which cancelled out the big endian
conversion).

This makes util/endian.hpp define __LITTLE_ENDIAN__ or __BIG_ENDIAN__
everywhere, and errors if it can't be set.
4 years ago
Jeff Becker 9efd796145
initial wack at 0.7.0 dht fixes 4 years ago
Jeff Becker 7146857df6
use static initialization for started times 4 years ago
Jeff Becker 7aa1b2c27c
monotonic time and run testnet at 20% realtime 4 years ago
Jeff Becker 2f02073cac
unsigned char 4 years ago
Jeff Becker c69eb2c970
off -> none 4 years ago
Jeff Becker ef0595602b
reduce number of values for LogLevelFromString 4 years ago
Jeff Becker 40876a6e3f
configurable log level 4 years ago
Jeff Becker 73e07ef2d0
client side replay filter 5 years ago
Jeff Becker 7c92805bb4
fix typo 5 years ago
Jeff Becker 562f3f07ab
add unit test for decaying hash set 5 years ago
Jeff Becker a9c9fe9c24
limit client side path builds per ip 5 years ago
Jeff Becker 8b8d636ded
make format 5 years ago
Jason Rhinelander 1b710455a7 Disallow AlignedBuffer < 8 bytes; add oddball buffer sizes 5 years ago
Jason Rhinelander d57d6bfc6d Use memcpy to extract hash value
Using the straight reinterpret_cast runs into type aliasing issues,
which manifest on armhf.  C++20 adds `std::bit_cast` to deal with
exactly this, but memcpy is the pre-C++20 way to do it properly.
5 years ago
Jeff Becker 16c7e7dd33 fix unit tests 5 years ago
Thomas Winget f4c9e09d44 remove obsolete timer-related code 5 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.
5 years ago
Rick V a08d2ff64e
microsoft libc a shit 5 years ago
Rick V caa6549cbb
clang-format everything 5 years ago
Rick V 64710ca4d4
Explicitly align to 16 bytes on Win32 targets 5 years ago
Jeff Becker 896dd85a2b
allow multiple calls to FeedData 5 years ago
Jeff Becker 53b159e361
dont fail on 0 sized data fed to json parser 5 years ago
Stephen Shelton a4aef312ae make format (or format-verify, at least) 5 years ago
Jason Rhinelander d4a5dc66ac Change alignment to std::max_align_t
This will typically be stricter alignment (16 byte on amd64) which seems
useful for the intended use case here.
5 years ago
Jason Rhinelander 460d64fc0f Simplify AlignedBuffer alignment implementation
This simplifies the use of std::aligned_storage with just using an
`alignas` on AlignedBuffer itself so that the (only) data member gets
the proper alignment and saves a bunch of reinterpret_casts in favour of
just having the std::array as an ordinary member.
5 years ago
Stephen Shelton e2e9e63467 Optimize AlignedBuffer:::IsZero() 5 years ago
Jeff Becker 8455d5d1cf more cleanup 5 years ago
Jeff Becker b286230d40 limit timer calls 5 years ago
Jeff Becker 35672e6d8c call timers with queuer if set 5 years ago
Jeff Becker cec36b62b5 make logic and net thread one in the same 5 years ago
Jeff Becker c9d38d421b clang fixes 5 years ago
Jeff fa75d7c96f
Merge pull request #957 from majestrate/reduce-cpu-use-in-tun-handler-2019-12-09
reduce cpu use in logic thread
5 years ago
Jeff Becker a7884a82e2
use faster hashing 5 years ago
Jeff Becker 950006c036
reduce log levels at runtime 5 years ago
Jeff 512a350783
Merge pull request #953 from majestrate/try-preventing-router-lockup-2019-12-07
try fixing router lockup
5 years ago
Jeff Becker c010bf05a6
use correct format string 5 years ago
Jeff Becker f56e543d75
add deadlock checker and revert bencode change from long ago 5 years ago
Jeff Becker c5f198cfa1
disable absl decorator in release 5 years ago
Jeff Becker 2eabe98d9b
add systemd watchdog if enabled on compile time 5 years ago
Jeff Becker 8ceb20452a
add absl annotations 5 years ago
Jeff Becker fe6783eef6
squash possible race condition 5 years ago
Jason Rhinelander 8d2c22fc72 Replace cppbackport with ghc-filesystem
From https://github.com/gulrak/filesystem which is more up-to-date and
looks better maintained than cppbackport.
5 years ago
Jeff 1396b7b857
Merge branch 'dev' into bootstrap-list-2019-12-06 5 years ago
Jeff Becker 0afb3b320b
add bootstrap list functionality and utility 5 years ago
Stephen Shelton 66a058a2af Make format 5 years ago
Jeff 27b1e36039
Merge pull request #936 from majestrate/dev
last changes before 0.6.0 version bump
5 years ago
Stephen Shelton 93b8832026
Merge branch 'dev' into private-keys-backup-support 5 years ago
Jeff 76fc50cfb7
Merge pull request #914 from despair86/dev
win32 fixes
5 years ago
Jeff Becker 7d5fd132c8
make format 5 years ago
Rick V 44e8d07d47
fix error msg 5 years ago
Rick V cf3469e11a
crash on wine, we support linux, ucb_unix, svr4
natively ffs. i tested this patch on wine 4.4 on fuckin
Solaris 11 snv_151
5 years ago
Jeff Becker 3c85691f81 limit calls to pumpll such that it gets called fast enough but not too much under load 5 years ago
Jason Rhinelander 740460318a Die if job queue full
If this happens it's a pretty serious error; if someone is hitting it
occassionally it's better to know and update their queue size (and if it
is a runaway situation lokinet doesn't come back anyway).
5 years ago
Jeff Becker fba1e47d1c call jobs in logic 5 years ago
Thomas Winget 6d506302dc Show number of logic thread jobs in debug builds 5 years ago
Jeff Becker a3a62c34f3 use timer guard for all jobs in debug mode 5 years ago
Jeff Becker af663d8b10 prune members in timer context 5 years ago
Jeff Becker 11d4760c3d add metrics tracking for logic jobs in debug mode 5 years ago
Jeff Becker dd48b149ca
make job queue size configurable 5 years ago
Jeff Becker 853108ce6e
make logic job queue 8 times bigger 5 years ago
Jeff Becker d44d034775
make contention checker templated 5 years ago
Jeff Becker 1fa0a0aab2
make it compile 5 years ago
Jeff Becker fdbaaa8188
try fixing file log segfault 5 years ago
Jeff Becker 1188763ece
typo fix in release 5 years ago
Jeff Becker 56dce90de9
add trace log level for tracking logic thread jobs 5 years ago
Jeff Becker eb6d042e73
make sure all calls of logic thread jobs are not having contention 5 years ago
Jeff Becker d7f09a365d
contention killer 5 years ago
Stephen Shelton db56e17c23 Rename bencode function for clarity 5 years ago
Stephen Shelton 1666498405 Replace bencode_write_version_entry with a more general-purpose function for writing bencoded dictionary entries 5 years ago
Jason Rhinelander e0340e86b2 clang-format fixes 5 years ago
Jason Rhinelander d96d33329b
Merge pull request #912 from majestrate/logic-thread-fix-2019-11-13
fix logic thread behavior
5 years ago
Jason Rhinelander 6524563d33
Merge pull request #897 from majestrate/bencode-seek-for-version-2019-11-03
seek for version and set it before deserializing
5 years ago
Stephen Shelton 9eed243346
Merge pull request #860 from notlesh/null_mutex_clarity
Null mutex clarity (via comments / log statement)
5 years ago
Stephen Shelton 46fe64c2e6 make format (and git commit --amend to re-trigger CI) 5 years ago