Commit Graph

78 Commits

Author SHA1 Message Date
Jason Rhinelander
7c964800ba
Fix unintentional whitelist/greylist copying 2021-06-07 16:16:18 -04:00
Jeff Becker
95537804cd
separate white/grey list for active/decommissioned nodes.
allow sessions to decommissioned nodes but not paths.
2021-06-07 10:57:33 -04:00
Jeff Becker
9ad90d029d
* use weak_ptr on core rpc
* use reachability testing code lifted storage server's code
2021-06-07 08:41:35 -04:00
Jeff Becker
499bb38e6f
fix route poking via rpc:
* immediately poke routes when we are told to use an exit so that packets get pushed which makes an exit path happen
* fix up cmake oddity in nsis section
2021-05-13 07:30:53 -04:00
Jeff Becker
ec62228149
limit path builds across all builders 2021-05-05 08:21:39 -04:00
Jeff Becker
545021aa3d
temp commit 2021-04-19 07:02:46 -04:00
Jeff Becker
25e338d621
srv records
* add srv records in RCs if we have any
* add mechanism to add SRV records for plainquic exposed ports
* resign and republish rc or introset on srv record changes
2021-04-19 07:02:43 -04:00
Jason Rhinelander
2ca7ef7f5f
Rename isRouter -> isSNode
The isRouter wording was quite confusing, especially in a call such as:

    router->Configure(config, opts.isRouter, nodedb)
2021-04-19 06:58:36 -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
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
Thomas Winget
4c630e0437 Large collection of changes to make android work
- Previous android java and jni code updated to work, but with much love
  still needed to make it work nicely, e.g. handling when the VPN is
  turned off.

- DNS handling refactored to allow android to intercept and handle DNS
  requests as we can't set the system DNS to use a high port
  (and apparently Chrome ignores system DNS settings anyway)

- add packet router structure to allow separate handling of specific
  intercepted traffic, e.g. UDP traffic to port 53 gets handled by our
  DNS handler rather than being naively forwarded as exit traffic.

- For now, android lokinet is exit-only and hard-coded to use exit.loki
  as its exit.  The exit will be configurable before release, but
  allowing to not use exit-only mode is more of a challenge.

- some old gitignore remnants which were matching to things we don't
  want them to (and are no longer relevant) removed

