Commit Graph

4337 Commits

Author SHA1 Message Date
Jeff Becker
9c742b36eb
call delivery status hook on overload 2021-04-12 12:00:35 -04:00
Jeff
6bd53484da
Merge pull request #1541 from majestrate/lns-consensus-2021-02-19
lns lookup consensus
2021-03-26 19:24:29 -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
dfa84081c9
forgot a type 2021-03-20 15:26:08 -04:00
Jeff Becker
202c9348fa
use std::variant 2021-03-20 15:18:04 -04:00
Jeff Becker
b7f72601ce
move stuff to var::variant 2021-03-20 14:30:18 -04:00
Jeff Becker
ba9dca6c5d
use var::variant and var::visit shims because apple is sux 2021-03-20 11:47:36 -04:00
Jeff Becker
f10269b03e
remove std::visit because apple is functionally retarded and does not support it despite claiming to support c++14 2021-03-20 10:06:26 -04:00
Jeff Becker
c07358f084
allow failure of setting ipv6 address when it is not allowed by kernel on linux 2021-03-20 09:55:43 -04:00
Jeff Becker
6c1d18412c
seperate logic into IsDone() 2021-03-19 16:13:09 -04:00
Jeff Becker
88ddcceca4
make lookup name async return optional variant 2021-03-19 16:06:03 -04:00
Jeff Becker
4e14567d67
make Endpoint::LookupNameAsync return void 2021-03-19 15:34:07 -04:00
Jeff Becker
8e57572b37
dont reference iterator in lambda. 2021-03-19 10:18:36 -04:00
Jeff Becker
95eba18e40
cache result on success 2021-03-19 10:13:03 -04:00
Jeff Becker
7a11f3b1e3
redunant lookups for lns.
* request lns from all endpoints we have on our pathset
* make sure all snodes agree on the lns name being looked up
2021-03-19 10:09:06 -04:00
Jeff
ec242447a0
Merge pull request #1581 from majestrate/ipv6-configurable-range-2021-03-18
make ipv6 range used by exit traffic configurable.
2021-03-18 19:11:00 -04:00
Jeff Becker
cf85ea6f2b
add warning and note in documenation of config option 2021-03-18 18:53:50 -04:00
Jeff Becker
1acea95ced
fix issue #1562
* use csrng for std::shuffle
2021-03-18 17:36:53 -04:00
Jeff Becker
b2687a53ee
dont use .value() because macos is absolutely broken, thanks apple. 2021-03-18 13:12:35 -04:00
Jeff Becker
a83428297e
make ipv6 range used by exit traffic configurable.
* add ip6-range option to network section to control which range we want to use for ipv6 traffic
* make ip6-range able to disable ipv6 exits ( i dont like this but eh )
2021-03-18 11:59:02 -04:00
Jeff Becker
ad6dcd683b
fix segfault 2021-03-11 08:35:14 -05:00
Jeff Becker
80a76c9386
fix segfault 2021-03-11 08:34:14 -05:00
Jason Rhinelander
181953b4a6 Replace ::Hash nested structs with std::hash specializations 2021-03-10 11:19:52 -04:00
Jason Rhinelander
d1dadb530c SockAddr endian cleanups & add uint128 ctors
- Make SockAddr endian arguments explicit
- Consolidate port-less contructors and port constructors into one with
  a default port of 0.
- Add {h,n}uint128_t ctors for construction from IPv6 addrs
2021-03-10 11:17:00 -04:00
Jason Rhinelander
fe0d099e86 Code cleanups
- De-lambda a lambda that is only called once, immediately after it is
  defined.
- C++17 modernize key-value for loops
- Remove unused (and useless) method
2021-03-10 11:17:00 -04:00
Jason Rhinelander
0339bd941a Convert protocol type to enum class 2021-03-10 11:16:55 -04:00
Jeff
9bf002cc8d
Merge pull request #1574 from tewinget/header_fixup
standardize include format and pragma once
2021-03-10 09:17:18 -05:00
Jason Rhinelander
f47e0cf7a2 Fix UB -- use after move 2021-03-09 21:23:40 -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
Thomas Winget
35fb54d131 add project source dir to util include directories 2021-03-09 16:55:10 -05:00
Jeff Becker
324498fe9a
flip order of parameters so it works 2021-03-08 06:59:55 -05:00
Jeff Becker
3d09b94590
make android work again
ip packet on read error was returning an uninitialized ip packet with non zero size so it was thinking it was a valid packet.
value initialize it to set the packet size to zero by default.

