Commit Graph

151 Commits (opensuse/tumbleweed)

Author SHA1 Message Date
Jason Rhinelander 91d6698a9d Reformat with clang-format-11 4 years ago
Jason Rhinelander c4559d158e Make format 4 years ago
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).
4 years ago
Jason Rhinelander 5b555ee5aa Replace libuv with uvw & related refactoring
- removes all the llarp_ev_* functions, replacing with methods/classes/functions in the llarp
  namespace.
- banish ev/ev.h to the void
- Passes various things by const lvalue ref, especially shared_ptr's that don't need to be copied
  (to avoid an atomic refcount increment/decrement).
- Add a llarp::UDPHandle abstract class for UDP handling
- Removes the UDP tick handler; code that needs tick can just do a separate handler on the event
  loop outside the UDP socket.
- Adds an "OwnedBuffer" which owns its own memory but is implicitly convertible to a llarp_buffer_t.
  This is mostly needed to take over ownership of buffers from uvw without copying them as,
  currently, uvw does its own allocation (pending some open upstream issues/PRs).
- Logic:
  - add `make_caller`/`call_forever`/`call_every` utility functions to abstract Call wrapping and
    dependent timed tasks.
  - Add inLogicThread() so that code can tell its inside the logic thread (typically for
    debugging assertions).
  - get rid of janky integer returns and dealing with cancellations on call_later: the other methods
    added here and the event loop code remove the need for them.
- Event loop:
  - redo everything with uvw instead of libuv
  - rename EventLoopWakeup::Wakeup to EventLoopWakeup::Trigger to better reflect what it does.
  - add EventLoopRepeater for repeated events, and replace the code that reschedules itself every
    time it is called with a repeater.
  - Split up `EventLoop::run()` into a non-virtual base method and abstract `run_loop()` methods;
    the base method does a couple extra setup/teardown things that don't need to be in the derived class.
  - udp_listen is replaced with ev->udp(...) which returns a new UDPHandle object rather that
    needing gross C-style-but-not-actually-C-compatible structs.
  - Remove unused register_poll_fd_(un)readable
  - Use shared_ptr for EventLoopWakeup rather than returning a raw pointer; uvw lets us not have to
    worry about having the event loop class maintain ownership of it.
  - Add factory EventLoop::create() function to create a default (uvw-based) event loop (previously
    this was one of the llarp_ev_blahblah unnamespaced functions).
  - ev_libuv: this is mostly rewritten; all of the glue code/structs, in particular, are gone as
    they are no longer needed with uvw.
- DNS:
  - Rename DnsHandler to DnsInterceptor to better describe what it does (this is the code that
    intercepts all DNS to the tun IP range for Android).
- endpoint:
  - remove unused "isolated network" code
  - remove distinct (but actually always the same) variables for router/endpoint logic objects
- llarp_buffer_t
  - make constructors type-safe against being called with points to non-size-1 values
- tun packet reading:
  - read all available packets off the device/file descriptor; previously we were reading one packet
    at a time then returning to the event loop to poll again.
  - ReadNextPacket() now returns a 0-size packet if the read would block (so that we can implement
    the previous point).
  - ReadNextPacket() now throws on I/O error
