Commit Graph

134 Commits

Author SHA1 Message Date
Jeff Becker
e48feb8b9a
kill outbound context when we remove our convotag 2021-06-21 15:16:26 -04:00
Jeff Becker
ce7643a3aa
remove case that spams build on an outbound context 2021-06-09 09:36:08 -04:00
Jeff Becker
c97fe4aa96
convert magic number to where it came from 2021-06-08 18:07:54 -04:00
Jeff Becker
e2bdf8792b
typofix 2021-06-08 17:27:50 -04:00
Jeff Becker
c2722be81c
this fixes the shit wtf 2021-06-08 14:36:33 -04:00
Jeff Becker
0096bd4e35
account for path latency in introset lookups on outbound contexts 2021-06-08 14:36:32 -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
c6660dd6c1
add path aligntment timeout to send and connect timeouts on outbound context to reduce the chance of timing race conditon 2021-06-08 14:36:32 -04:00
Jeff Becker
0f1e806155
don't kill outbound context after build or lookup fails 2021-06-08 14:36:32 -04:00
Jeff Becker
220b8837da
delay setting sentIntro by the advertised latency of the remote intro instead of static value 2021-06-08 14:36:31 -04:00
Jeff Becker
c5a86a49a3
defer ready to send state until after we send a handshake 2021-06-08 14:36:31 -04:00
Jeff Becker
40a189a9a3
log drop events more 2021-06-08 14:36:31 -04:00
Jeff Becker
a94c100e7b
improve log messages about expiring convotags 2021-06-08 14:36:30 -04:00
Jeff Becker
8dd1358cc6
* tweak introset handover timeouts
* introset path haodver tweaks
* improve warn/error messages to convey more information
* dont block on queue insertion
* reset convotag on decrypt/verify fail
* add multiple ready hooks on outbound context
* lookup introsets from close routers on dht
* continue to tick dead sessions so they expire their paths
* introset spacing
* reduce lns lookup diversity requirement for speed
* add a function to send reset convotag message
* only have 1 outbound context at a time
2021-06-08 14:36:30 -04:00
Jeff Becker
9a1a022d62
add relayOrder awareness to introset lookups.
* only propgate fail when relay order is non zero as zero relay order often fails
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
f172db75c5
don't defer call to ready hook with timer call it right away because we are ready 2021-05-16 19:31:59 -04:00
Jeff Becker
432e7f2a5a
update introset if we get a discard message from a possibly expired intro 2021-05-16 16:27:48 -04:00
Jeff Becker
970ccfcd4e
send a keep alive to keep an idle session alive so it doesn't get removed 2021-05-16 05:59:39 -04:00
Jeff Becker
38cc130dc3
shift off bad intros when we get a discard message, this happens if the
other side's intro expires or the pivot restarts for whatever reason.
2021-05-10 09:01:46 -04:00
Jeff Becker
d3d929efa7
fixups in service endpoint
* increase publish introset timeout so that it does not time out on the network
* remove pedantic log warn
* make sure the path we are using for replying on inbound sessions is alive
* include convotag in log message so we know wtf is going on
* appease tom's autism, improve log message text
2021-05-06 16:34:24 -04:00
Jeff Becker
f9fe6f7e3b
consmetic fixes
* print names in lookup jobs instead of yyyyyy
* update syntax in construction of objects
2021-05-01 08:59:56 -04:00
Jeff Becker
b31a484bc9
fix up outbound session
* prevent introset lookup spam
* change return values to void becuase bool doesn't mean fucking shit at all
2021-05-01 08:52:41 -04:00
Jeff Becker
fedc56e3f1
initial commit for #1595 2021-04-19 07:02:46 -04:00
Jeff Becker
5b05d22bad
refactors
* add path sequence numbers on routing messages
* reduce log level in debug mode
* wire up loopback style sending to ourself
2021-04-19 06:59:06 -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
Jeff Becker
100a953a23
make the lokinet endpoint code work
still needs the quic sides to work
2021-04-19 06:58:37 -04:00
Jeff Becker
7098f46d60
rpc endpoint for triggering quic tunnel 2021-04-19 06:58:37 -04:00
Jeff Becker
9d483a12db
* add protocol type to snode traffic
* make path::PathSet::SendPacketToRemote know about protocol type
2021-04-19 06:58:35 -04:00
Jeff
cb2254ba46
Merge pull request #1573 from jagerman/more-code-refactors
More code refactors
2021-03-23 16:22:23 -04:00
Jeff Becker
1acea95ced
fix issue #1562
* use csrng for std::shuffle
2021-03-18 17:36:53 -04:00
Jason Rhinelander
0339bd941a Convert protocol type to enum class 2021-03-10 11:16:55 -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
c4559d158e Make format 2021-03-04 16:51:18 -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
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
2021-03-04 16:51:18 -04:00
Jeff Becker
9457da27d9
add option to enforce unique netblocks per path. 2021-03-02 07:20:28 -05:00
Jeff Becker
5fe7e00765
make AuthResultCode an enum class 2021-02-24 14:08:21 -05:00
Jeff Becker
5b2abce86f
add string reason to auth messages 2021-02-24 14:08:21 -05:00
Jeff Becker
6d5f1b0c6a
feedback auth result via lmq rpc 2021-02-24 14:07:50 -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
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
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
2020-09-03 18:22:22 -04:00
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
2020-09-01 17:22:22 -04:00
Jeff Becker
f4971a88fd
use lokimq workers instead of llarp:🧵:ThreadPool 2020-07-02 11:07:34 -04:00
Jeff Becker
c6885ec285
remove Endpoint::GetExitRouters() 2020-06-01 09:35:21 -04:00
Jeff Becker
6af498092b
exit traffic via loki addresses 2020-05-23 16:07:19 -04:00
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().
2020-05-20 19:18:28 -03:00