this fixed it in an emulator at least...
2021-03-08 06:17:20 -05:00
Jeff Becker
6550aa844c
try to unbreak more 2021-03-08 06:17:20 -05:00
Jeff Becker
7af4807302 correctly set size of OwnedBuffer when using OwnedBuffer::copy_used 2021-03-07 12:16:15 -04:00
Jason Rhinelander
91d6698a9d Reformat with clang-format-11 2021-03-05 13:36:31 -04:00
Jason Rhinelander
c00de1e4ec Add wakeup call into transit_hop UpstreamHandler 2021-03-04 16:51:18 -04:00
Jason Rhinelander
89b582bf60 Modernize [[maybe_unused]] attribute 2021-03-04 16:51:18 -04:00
Jason Rhinelander
4b5387a078 Remove unused ShouldFlushNow method 2021-03-04 16:51:18 -04:00
Jason Rhinelander
f9dc308f75 Tick event loop on data queuing 2021-03-04 16:51:18 -04:00
Jason Rhinelander
895acc45ff EventLoop: add public wakeup() method, and call it from call()
call(), when invoked from the logic thread, wasn't triggering a wakeup
which stalled some traffic (such as client-to-snode packets).

Fix it by triggering a wakeup on `call()`, and expose it because this is
a useful thing to be able to do.
2021-03-04 16:51:18 -04:00
Jason Rhinelander
f8d5e106a0 Uncurse SockAddr's sockaddr* operator
The `const sockaddr*` conversion was returning a pointer to the
sockaddr_in6, but with its family set to AF_INET, so the receiving code
would have treated interpreting the result as a sockaddr_in pointer --
but it isn't, and trying to get the IPv4 from the mis-reinterpreted
sockaddr_in6 fails; this then prevented uvw UDP binding (which uses the
sockaddr* operator) from working.

This changes it to always leave the family value at the proper value and
using the ipv6_is_mapped_ipv4 check to determine when we have (and
should return) a pointer to the sockaddr_in rather than the
sockaddr_in6.

Also fixes toString() to compare the full prefix instead of just bytes
10 and 11.
2021-03-04 16:51:18 -04:00
Jason Rhinelander
62fc1bbc48 Make llarp_buffer_t constructible from an rvalue reference 2021-03-04 16:51:18 -04:00
Jason Rhinelander
f8486604c4 Export UDP file descriptor (for android) 2021-03-04 16:51:18 -04:00
Jason Rhinelander
d995766436 Android & hive fixes 2021-03-04 16:51:18 -04:00
Jason Rhinelander
673d065ed8 Remove HasNextPacket() (and fix win32)
We don't use it anymore (instead we just ReadNextPacket until it returns
an empty result).
2021-03-04 16:51:18 -04:00
Jason Rhinelander
6e05dc693f Remove unused arguments (and ants) 2021-03-04 16:51:18 -04:00
Jason Rhinelander
2c827870c9 Simplify code of many f's
We don't need to go through the contention killer here, that was mainly
for (long ago) debugging reasons.
2021-03-04 16:51:18 -04:00
Jason Rhinelander
36edabd9b0 Rename EventLoop::udp to EventLoop::make_udp
Makes it consistent with the make_waker, etc.