- Miscellaneous code cleanups/simplifications
4 years ago
Jeff Becker 9457da27d9
add option to enforce unique netblocks per path. 4 years ago
Jeff Becker 5fe7e00765
make AuthResultCode an enum class 4 years ago
Jeff Becker 5b2abce86f
add string reason to auth messages 4 years ago
Jeff Becker 6d5f1b0c6a
feedback auth result via lmq rpc 4 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
4 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 3ab7db7723
macos route poking (#1333)
* fix up macos route poker logic

* fix typo

* use string_view

* add forgotten header

* full paths

* add debugging

* catch exception on adding route

* workarround for macos

* typofix

* typofix

* fix for macos

* fix command for macos

* because we autopoke remove explicit route poking in rpc

* probably final fix of macos route poking

* split routes instead of deleting them

* dynamic route poking

* move log statement for introset lookup and dont consider bad sessions as able to send

* send convotag reset frame when we have no session

* add exit map to rpc

* use split_any
4 years ago
Jeff 60f4d96ba5
proper route poking (#1330)
* route poking:

* remove popen() call, replace with reading /proc/net/route for getting default route
* dynamically poke and unpoke routes on runtime

* swap intros and fix rpc endpoint for version to return what the ui expects

* use std::string::find_first_not_of instead of using a lambda
4 years ago
Jeff Becker f4971a88fd
use lokimq workers instead of llarp:🧵:ThreadPool 4 years ago
Jeff Becker c6885ec285
remove Endpoint::GetExitRouters() 4 years ago
Jeff Becker 6af498092b
exit traffic via loki addresses 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 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 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.
5 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 5 years ago
Jeff Becker d2d109e92c
llarp_time_t is now using std::chrono 5 years ago
Jeff Becker 39cdc9e6dd
shift intro on introset update 5 years ago
Jeff 6ac5f19b3a
Merge pull request #1110 from jagerman/no-abseil-optional
De-abseil, part 1: remove absl::optional
5 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").
5 years ago
Jeff Becker 1874f439b7
add comment 5 years ago
Jeff Becker e907d2ae19
handover fixes 5 years ago
Jeff Becker f7f5d893a5
use endpoint path for lookup because outboundcontext does not implement pathset::HandleGotIntroMessage 5 years ago
Jeff Becker c9866b6a0b
simplify 5 years ago
Jeff Becker 9aeee37347
short circuit 5 years ago
Jeff Becker 6a495dd090
ammend outbound context logic 5 years ago
Jeff Becker 02228ded08
spread out path builds 5 years ago
Jason Rhinelander 24469daefb Remove unused parameter
We always randomize now.
5 years ago
Stephen Shelton 9dfcfbc3ac Bencode/decode relayOrder in lexigraphical order, make it uint64_t 5 years ago
Stephen Shelton 906803e387 Refactor DHT introset lookups to use redundant lookup strategy 5 years ago
Jeff Becker 4d4b33607f dont use optional 5 years ago
Jeff Becker df8c56343d refactor GetManyPathsWithUniqueEndpoints to go into service/endpoint_util.hpp 5 years ago
Jeff Becker 8c698a1cd1
* rename i to foundIntro
* check for zero timestamp
* use > not >=
5 years ago
Jeff Becker 41210a8ae1
check for current introset being zero (initial state) 5 years ago
Jeff Becker 99eb7726ff
initial dht key blinding 5 years ago
Jeff 0ad2809ac7
Merge pull request #1033 from majestrate/prevent-segfault-2020-01-10
prevent segfault
5 years ago
Jeff Becker 77f0944d6d
use shared_from_this 5 years ago
Jeff Becker 78e325c4c5
always lookup introset from nearest router 5 years ago
Jeff Becker 3147e2d357
shuffle intros when more than 1 exists 5 years ago
Jeff Becker b3ad65f470
randomize intro order on shift 5 years ago
Jeff Becker 79c3c748e4
limit number of snode sessions client side 5 years ago
Jeff Becker 28a2d471d6 style nitch 5 years ago
Jeff Becker 285a9a1dd5 prevent segfault 5 years ago
jeff 32ed821763 Merge remote-tracking branch 'upstream/dev' into multithreaded-cryptography 5 years ago
jeff f9fb40f590 final touches 5 years ago
jeff 7c691cf334 handover should be fixed now 5 years ago
Jeff Becker 993e4c2637
try fixing handover 5 years ago
jeff 6c2ebbb925 try fixing handover and add snapp traffic to multithreaded crypto workers 5 years ago
Jeff Becker 1adae338ce
Merge remote-tracking branch 'origin/master' 5 years ago
Michael 4d8fe2a8a8
Move meta programming to subdirectory 5 years ago
Jeff Becker c01112e4b7
tracy lock contention testing and other fun things 5 years ago
Jeff 093021ef99 try fixing handover drop bug 5 years ago
Michael 094b697b01
Replace StatusObject with underlying JSON type 5 years ago
Michael 16cdfbd5f0
clang-tidy modernize pass 5 years ago
Jeff Becker f48754c45d
make hop count and length configurable 5 years ago
Michael e52492911d
Refactor endpoint state management to a new class 5 years ago
Jeff Becker 1fd6b5ae74
Merge remote-tracking branch 'origin/master' into ipv6-tun 5 years ago
Michael 488695047f
Remove redundant else blocks 5 years ago
Jeff Becker b9bcc2b775
make threadpool consice 5 years ago
Jeff Becker 5874c38b38
swap path on inbound convo if expires soon 5 years ago
Jeff Becker 64e9622270
start seperating tun and endpoint 5 years ago
Jeff Becker fbf01bd129
fix order 5 years ago
Jeff Becker 1061ae4fee
set outbound context to be outbound session 5 years ago
Jeff Becker 6ab3678f5c
correct comparison 5 years ago
Jeff Becker 5c8b17154c
swap intros only on path build success 5 years ago
Jeff Becker 4734fa91fe
check for zero 5 years ago
Jeff Becker f66e37ca37
oooof 5 years ago
Jeff Becker 289eb2a04c
fix previous commit 5 years ago
Jeff Becker 5c679a10e8
outbound context build more 5 years ago
Jeff Becker 8830ac8fac
tweak 5 years ago
Jeff Becker b0612e2ee1
Merge remote-tracking branch 'origin/master' into ipv6-tun 5 years ago
Michael b6b400baef
Tidy up pathbuilder code 5 years ago
Jeff Becker d8aebf36fb
swap intros on message rejection 5 years ago
Jeff Becker 1883c63997
swap intros on message rejection 5 years ago
Jeff Becker 2403ab8f86
ipv6 5 years ago
Michael 75430a234c
Convert to use memFn 5 years ago
Michael 491fee206b
Port code to use CryptoManager over passing Crypto pointers 5 years ago
Jeff Becker 41523b934c
more 5 years ago
Jeff Becker 2ac89c0afb
DRY 5 years ago
Jeff Becker 81f73bccc2
pick newer intros only 5 years ago
Jeff 06f8bb2f42 add blacklist-snode option 5 years ago
Jeff Becker 3821b4801c
fix intro section to not use first hop as intro 5 years ago
Jeff Becker e7a40ac4e5
Revert "permit outbound context to select an intro who is a first hop."
This reverts commit c8c00e2d9f.
5 years ago
Jeff Becker c8c00e2d9f
permit outbound context to select an intro who is a first hop. 5 years ago
Jeff Becker df322e1149
don't include duplicate hops in paths 5 years ago
Jeff Becker dee639500a
set intro 5 years ago
Jeff Becker 34533db620
add urgent build that builds over an existing path for an endpoint 5 years ago
Jeff Becker 5b49008bca
more 5 years ago
Jeff 01906c5d94 Merge remote-tracking branch 'origin/master' 6 years ago
Michael 0b4d787042
More work on router docker image
- Multi-stage docker build (final image only 15MB!)
- Build in release mode
    - Fix bug with release mode
    - Fix compiler being dumb AF
    - Disable FORTIFY for now
- Enable LTO when making a staticly linked release
- Fix some gcc specific warnings
- Refactor cmake stuff into multiple files
6 years ago
Jeff Becker 5921086391
common codepath for sending protocol frames 6 years ago
Jeff Becker 6711296b26
finish converting to shared_ptr 6 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.
6 years ago
Jeff Becker a2912ff860
Merge remote-tracking branch 'origin/master' 6 years ago
Michael e33a33635c
Remove usage of raw new from service classes 6 years ago
Jeff Becker 3a8cb0bfb5
add shell based hooks for service::Endpoint, also make format 6 years ago