Commit Graph

454 Commits

Author SHA1 Message Date
Jason Rhinelander
0839c16f19 Final abseil purge
Bye-bye Google Boost.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
5ce6c01476 Don't use double-underscores
double-underscore names are reserved for the compiler/STL.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
5fcc11f2bf Fix format 2020-02-24 14:27:44 -04:00
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).
2020-02-24 14:27:44 -04:00
Jason Rhinelander
46242ba69b TrimWhiteSpace -> TrimWhitespace
Fix my dumb initial capitalization choice.
2020-02-24 14:27:44 -04:00
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.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
5fd830bc36 Prettify uptime duration in log lines
Produces strings such as:

    [+1h09m12.475s]

instead of:

    [+4152475 ms]
2020-02-24 14:27:44 -04:00
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).
2020-02-24 14:27:44 -04:00
Jason Rhinelander
ba1b20153e Miscellaneous small absl removals 2020-02-24 14:27:44 -04:00
Jason Rhinelander
5c95971335 Make C++ literals available everywhere in llarp 2020-02-24 14:27:44 -04:00
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).
2020-02-24 14:27:44 -04:00
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.
2020-02-24 14:27:44 -04:00
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).
2020-02-22 12:17:53 -04:00
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).
2020-02-21 23:39:11 -04:00
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.
2020-02-21 23:24:33 -04: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
Jason Rhinelander
05a2e961e6 Add missing header 2020-02-20 11:49:18 -04:00
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").
2020-02-19 18:21:25 -04:00
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.
2020-02-13 15:47:11 -04:00
Stephen Shelton
68d0cabcc5
Print an error when BDecodeReadFromFile() fails before calling DumpBuffer() 2020-02-13 08:19:10 -07:00
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
2020-02-12 12:10:48 -05:00
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.
2020-02-07 03:29:50 -04:00
Jeff Becker
9efd796145
initial wack at 0.7.0 dht fixes 2020-01-27 11:54:51 -05:00
Jeff Becker
7146857df6
use static initialization for started times 2020-01-23 12:14:26 -05:00
Jeff Becker
7aa1b2c27c
monotonic time and run testnet at 20% realtime 2020-01-23 12:14:25 -05:00
Jeff Becker
2f02073cac
unsigned char 2020-01-20 16:16:00 -05:00
Jeff Becker
c69eb2c970
off -> none 2020-01-20 16:12:19 -05:00
Jeff Becker
ef0595602b
reduce number of values for LogLevelFromString 2020-01-20 16:11:34 -05:00
Jeff Becker
40876a6e3f
configurable log level 2020-01-20 16:00:08 -05:00
Jeff Becker
73e07ef2d0
client side replay filter 2020-01-03 06:04:47 -05:00
Jeff Becker
7c92805bb4
fix typo 2019-12-30 17:03:19 -05:00
Jeff Becker
562f3f07ab
add unit test for decaying hash set 2019-12-30 15:52:10 -05:00
Jeff Becker
a9c9fe9c24
limit client side path builds per ip 2019-12-30 15:15:19 -05:00
Jeff Becker
8b8d636ded
make format 2019-12-22 09:16:28 -05:00
Jason Rhinelander
1b710455a7 Disallow AlignedBuffer < 8 bytes; add oddball buffer sizes 2019-12-19 16:17:02 -04:00
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.
2019-12-19 15:55:02 -04:00
Jeff Becker
16c7e7dd33 fix unit tests 2019-12-19 10:25:52 -05:00
Thomas Winget
f4c9e09d44 remove obsolete timer-related code 2019-12-18 19:05:33 -05:00
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.
2019-12-18 13:11:13 -05:00
Rick V
a08d2ff64e
microsoft libc a shit 2019-12-16 11:32:50 -06:00
Rick V
caa6549cbb
clang-format everything 2019-12-16 11:32:49 -06:00
Rick V
64710ca4d4
Explicitly align to 16 bytes on Win32 targets 2019-12-16 11:28:48 -06:00
Jeff Becker
896dd85a2b
allow multiple calls to FeedData 2019-12-15 12:01:29 -05:00
Jeff Becker
53b159e361
dont fail on 0 sized data fed to json parser 2019-12-15 11:59:26 -05:00
Stephen Shelton
a4aef312ae make format (or format-verify, at least) 2019-12-12 10:09:57 -07:00
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.
2019-12-12 12:15:13 -04:00
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.
2019-12-12 12:12:45 -04:00
Stephen Shelton
e2e9e63467 Optimize AlignedBuffer:::IsZero() 2019-12-10 11:50:52 -07:00
Jeff Becker
8455d5d1cf more cleanup 2019-12-10 11:49:32 -07:00
Jeff Becker
b286230d40 limit timer calls 2019-12-10 11:49:32 -07:00
Jeff Becker
35672e6d8c call timers with queuer if set 2019-12-10 11:49:32 -07:00
Jeff Becker
cec36b62b5 make logic and net thread one in the same 2019-12-10 11:49:32 -07:00
Jeff Becker
c9d38d421b clang fixes 2019-12-10 11:49:32 -07:00
Jeff
fa75d7c96f
Merge pull request #957 from majestrate/reduce-cpu-use-in-tun-handler-2019-12-09
reduce cpu use in logic thread
2019-12-09 17:35:27 -05:00
Jeff Becker
a7884a82e2
use faster hashing 2019-12-09 17:35:05 -05:00
Jeff Becker
950006c036
reduce log levels at runtime 2019-12-09 08:08:30 -05:00
Jeff
512a350783
Merge pull request #953 from majestrate/try-preventing-router-lockup-2019-12-07
try fixing router lockup
2019-12-09 07:38:17 -05:00
Jeff Becker
c010bf05a6
use correct format string 2019-12-07 15:05:07 -05:00
Jeff Becker
f56e543d75
add deadlock checker and revert bencode change from long ago 2019-12-07 14:58:19 -05:00
Jeff Becker
c5f198cfa1
disable absl decorator in release 2019-12-07 14:22:10 -05:00
Jeff Becker
2eabe98d9b
add systemd watchdog if enabled on compile time 2019-12-07 14:21:26 -05:00
Jeff Becker
8ceb20452a
add absl annotations 2019-12-07 07:28:43 -05:00
Jeff Becker
fe6783eef6
squash possible race condition 2019-12-07 07:19:26 -05:00
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.
2019-12-06 20:41:22 -04:00
Jeff
1396b7b857
Merge branch 'dev' into bootstrap-list-2019-12-06 2019-12-06 15:34:38 -05:00
Jeff Becker
0afb3b320b
add bootstrap list functionality and utility 2019-12-06 12:32:46 -05:00
Stephen Shelton
66a058a2af Make format 2019-12-06 10:13:09 -07:00
Jeff
27b1e36039
Merge pull request #936 from majestrate/dev
last changes before 0.6.0 version bump
2019-12-03 15:58:22 -05:00
Stephen Shelton
93b8832026
Merge branch 'dev' into private-keys-backup-support 2019-12-03 11:20:45 -07:00
Jeff
76fc50cfb7
Merge pull request #914 from despair86/dev
win32 fixes
2019-12-03 13:08:55 -05:00
Jeff Becker
7d5fd132c8
make format 2019-12-03 12:55:24 -05:00
Rick V
44e8d07d47
fix error msg 2019-12-01 19:01:58 -06:00
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
2019-12-01 19:01:40 -06:00
Jeff Becker
3c85691f81 limit calls to pumpll such that it gets called fast enough but not too much under load 2019-11-29 19:11:14 -04:00
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).
2019-11-29 19:11:14 -04:00
Jeff Becker
fba1e47d1c call jobs in logic 2019-11-29 19:11:14 -04:00
Thomas Winget
6d506302dc Show number of logic thread jobs in debug builds 2019-11-29 19:11:14 -04:00
Jeff Becker
a3a62c34f3 use timer guard for all jobs in debug mode 2019-11-29 19:11:14 -04:00
Jeff Becker
af663d8b10 prune members in timer context 2019-11-29 19:11:14 -04:00
Jeff Becker
11d4760c3d add metrics tracking for logic jobs in debug mode 2019-11-29 19:11:14 -04:00
Jeff Becker
dd48b149ca
make job queue size configurable 2019-11-25 16:30:34 -05:00
Jeff Becker
853108ce6e
make logic job queue 8 times bigger 2019-11-25 16:15:31 -05:00
Jeff Becker
d44d034775
make contention checker templated 2019-11-22 16:23:19 -05:00
Jeff Becker
1fa0a0aab2
make it compile 2019-11-22 16:23:19 -05:00
Jeff Becker
fdbaaa8188
try fixing file log segfault 2019-11-22 16:23:19 -05:00
Jeff Becker
1188763ece
typo fix in release 2019-11-22 16:23:19 -05:00
Jeff Becker
56dce90de9
add trace log level for tracking logic thread jobs 2019-11-22 16:23:19 -05:00
Jeff Becker
eb6d042e73
make sure all calls of logic thread jobs are not having contention 2019-11-22 16:23:18 -05:00
Jeff Becker
d7f09a365d
contention killer 2019-11-22 16:23:18 -05:00
Stephen Shelton
db56e17c23 Rename bencode function for clarity 2019-11-22 14:14:37 -07:00
Stephen Shelton
1666498405 Replace bencode_write_version_entry with a more general-purpose function for writing bencoded dictionary entries 2019-11-22 10:39:35 -07:00
Jason Rhinelander
e0340e86b2 clang-format fixes 2019-11-20 17:45:56 -04:00
Jason Rhinelander
d96d33329b
Merge pull request #912 from majestrate/logic-thread-fix-2019-11-13
fix logic thread behavior
2019-11-19 15:26:35 -04:00
Jason Rhinelander
6524563d33
Merge pull request #897 from majestrate/bencode-seek-for-version-2019-11-03
seek for version and set it before deserializing
2019-11-19 15:24:07 -04:00
Stephen Shelton
9eed243346
Merge pull request #860 from notlesh/null_mutex_clarity
Null mutex clarity (via comments / log statement)
2019-11-19 11:19:44 -07:00
Stephen Shelton
46fe64c2e6 make format (and git commit --amend to re-trigger CI) 2019-11-19 10:07:27 -07:00
Jeff Becker
168d25f244
add warning when trying to queue onto full logic thread 2019-11-14 12:18:20 -05:00
Jeff Becker
f16c9f9b5d
iot seems that logic thread didn't work the way i remember it should
make logic work the way it should
2019-11-14 10:06:53 -05:00
Jeff Becker
3c8e148372
prevent double free crap with shared_ptr 2019-11-13 18:16:34 -05:00
Jeff Becker
b589ea96ff
remove printf 2019-11-05 12:00:33 -05:00
Jeff Becker
7ee026fa50
make path builds work again 2019-11-05 11:58:53 -05:00
Jeff Becker
bdb0b847f8
seek for version and set it before deserializing 2019-11-03 10:31:01 -05:00
Stephen Shelton
a3c48e22f3
Even more clarity to NullMutex comments 2019-10-11 13:50:50 -06:00
Stephen Shelton
36ef0954ec Add comments to NullMutex implementation to express intent 2019-10-10 23:26:55 -06:00
jeff
7d949ebf5d always use absl for string_view 2019-10-02 11:35:20 -04:00
jeff
605da68e15 use absl optional 2019-10-02 09:17:12 -04:00
jeff
3c1d5518d8 fix windows port and make it compile 2019-10-02 09:06:14 -04:00
jeff
da9437d0cf don't need that 2019-10-01 11:05:37 -04:00
jeff
32ed821763 Merge remote-tracking branch 'upstream/dev' into multithreaded-cryptography 2019-10-01 10:51:28 -04:00
Michael
5f0bb6fbd1
Try to fix windows build 2019-09-24 09:51:54 +01:00
Michael
ae3fc3a395
Add initial macOS app 2019-09-24 09:50:57 +01:00
Jeff Becker
327c545530
finish multithread cryptography first pass 2019-09-16 12:12:05 -04:00
jeff
14c9ef15ed try calling stuff in logic thread from event loop 2019-09-16 06:21:12 -04:00
jeff
ac2a2aed1d gut libutp and finish making things compile and pass tests 2019-09-12 14:19:25 -04:00
Jeff Becker
e3bb59707e
more 2019-09-05 17:28:50 -04:00
Michael
19473a291a
Abort when a null mutex is locked from a different thread (in debug mode only) 2019-09-04 22:34:41 +01:00
Jeff Becker
ab64c0d013
Merge remote-tracking branch 'micheal/abort_mutex' 2019-09-04 07:58:48 -04:00
Jeff Becker
1adae338ce
Merge remote-tracking branch 'origin/master' 2019-09-04 07:58:02 -04:00
Michael
23d76e3600
Abort when a null mutex is locked from a different thread (in debug mode only) 2019-09-03 23:25:37 +01:00
Michael
edd0ec398f
Move thread stuff to subdirectory 2019-09-03 20:52:28 +01:00
Michael
0950571313
Move metrics to subdirectory 2019-09-03 20:52:28 +01:00
Michael
4d8fe2a8a8
Move meta programming to subdirectory 2019-09-03 20:52:28 +01:00
Michael
1aec0dfa2b
Move logging to subdirectory 2019-09-03 20:52:27 +01:00
Jeff Becker
c01112e4b7
tracy lock contention testing and other fun things 2019-09-03 11:56:56 -04:00
Rick V
55612bc032
ok use clang-format v8 2019-08-26 03:32:40 -05:00
Rick V
2000826a35
override print 2019-08-26 03:32:40 -05:00
Rick V
50d4b4b40c
fix log colours on old win32 platforms 2019-08-26 03:32:39 -05:00
Michael
094b697b01
Replace StatusObject with underlying JSON type 2019-08-19 10:33:26 +01:00
Michael
16cdfbd5f0
clang-tidy modernize pass 2019-08-12 16:52:58 +01:00
Michael
d1990b5e93
Fix suspicious thread-unsafety 2019-08-08 00:18:56 +01:00
Jeff
10d7e7cb77
Merge branch 'master' into master 2019-08-05 07:59:30 -04:00
Michael
f9e9227e19
Fix gcc trunk warnings 2019-08-02 10:29:08 +01:00
Rick V
8cf5f2c9a5 fix thread naming on windows 2019-08-01 23:42:32 -05:00
Rick V
f6c97091fd
clang-format 2019-08-01 22:25:48 -05:00
Rick V
609a9a1c31
fix netbsd 2019-08-01 21:39:51 -05:00
Rick V
a0a14b97a0
really fix #689 this time 2019-08-01 21:39:50 -05:00
Rick V
3782479276
fix sun 2019-08-01 21:39:49 -05:00
Michael
a062186f2d
or not 2019-07-29 23:23:55 +01:00
Michael
ee2dd0fb68
Use __cpp_lib_filesystem 2019-07-29 21:44:14 +01:00
Michael
3c2f7792c2
Fixup 2019-07-29 21:32:29 +01:00
Michael
614b669fd5
Abandon debian 2019-07-29 21:31:26 +01:00
Michael
df498c7bf8
try to make some windows 2019-07-29 21:31:26 +01:00
Jeff Becker
b0406e1a76
on logic queue overflow put job on timer instead 2019-07-28 13:13:52 -04:00
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
2019-07-25 17:46:56 -04:00
Jeff
183ec25717
Merge pull request #729 from majestrate/fix-android-2019-07-24
make android compile again
2019-07-25 14:24:13 -04:00
Thomas Winget
baf8019fe5 Refactor Router code into more classes
This commit refactors functionality from the Router class into separate,
dedicated classes.
There are a few behavior changes that came as a result of discussion on
what the correct behavior should be.
In addition, many things Router was previously doing can now be provided
callback functions to alert the calling point when the asynchronous
action completes, successfully or otherwise.
2019-07-25 14:11:02 -04:00
Jeff Becker
43cb62af16
fix android compile, have makefile pull in libuv for cmake on android 2019-07-24 11:25:40 -04:00
Jeff Becker
909e0399d6
make android compile 2019-07-24 10:17:54 -04:00
Michael
53bccc4f23
try to ensure on windows, but don't fail 2019-07-21 16:57:12 +01:00
Michael
9b40c0eb67
Fixup some tests 2019-07-21 16:57:12 +01:00