Also removes some debugging.
2021-03-04 16:51:18 -04:00
Jason Rhinelander
afd856bca0 Remove unused junk (also fix win32 compilation fail) 2021-03-04 16:51:18 -04:00
Jason Rhinelander
096f37fe4e Fix linux compilation & narrowing conversion warning 2021-03-04 16:51:18 -04:00
Jason Rhinelander
e198bfd3e1 Remove unused variable 2021-03-04 16:51:18 -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
Jason Rhinelander
c71d3527bd C++17 simplification 2021-03-04 16:51:18 -04:00
Jason Rhinelander
8b00eacabf Fix signed/unsigned char comparison bug
These functions would not working properly if given a high bit char
value.
2021-03-04 16:51:18 -04:00
Jeff
abf057d6e3
Merge pull request #1536 from majestrate/memleak-fix-2021-02-15
plug super slow memory leak
2021-03-04 15:50:11 -05:00
Jeff Becker
ec0f45eeb7
plug memory leak in outbound message queue.
sometimes we use rxid in our pathid so we need to clear those queues too.
if we don't it'll leak from never clearing those queues.
2021-03-04 15:29:09 -05:00
Jeff Becker
7dbd25f271
don't leave old multi ack codepath in 2021-03-04 15:25:11 -05:00
Jeff Becker
c9ff917e0d
revert priority queue ordering change 2021-03-04 15:21:51 -05:00
Jeff Becker
ad3c23ba2b
simplify call 2021-03-04 15:21:51 -05:00
Jeff Becker
5cffc3b0f8
consolidate rx message handling in iwp
* add toggle flag for using multi ack
* check replay filter before processing message
2021-03-04 15:21:51 -05:00
Jeff Becker
e6ac7e721d
use a std::map instead of a std::unordered_map for holding message buffers by their sequentially increasing message id.
when retransmissions happen, they will be executed in a deterministic order by their delivery id.
this reduces the jitter from delayed message delivery on link layer as with an unordered map the order of iteration is "random",
so when we iterate all messages for retransmission we do it lowest id first (the messages queued first).
2021-03-04 15:21:51 -05:00
Jeff Becker
74f707ee01
only do single ack packets 2021-03-04 15:21:51 -05:00
Jeff
4992629f20
Merge pull request #1563 from majestrate/dont-multiplex-from-outbound-context-2021-03-03
use lowest latency path for send context
2021-03-04 15:16:40 -05:00
Jeff Becker
7060a60c84
enable route poker poking before going "up" 2021-03-04 06:22:23 -05:00
Jeff Becker
f77cbfb48e
fixes for ipv4 traffic: dont use new range because that breaks backwards comapt 2021-03-03 20:08:38 -05:00
Jeff Becker
f67668f0a6
use lowest latency path for send context 2021-03-03 18:42:10 -05:00
Jeff
f2b234d6c3
Merge pull request #1539 from majestrate/path-algorithm-flavors-2021-02-18
add option to enforce unique netblocks per path.
2021-03-03 14:06:40 -05:00
Jeff
b4b8b84e57
Merge pull request #1548 from majestrate/lns-mx-records-2021-02-25
add mx records to lns names
2021-03-03 14:06:28 -05:00
Jeff Becker
d6567614e3
use mutable lambda instead of shared_ptr for handling mx dns reply for lns 2021-03-03 10:37:31 -05: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
b59a92aa01
add mx records to lns names 2021-03-02 07:21:05 -05:00
Jeff Becker
0fa91381ba
add llarp::CSRNG for cryptographically secure random number generator for use in std::shuffle 2021-03-02 07:20:29 -05:00
Jeff Becker
a88aec5f01
fix typo 2021-03-02 07:20:29 -05:00
Jeff Becker
a3585caa70
add value 0 to disable unique-range-size 2021-03-02 07:20:29 -05:00
Jeff Becker
f7424b8bbe
dont use std::optional 2021-03-02 07:20:29 -05:00
Jeff Becker
4478cf6f72
use pointers to entries instead of lookups by key 2021-03-02 07:20:29 -05:00
Jeff Becker
b865ffb736
use 64-bit Mersenne Twister instead of 32 bit flavor in nodedb 2021-03-02 07:20:29 -05:00
Jeff Becker
e584cbe44d
make non 64 bit platforms happy 2021-03-02 07:20:29 -05:00
Jeff Becker
3425069b41
feedback from jason
* use emplace in PeerSectionConfig::Acceptable use insert everywhere else
* use const l-value references
* fix typos and spelling mistakes
2021-03-02 07:20:29 -05:00
Jeff Becker
5d465264a8
truly random access in nodedb iteration 2021-03-02 07:20:29 -05:00
Jeff Becker
9457da27d9
add option to enforce unique netblocks per path. 2021-03-02 07:20:28 -05:00
Jason Rhinelander
56cbef6086 SockAddr fixes and cleanups
- Remove SIIT from method names & comments because we're doing IPv4
mapped addresses (::ffff:0:0/96) rather than actual SIIT
(::ffff:0:0:0/96).

- add constructor taking a string+numeric port (and then don't allow a
port in the string).

- simplify IP string parsing by using parse_int()