- some minor changes to CI configuration
2021-03-02 13:18:22 -05:00
Jeff Becker
ffef3bc48f
wire up sigusr1 to reset libunbound dns resolver 2021-02-17 13:32:55 -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
49b9ad7197
tun code refactor (#1495)
* partial tun code refactor

* take out the trash

* move vpn platform code into llarp/vpn/platform.cpp

* fix hive build

* fix win32

* fix memory leak on win32

* reduce cpu use

* make macos compile

* win32 patches:

* use wepoll for zmq
* use all cores on windows iocp read loop

* fix zmq patch for windows

* clean up cmake for win32

* add uninstall before reinstall option to win32 installer

* more ipv6 stuff

* make it compile

* fix up route poker

* remove an unneeded code block in macos wtf

* always use call to system

* fix route poker behavior on macos

* disable ipv6 on windows for now

* cpu perf improvement:

* colease calls to Router::PumpLL to 1 per event loop wakeup

* set up THEN add addresses

* emulate proactor event loop on win32

* remove excessively verbose error message

* fix issue #1499

* exclude uv_poll from win32 so that it can start up

* update logtag to include directory

* create minidump on windows if there was a crash

* make windows happy

* use dmp suffix on minidump files

* typo fix

* address feedback from jason
* use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR
* quote $@ in apply-patches in case path has spaces in it

* address feedback from tom

* remove llarp/ev/pipe
* add comments for clairification
* make event loop queue size constant named
2021-01-11 18:13:22 -05:00
Jeff
252692a55b
dont poke routes if we have no exit (#1352)
* * refactor route poking out of llarp::Router and into llarp::RoutePoker
* only poke routes when we have an exit enabled as a client

* add route_poker header so it compiles
2020-09-23 20:28:38 -04:00
jeff
5391e6a66a initial config overriding on runtime 2020-08-27 12:43:53 +00:00
jeff
f6f56029d3
working netlink route poker 2020-08-24 20:23:26 -04:00
Stephen Shelton
0f074cff8c
Remove ambguity WRT loading and passing of Config 2020-07-06 13:38:02 -06:00
Stephen Shelton
552dcce5fd
Use inheritance to handle Hive injection 2020-07-02 10:25:10 -06:00
Stephen Shelton
aeb0c2be3a
Remove ability to stop routers from gossiping for now 2020-07-02 10:22:03 -06:00
Stephen Shelton
bdac43e19f
Peer stats test which artificially stops a router from gossiping its RC 2020-07-02 10:22:03 -06:00
Stephen Shelton
595288e046
Add PeerDb::handleGossipedRC 2020-07-02 10:13:22 -06:00
Jeff Becker
d7ff6c579c
address feedback from jason
* split up ipv6 netmask
* revert iwp ack interval change
* c++17-isms in ip range map
* lambda-ize nodedb
* mutable lambdas in transit hops
* perfect forwarding of args in abstract router
* mutable lambdas in lokid rpc client
* notes in readme about nproc
2020-07-02 11:13:32 -04:00
Jeff Becker
e13e886df9
fix up event loop crap so that unit tests pass 2020-07-02 11:10:06 -04:00
Jeff Becker
397d558af8
wtf 2020-07-02 11:07:34 -04:00
Jeff Becker
59eb1b0842
make format 2020-07-02 11:07:34 -04:00
Jeff Becker
f1e7fc2cba
make format and update submodule 2020-07-02 11:07:34 -04:00
Jeff Becker
f4971a88fd
use lokimq workers instead of llarp:🧵:ThreadPool 2020-07-02 11:07:34 -04:00
Jeff Becker
ad882d0d70
initial working code 2020-07-02 11:07:31 -04:00
Jeff Becker
0006751d80
initial wack at lokimq 2020-07-02 11:07:31 -04:00
Stephen Shelton
1497b829bd
Ignore our self.signed file if we're a client 2020-06-04 11:05:23 -06:00
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.
2020-04-07 12:38:56 -06:00
Stephen Shelton
ea835405c5
Refactor NotifyRouterEvent() to forward args, event code cleanup
This template-ifies Router::NotifyRouterEvent() up so that it accepts
the arguments to instantiate the specified event type, forwarding them
to std::make_unique. This would allow (in the future) the function to
no-op the call and avoid memory allocation. It also slightly reduces
the amount of code required to fire an event.

This commit also simplifies some of the RouterEvent code to reduce
redundancy.
2020-03-12 11:50:46 -06:00
Thomas Winget
84a1d7dbcc clang format....... 2020-03-06 20:20:11 -05:00
Thomas Winget
f712acc486 huzzah it builds, time to test soon! 2020-03-03 19:57:09 -05:00
Jeff Becker
da79b14703 make it compile 2020-03-03 19:57:09 -05:00
Thomas Winget
8dc5dabe49 working toward compilation, still has include issue 2020-03-03 19:57:09 -05:00
Thomas Winget
8d03e6dd3c more router hive stuff, read below the fold
Router now has a hive pointer if LOKINET_HIVE is set.
llarp::Context has a method InjectHive to give Router the pointer.
Router has a method NotifyRouterEvent which does:
  - when LOKINET_HIVE is set, passes the event to RouterHive
  - else when LOKINET_DEBUG is set, prints the event at a low log level
  - else NOP
2020-03-03 19:57:09 -05:00
Thomas Winget
74d421ac2d PathBuildNumber -> NextPathBuildNumber because increment side-effect 2020-02-20 16:57:48 -05:00
Thomas Winget
fc56a018e5 path builder prints hops, rest print short name 2020-02-20 16:37:39 -05:00
Jeff Becker
ea3851d15f
rc gossiping 2020-02-12 12:10:48 -05:00
Stephen Shelton
fba12093ac
Remove dead code (AbstractRouter::EnsureRouter()) 2020-01-22 11:15:40 -07:00
Jeff Becker
e5f92eaa79
only ping lokid if a service node 2020-01-07 12:58:49 -05:00
Jeff Becker
f56e543d75
add deadlock checker and revert bencode change from long ago 2019-12-07 14:58:19 -05:00
Stephen Shelton
2c6226f54a Backup SNApp keys when migrating to new ed25519 crypto 2019-12-06 11:21:14 -07:00
jeff
58a25602f5 more fixes, implemenmt missing functions 2019-10-09 09:08:38 -04:00
Michael
15cb49c9bd
Introduce --background to only start JSON RPC
fixes #853
2019-10-04 10:32:52 +01: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
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