- replace addrIsV4 with call to ipv6_is_mapped_ipv4 (this also fixes a
bug where addrIsV4 was not checking for leading 0s and so could return
true for a public IPv6 that happened to have ffff in the wrong spot).
2021-02-24 19:34:42 -04:00
Jeff Becker
dcdd147e74
use static_cast with enum class 2021-02-24 14:08:21 -05:00
Jeff Becker
5fe7e00765
make AuthResultCode an enum class 2021-02-24 14:08:21 -05:00
Jeff Becker
94b8743b1c
fix typo 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
2cb889013b
revise lambda captures 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
c76f2fe8de
Merge pull request #1496 from majestrate/rpc-kill-endpoint-sessions-2020-11-28
add llarp.endpoint rpc command
2021-02-23 18:53:06 -05:00
Jeff Becker
785b4258ed
only set public address when provided 2021-02-23 09:35:24 -05:00
Jeff Becker
d7842d18ee
add missing header 2021-02-23 05:53:48 -05:00
Jeff Becker
cb3b89457f
remove pointless operator overload 2021-02-23 05:49:32 -05:00
Jeff Becker
be3faeb402
feedback from tom.
* remove unneeded header.
* fix typo in docs
2021-02-23 05:48:50 -05:00
Jeff Becker
1c3020a05e
drop on overload 2021-02-22 15:29:12 -05:00
Jeff Becker
bb9bd25059
get rid of use of llarp::IpAddress from hotpaths 2021-02-22 10:01:05 -05:00
Jeff Becker
01262d1c4d
flush queue when full 2021-02-22 09:03:34 -05:00
Jeff Becker
42ffbcca0a
try coleasing inbound packets from iwp 2021-02-22 08:26:32 -05:00
Jeff Becker
dc68ff6de9
prevent bad side effects, dont use iterator after use and use operator[] 2021-02-18 18:51:43 -05:00
Jeff Becker
b2b68c413c
actually set disabled when disabiling route poker 2021-02-18 18:24:50 -05:00
Jeff Becker
6a29cc7380
call closed hook when we explicitly close a link session 2021-02-17 14:26:54 -05:00
Jeff Becker
6a2d35d907
always use most recent convotag 2021-02-17 14:26:39 -05:00
Jeff Becker
b484d9bebb
update route poker logic to include "up" 2021-02-17 13:36:57 -05:00
Jeff Becker
e46204b068
dont wire up router thaw to sigusr1 2021-02-17 13:35:06 -05:00
Jeff Becker
07b599430e
thaw router when connectivity changes 2021-02-17 13:35:06 -05:00
Jeff Becker
676ca7f511
close stale sessions on thaw because they are probably already gone. this removes them and forces the sessions to be renegotiated. 2021-02-17 13:32:55 -05:00
Jeff Becker
ffef3bc48f
wire up sigusr1 to reset libunbound dns resolver 2021-02-17 13:32:55 -05:00
Jeff Becker
8239efa71b
clarify new member's purpose and name. add comment. 2021-02-17 07:54:18 -05:00
Jeff Becker
1526941f3a
make it compile again 2021-02-17 07:49:47 -05:00
Jeff Becker
0600f42814
fix up names of functions to be less hidious. 2021-02-17 06:37:21 -05:00
Jeff Becker
1ee545d6d2
fix up macos route command for ipv6 2021-02-16 16:37:08 -05:00
Jeff Becker
35137913b9
windows and macos route pokers for ipv6 2021-02-16 15:01:07 -05:00
Jeff Becker
1c7079dbab
fix up route poking with lokinet to work with ipv6 2021-02-16 12:37:16 -05:00
Jeff Becker
063e982ef6
fix exit range default value 2021-02-16 11:25:44 -05:00
Jeff Becker
bd93a8f828
initial v6 exits 2021-02-16 10:59:57 -05:00
Jeff Becker
1f1db29816
GetIf -> GetRandom 2021-02-03 16:38:31 -05:00
Jeff Becker
f24cdb305b
clean up calls to NodeDB::GetIf to be cleaner and more concise 2021-02-03 14:49:33 -05:00
Jeff Becker
c8aba0af31
make llarp::NodeDB::GetIf always randmize location 2021-02-03 14:49:00 -05:00
Jeff Becker
d55705362a
use good routers 2021-02-03 13:50:12 -05:00
Jeff Becker
b6dbbb4bef
consolidate pathbuilder logic
* deduplicate code for path hops selection
2021-02-03 13:44:43 -05:00
Jeff Becker
242e56507c
proper lokimq -> oxenmq refactor 2021-02-03 13:12:21 -05:00
Jeff Becker
1e58715e0b
fix pybind layer 2021-02-02 13:16:34 -05:00
Jeff Becker
922f4fb724
fix iteration bug 2021-02-02 13:15:51 -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
5f0f4e0c70
prevent crash by removing duplicate logic (#1515)
when a path expires or fails or something causes its lifecycle to end we have cleanup
logic that handles clean up for it. this removes a code path that was crashing that
is duplicated elsewhere and is thus probably safe to bin. yolo.
2021-01-19 07:39:22 -05:00
Jeff Becker
82b3ec19e8
unbreak the build
* remove llarp/ev/pipe.cpp from cmake
* fix typo in llarp/ev/ev_libuv.cpp
2021-01-12 08:37:45 -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 Becker
7ee9d0281c
add llarp.endpoint rpc command with kill option to kill all active convotags given
a list of or a single remote service address.
2020-11-28 07:15:55 -05:00
Jeff
6407733c8e
* make llarp.halt rpc call actually return a reply (#1488)
* add --kill flag to lokinet-vpn that calls llarp.halt
* make macos uninstaller kill lokinet via lokinet-vpn --kill
2020-11-20 12:37:30 -05:00
Jason Rhinelander
384b968cf0
Merge pull request #1437 from majestrate/key-manager-fixes-2020-10-30
key manager should throw on failure to load keys
2020-11-17 19:05:56 -04:00
Jeff
db7abe8f09
do /1 route poker split on linux (#1480)
* do /1 route poker split on linux

i hate netlink so god damn much

* use an enum class for the gateway mode
2020-11-16 13:33:45 -05:00
Jeff
dad66c50cb
poke route hole for loopback on windows because that OS is made by brain damaged non programmers. (#1473)
this fixes the gui bug where it hangs on adding an exit becuase loopback gets routed over the exit.
before it was causing the lmq connection to hang becuase of that route change.
2020-11-16 12:16:38 -05:00
Jeff
a0ed303d7b
try to handle router deregistrations on the network better (#1461)
* don't send messages to de-registered relays but allow traffic to clients

* actively close sessions to de-registered relays
2020-11-10 09:24:58 -05:00
Jeff
a7518057cb Revert "deny traffic to non whitelisted routers. (#1444)"
This reverts commit ff02e62a79.
2020-11-08 10:04:28 -05:00
Jeff
c743022cfb
try fixing deadlock (#1454)
* fix deadlock in #1453

* remove use of shared_lock in profiling
* clean up Save and Load to acquire lock
* bencode and bdecode are now non locking

* remove all places using std::shared_lock

* bail if write fails
2020-11-05 06:19:43 -05:00
Jeff
e66522b9dd
fix path reference leak (#1451) 2020-11-04 11:08:29 -05:00
Jeff
34c7f0da0d
profiles.dat is always relative so if you spawn lokinet in / then it will error about permissions. (#1449)
* use absolute path for profiles.dat.

* remove old bencoding bits to use const fs::path instead of const char *
2020-11-03 10:54:55 -05:00
Jeff
8be7c46531
try fixing memory leak in path builder (#1442) 2020-11-02 08:06:46 -05:00
Jeff
ff02e62a79
deny traffic to non whitelisted routers. (#1444)
* deny message delivery from non registered nodes when whitelist is enabled and applicable

* use DoCallback and return true so that the event gets fired right
2020-11-01 10:02:24 -05:00
Jeff
87c76a6769
add exit.localhost.loki cname record (#1440)
* add exit.localhost.loki cname record

* return cname in localhost.loki A/AAAA lookup reply

* correctly handle case where we have no exit

* typofix

* simplify logic
2020-10-31 11:59:03 -04:00
Jeff
3ec727d844
I have no words. (#1438)
So apparently dnsConfig in Router was never set.
Router::networkConfig was set, but only used in the function
which set it and otherwise only passed to another function once.
dnsConfig was only used in one place.

both member variables have been removed in favor of just
referencing Router::m_Config.

Co-authored-by: Thomas Winget <tewinget@gmail.com>
2020-10-30 19:32:00 -04:00
Jeff Becker
5233b26552
format 2020-10-30 15:53:05 -04:00
Jeff Becker
bf1a692005
key manager should throw on failures 2020-10-30 15:52:19 -04:00
Jeff
0e1e0aaef3
allow for relative file paths in config (#1432)
* llarp::Config constructor can take an empty fs::path now and it will default to fs::current_path
* llarp::ensureConfig now throws on fs error
* updates to daemon/main.cpp to reflect changes to llarp::ensureConfig's new throwability
* dowse parts of the code with holy water for the 0.8.1 tag
2020-10-30 09:38:17 -04:00
Jeff
c81b6049f1
fix crashes on shutdown (#1433) 2020-10-29 10:19:45 -04:00
Jason Rhinelander
e47b70a82f
CMake fixes: libuv static build, base_libs, shared lib install dir (#1431)
* Update how we build libuv

- Update submoduled libuv to latest stable (1.40.0)
- Don't look for a system libuv if we're under BUILD_STATIC_DEPS
- Add a libuv interface library rather than using globals
- Make the windows build fall back to the submodule if not explicitly
  given a LIBUV_ROOT

* Replace ${LIBS} global with `base_libs` interface

This simplifies linking and include handling a bit.

* Remove unneeded header

* Add missing csignal header

(This was previously being pulled in incredibly indirectly via some
stuff that eventually includes some other stuff that eventually included
uv.h)

* Use GNUInstallDirs to get lib dir instead of hard-coding lib

Fixes #1429
2020-10-28 18:26:43 -04:00
Jeff
dcb48db5fe
enable profiling on clients by default (#1421)
* enable client relay profiling by default

* macos dns fixes

* improve peer profiling algorithm to track timeouts vs failures

* remove debug ioctl call in tuntap code

* use ub_wait instead of ub_process as that was what was there before

* const correctness

* DRY out checking for SIIT

* typofix

* correct name
2020-10-27 17:34:09 -04: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
7a1207dc47
dont bind inbound links as client (#1419)
* dont bind inbound links as client

* fix broken test

* logic call MUST defer call
2020-10-21 17:31:57 -04:00
Thomas Winget
a91bb35dbf
Some Windows fixes (#1415)
* Should fix some windows service issues

* fix return condition inversion

* Add some Trace level logging

also make the logger actually respect the log level you set.

* event loop should not queue things to itself...

at present, logic thread queue continues until it is empty, so
queueing things onto itself is just wasteful.

* call_later(foreach thing) is better than foreach thing (call later)

also if you already queued those things but they have not happened yet,
there is no sense to queue them to happen again.

* do not queue read on write finish, only on read finish

* failure to start DNS server should be proper startup failure.

without the DNS server working lokinet is...kinda pointless, right?

* format

* don't queue stuff to logic thread if in logic thread
the thing that clears the queue...clears it.  So you're just delaying and adding overhead.

* windows unbound thread sleep instead of just busy-waiting

also clang-format decided I can't have a blank line for some reason...

* fix unbound async worker on windows
2020-10-21 09:06:43 -04:00
Jeff
12eb32a816
add conf.d directory for config overrides (#1410)
* add conf.d directory for config overrides

* refactor llarp::Config

* add explicit constructor with datadir as parameter
* have all config files be passed as std::optional
* make Config::LoadDefault private and use std::optional in Config::Load to remove ambiguity
* update rest of codebase to reflect above changes

* fix pybind

* rename bootstrap config skipBootstrap to seednode as it's more descriptive
* make seednode configurable
* make pybind layer compile
* make pybind layer run
2020-10-21 08:58:08 -04:00
Jeff
22acf0a537
Lns exits (#1407)
* lns exits

* try appeasing the clang

* clean up lambda
2020-10-21 05:39:01 -04:00
Thomas Winget
df36ed953d
Route Poker changes (#1416)
If not using an exit, messing with the routing table is not good.
As such, the ability to keep track of routes we *might* want is good,
but the ability to set/unset those routes is necessary, to correspond
to enabling/disabling exit functionality.
2020-10-20 05:15:39 -04:00
Jeff
98e022ea21
Unflaky-ify lns dns (#1406)
* always ensure path to service on dns lookup

* deprecate profiles option
2020-10-12 13:55:58 -04:00
Jeff
38f13533df
always use data directory for bootstrap.signed (#1405) 2020-10-12 13:03:39 -04:00
Jeff
5b5bd6b44e
dns features (#1404)
* add some dns txt records for stuff we want to expose

* fix txt records

* txt records for snode info

* dont send cname as it mangles the response

* check for 3 parts not 3 characters
2020-10-12 12:18:46 -04:00
Jason Rhinelander
d10fee87c7
Don't report a huge negative elapsed time on startup (#1401) 2020-10-09 11:40:04 -04:00
Jeff
3b70b99dd2
fix empty config case (#1400)
* fix empty config case

* * fix case for empty ifname / ifaddr on relay
* bail if no dns server bound

* use AssignmentAcceptor
2020-10-09 11:39:39 -04:00
Jeff
50aea744f6
order packets when writing to network interface (#1372)
* order packet writes on userside

* make it compile

* fix pybind
2020-10-08 07:59:01 -04:00
Jason Rhinelander
af6caf776a
Config file improvements (#1397)
* Config file API/comment improvements

API improvements:
=================

Make the config API use position-independent tag parameters (Required,
Default{123}, MultiValue) rather than a sequence of bools with
overloads.  For example, instead of:

    conf.defineOption<int>("a", "b", false, true, 123, [] { ... });

you now write:

    conf.defineOption<int>("a", "b", MultiValue, Default{123}, [] { ... });

The tags are:
- Required
- MultiValue
- Default{value}
plus new abilities (see below):
- Hidden
- RelayOnly
- ClientOnly
- Comment{"line1", "line2", "line3"}

Made option definition more powerful:
=====================================

- `Hidden` allows you to define an option that won't show up in the
  generated config file if it isn't set.

- `RelayOnly`/`ClientOnly` sets up an option that is only accepted and
  only shows up for relay or client configs.  (If neither is specified
  the option shows up in both modes).

- `Comment{...}` lets the option comments be specified as part of the
  defineOption.

Comment improvements
====================

- Rewrote comments for various options to expand on details.
- Inlined all the comments with the option definitions.
- Several options that were missing comments got comments added.
- Made various options for deprecated and or internal options hidden by
  default so that they don't show up in a default config file.
- show the section comment (but not option comments) *after* the
  [section] tag instead of before it as it makes more sense that way
  (particularly for the [bind] section which has a new long comment to
  describe how it works).

Disable profiling by default
============================

We had this weird state where we use and store profiling by default but
never *load* it when starting up.  This commit makes us just not use
profiling at all unless explicitly enabled.

Other misc changes:
===================

- change default worker threads to 0 (= num cpus) instead of 1, and fix
  it to allow 0.
- Actually apply worker-threads option
- fixed default data-dir value erroneously having quotes around it
- reordered ifname/ifaddr/mapaddr (was previously mapaddr/ifaddr/ifname)
  as mapaddr is a sort of specialization of ifaddr and so makes more
  sense to come after it (particularly because it now references ifaddr
  in its help message).
- removed peer-stats option (since we always require it for relays and
  never use it for clients)
- removed router profiles filename option (this doesn't need to be
  configurable)
- removed defunct `service-node-seed` option
- Change default logging output file to "" (which means stdout), and
  also made "-" work for stdout.

* Router hive compilation fixes

* Comments for SNApp SRV settings in ini file

* Add extra blank line after section comments

* Better deprecated option handling

Allow {client,relay}-only options in {relay,client} configs to be
specified as implicitly deprecated options: they warn, and don't set
anything.

Add an explicit `Deprecated` tag and move deprecated option handling
into definition.cpp.

* Move backwards compat options into section definitions

Keep the "addBackwardsCompatibleConfigOptions" only for options in
sections that no longer exist.

* Fix INI parsing issues & C++17-ify

- don't allow inline comments because it seems they aren't allowed in
ini formats in general, and is going to cause problems if there is a
comment character in a value (e.g. an exit auth string).  Additionally
it was breaking on a line such as:

    # some comment; see?

because it was treating only `; see?` as the comment and then producing
an error message about the rest of the line being invalid.

- make section parsing stricter: the `[` and `]` have to be at the
beginning at end of the line now (after stripping whitespace).

- Move whitespace stripping to the top since everything in here does it.

- chop off string_view suffix/prefix rather than maintaining position
values

- fix potential infinite loop/segfault when given a line such as `]foo[`

* Make config parsing failure fatal

Load() LogError's and returns false on failure, so we weren't aborting
on config file errors.

* Formatting: allow `{}` for empty functions/structs

Instead of using two lines when empty:

    {
    }

* Make default dns bind 127.0.0.1 on non-Linux

* Don't show empty section; fix tests

We can conceivably have sections that only make sense for clients or
relays, and so want to completely omit that section if we have no
options for the type of config being generated.

Also fixes missing empty lines between tests.

Co-authored-by: Thomas Winget <tewinget@gmail.com>
2020-10-07 18:22:58 -04:00
Jeff
b0088b3298
dont segfault on exit (#1396)
* dont segfault on exit

* initialize m_isServiceNode earlier.
2020-10-06 09:44:51 -04:00
Jeff
ff23106852
don't allow running lokid-rpc as client (#1394) 2020-10-05 12:55:19 -04:00
Jason Rhinelander
753d989f7c Set default inbound link to best public interface
Fixes default config not working.
2020-10-02 23:27:25 -03:00
Jason Rhinelander
7aa4566016 Make format 2020-10-02 20:57:51 -03:00
Jason Rhinelander
4faaf9082c Fix broken unbound resolver when including upstream port
unbound breaks when given "1.2.3.4:53" as it expects only an IP.
2020-10-02 20:19:53 -03:00
Jason Rhinelander
01013c1963 Make upstream= override work; reject non-default upstream port
If you specify upstream= then you get no upstream, if you give one then
you use that instead of the default, but you can still list multiple.

unbound doesn't support an upstream port, so bail if the user gives a
non-port-53 response.
2020-10-02 20:17:12 -03:00
Jason Rhinelander
d129b0432a Allow empty values so that upstream= can disable the default 2020-10-02 19:39:43 -03:00
Jason Rhinelander
c97b9ef31b Simplify k=v parsing code 2020-10-02 19:38:58 -03:00
Jeff
9d6dc40f81 format 2020-10-02 18:02:03 -04:00
Jeff
2b5b3ce8e1 default upstream dns to cloudflare 2020-10-02 18:01:26 -04:00
Jeff
0f7e848903
disable rpc on relays by default (#1383)
* disable rpc on relays by default

* add default inbound link as service node

* throw if public-ip and public-port are not set
2020-10-02 16:54:31 -04:00
Jason Rhinelander
fbfa8ca89c
make format (#1381) 2020-10-02 15:50:20 -04:00
Jason Rhinelander
b121933374
Make public-ip option work (#1380)
0.7 supported both public-address and public-ip, but only the former was
being allowed in 0.8.

This makes `public-ip=...` work again, and makes it the canonical option
(because it makes a bit more sense than address when we also have the
public-port parameter), while making `public-address=` accepted with a
deprecation warning.

Also adds default descriptions for port and ip for the generated ini.
2020-10-02 14:47:14 -04:00
Jeff
f797405318 ping lokid every 30 second after starting up 2020-10-02 14:11:39 -04:00
Thomas Winget
4f3ed5d1c4
remove unnecessary code
the signed_bt_dict field is not used for a Version 0 RC anyway, so no need to handle it here.  That was my bad.
2020-10-02 11:41:21 -04:00
Jeff Becker
c04cbfe34f
fix decode version 0 rc when in version 1 mode 2020-10-02 11:09:38 -04:00
Jeff Becker
79dfb6d357
kill lmq before stopping links/ 2020-10-02 11:09:13 -04:00
Jeff Becker
bb67b42f0b
put pubkey_ed25519 in fields 2020-10-02 10:06:35 -04:00
Jeff Becker
23302cd10c
use size_left 2020-10-02 10:06:08 -04:00
Jeff
503a92c992 un limit lmq 2020-10-02 05:51:52 -04:00
Jeff
7852735b36 tweak configuration defaults 2020-10-02 05:48:08 -04:00
Jeff
28bfaf0372
ammend log levels for common spammy log events (#1375) 2020-10-01 11:14:08 -04:00
Jeff
8943be6c3a
serialize auth codes in rpc (#1369)
* serialize auth codes in rpc

* format

* format

* config and route fixups

* bump lokimq

* fix compile

* discard unknown members in service keys

* format
2020-09-29 09:26:45 -04:00
Thomas Winget
7f18df4e9a
fix format string for size_t (#1371) 2020-09-28 20:07:40 -04:00
Jeff
56f49a6980
make win32 exits work again (#1367) 2020-09-28 18:43:31 -04:00
Jeff
53598ec0e9
dont serialize ephemeral members of service identity (#1370)
* prepare for keytool script

* dont serialize ephemeral members in service key file
* regnerate ephemeral members in service identity on load

* add keygen script

* use nacl for generating keys

* format
2020-09-28 11:15:07 -04:00
Thomas Winget
15229ea7ff
New RC format (#1368)
* initial work for RC SRVs.

Needs tests for new RC format.

Needs SRVs added to new RC, and associated tests.

* convert rc sign/verify test to catch2, add test for new rc

Also fixes a mistake in new rc serialization

* bump loki-mq submodule

need support for viewing bt deserialize consumer buffer so we
know how much it has consumed.

* fix some behavior errors

need to advance llarp_buffer_t after consuming data from it

only rewind and modify size of llarp_buffer_t in owning context.

* Add test for router contact (de-)serialization

Adds a test that makes a list of RouterContact with mixed
versions and ensures it serializes and deserializes correctly.
2020-09-25 14:05:28 -04: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
10e3d80559
resolve issue #1361 about peer stats excessive logging (#1365) 2020-09-23 14:44:39 -04:00
Jeff Becker
7a18d14fde make it compile 2020-09-23 14:39:06 -03:00
Jeff
a9d23d3ac3
use absolute path for route command (#1354)
* ignore tun interfaces on windows for mitigating foot cannons

* add flag for git add -p when using format verifier as git hook

* use explicit path for route command on windows

* fix typo

* fix typo

* remove hunk for win32 route exclusion based off being a tun interface

* add metric to win32 route command

* * refactor win32 route poking to use a common function for iterating over routes

* put interface in route poking for default route

* mnake it compile

* use correct route command on windows

* use fs::path for service::Identity::EnsureKeys
2020-09-23 07:06:11 -04:00
Jeff
11ed8924c6
use fs::path for service::Identity::EnsureKeys (#1364) 2020-09-23 07:05:37 -04:00
Jason Rhinelander
d03066ee05
Support [dns] no-resolvconf option (ignored by lokinet) for deb compatibility (#1362)
* Add ignored [dns]no-resolvconf option for deb backwards compat

The debs hack a `#no-resolvconf=1` into the config file in 0.7 to allow
a user to disable resolvconf setup during startup by uncommenting it.
That doesn't work anymore since 0.8 errors on invalid config options, so
add it as an ignored option so that 0.7 deb config files can still be
compatible.

* Fix `[dns]upstream` comment not being produced in generated conf file

* fix test

Co-authored-by: Jeff <jeff@i2p.rocks>
2020-09-22 17:46:06 -04:00
Jeff
c91e4df856
make errors with service keyfile throw (#1358) 2020-09-22 15:04:31 -04:00
Jeff
fe30193a97
revive android build system (#1339)
* it lives?

* clean up

* add readme and add x86_64 to abi filters

* disable route poking on android

* make it compile on android

* it compiles!!111

* typofix

* re-enable ccache for android
2020-09-22 15:04:15 -04:00
Jeff
75ef28531e allow lns subdomains 2020-09-19 10:38:57 -04:00
Jeff
a035dbdb9a enable peer stats by default 2020-09-19 09:56:47 -04:00
Jeff
78b40d6725 wire up lns gotnamemessage handler to kitchen sink 2020-09-19 09:29:36 -04:00
Jeff
21930cf667
LNS (#1342)
* initial relay side lns

* fix typo

* add reserved names and refactor test for dns

* lns name decryption

* all wired up (allegedly)

* refact to use service::EncryptedName for LNS responses to include nonce with ciphertext

* fully rwemove tag_lookup_job

* replace lns cache with DecayingHashTable

* check for lns name validity against the following rules:

* not localhost.loki, loki.loki, or snode.loki

* if it contains no dash then max 32 characters long, not including the .loki tld (and also assuming a leading subdomain has been stripped)

* These are from general DNS requirements, and also enforced in
registrations:

* Must be all [A-Za-z0-9-]. (A-Z will be lower-cased by the RPC call).

* cannot start or end with a -

* max 63 characters long if it does contain a dash

* cannot contain -- in the third and fourth characters unless it starts with xn--

* handle timeout in name lookup job by calling the right handler with std::nullopt
2020-09-17 15:18:08 -04:00