Commit Graph

967 Commits (dev)

Author SHA1 Message Date
Jeff Becker fc9b09bdbc
clean up address/ip management code to use std::variant and std::optional 3 years ago
Jeff Becker 1885b1cae9
more 3 years ago
Jeff Becker 4446f2fc16
fix and format.
* start moving quic code to use lokinet internals
3 years ago
Jason Rhinelander aa0f54fa07
WIP plainquic tunnels 3 years ago
Jeff Becker a6715a1f75
remove old vpnio bits 3 years ago
Jeff 6bd53484da
Merge pull request #1541 from majestrate/lns-consensus-2021-02-19
lns lookup consensus
3 years ago
Jeff cb2254ba46
Merge pull request #1573 from jagerman/more-code-refactors
More code refactors
3 years ago
Jeff Becker dfa84081c9
forgot a type 3 years ago
Jeff Becker 202c9348fa
use std::variant 3 years ago
Jeff Becker b7f72601ce
move stuff to var::variant 3 years ago
Jeff Becker ba9dca6c5d
use var::variant and var::visit shims because apple is sux 3 years ago
Jeff Becker f10269b03e
remove std::visit because apple is functionally retarded and does not support it despite claiming to support c++14 3 years ago
Jeff Becker 6c1d18412c
seperate logic into IsDone() 3 years ago
Jeff Becker 88ddcceca4
make lookup name async return optional variant 3 years ago
Jeff Becker 4e14567d67
make Endpoint::LookupNameAsync return void 3 years ago
Jeff Becker 8e57572b37
dont reference iterator in lambda. 3 years ago
Jeff Becker 95eba18e40
cache result on success 3 years ago
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
3 years ago
Jeff Becker 1acea95ced
fix issue #1562
* use csrng for std::shuffle
3 years ago
Jeff Becker ad6dcd683b
fix segfault 3 years ago
Jason Rhinelander 181953b4a6 Replace ::Hash nested structs with std::hash specializations 3 years ago
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
3 years ago
Jason Rhinelander 0339bd941a Convert protocol type to enum class 3 years ago
Jeff 9bf002cc8d
Merge pull request #1574 from tewinget/header_fixup
standardize include format and pragma once
3 years ago
Jason Rhinelander f47e0cf7a2 Fix UB -- use after move 3 years ago
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.
3 years ago
Jason Rhinelander 91d6698a9d Reformat with clang-format-11 3 years ago
Jason Rhinelander c4559d158e Make format 3 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).
3 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
3 years ago
Jeff Becker f67668f0a6
use lowest latency path for send context 3 years ago
Jeff Becker 9457da27d9
add option to enforce unique netblocks per path. 3 years ago
Jeff Becker dcdd147e74
use static_cast with enum class 3 years ago
Jeff Becker 5fe7e00765
make AuthResultCode an enum class 3 years ago
Jeff Becker 5b2abce86f
add string reason to auth messages 3 years ago
Jeff Becker 6d5f1b0c6a
feedback auth result via lmq rpc 3 years ago
Jeff c76f2fe8de
Merge pull request #1496 from majestrate/rpc-kill-endpoint-sessions-2020-11-28
add llarp.endpoint rpc command
3 years ago
Jeff Becker 6a2d35d907
always use most recent convotag 3 years ago
Jeff Becker ffef3bc48f
wire up sigusr1 to reset libunbound dns resolver 3 years ago
Jeff Becker 1f1db29816
GetIf -> GetRandom 3 years ago
Jeff Becker 242e56507c
proper lokimq -> oxenmq refactor 3 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
3 years ago
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
3 years ago
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.
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 22acf0a537
Lns exits (#1407)
* lns exits

* try appeasing the clang

* clean up lambda
4 years ago
Jeff 50aea744f6
order packets when writing to network interface (#1372)
* order packet writes on userside

* make it compile

* fix pybind
4 years ago
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>
4 years ago
Jeff 28bfaf0372
ammend log levels for common spammy log events (#1375) 4 years ago
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
4 years ago
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
4 years ago
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
4 years ago
Jeff 11ed8924c6
use fs::path for service::Identity::EnsureKeys (#1364) 4 years ago
Jeff c91e4df856
make errors with service keyfile throw (#1358) 4 years ago
Jeff 78b40d6725 wire up lns gotnamemessage handler to kitchen sink 4 years ago
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
4 years ago
Jeff 681459185f
remove locks (#1336)
* remove locks

* use tryPushBack to attempt to prevent deadlocks
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
Thomas Winget 2c6e7b86c3
SRV records fixes (#1332)
* fix a log print log level

* correctly match SRV record service and protocol...

* tests for new dns question functions
4 years ago
Thomas Winget b1c14af938
SRV Record handling for introsets (#1331)
* update loki-mq submodule for tuple support

* srv record reply implementation

still need to encode srv records into intro sets / router contacts
as well as decode from them and match against queried service.proto

* inverted condition fix in config code

* SRV record struct (de-)serialization for intro sets

* parsing and using srv records from config (for/in introsets)

* adopt str utils from core and use for srv parsing

* changes to repeat requests

no longer drop repeat requests on the floor, but do not make
an *actual* request for them if one is in progress.

do not call reply hook for each reply for a request, as
each userland request is actually made into several lokinet
requests and this would result in duplicate replies.

* fetch SRVs from introsets for .loki

* make format

* dns and srv fixes, srv appears to be working
4 years ago
jeff e3bfe76f98 add exit auth token awareness to config 4 years ago
jeff 574a986d9a
explicitly set frame reset field to zero by default 4 years ago
jeff e039aeb6d5
remove codepath for convotag invalidation 4 years ago
jeff b0bb0b7609
initial route poking 4 years ago
jeff 2e7f9d1b87
remove convo tag when we invalidate it 4 years ago
jeff 3fbc46879d
Revert "don't send protocol discard message on fail"
This reverts commit ee2a42118c88bd7778cd6dc8694564c7d10e60d1.
4 years ago
jeff 78a4d361ab
don't send protocol discard message on fail 4 years ago
jeff 75f9643776
attempt to fix snode traffic ip rewrite bug 4 years ago
Jeff Becker 80919a3b76
address feedback.
* use exceptions when fetching identity key instead of std::optional, will throw on fail
* fix up config options for endpoint auth and add better docs
* add llarp::serive::AuthType enum for controlling what kind of endpoint auth to use
4 years ago
Jason Rhinelander a7c42ab2bd
Use lokimq's hex/base32z encoding/decoding 4 years ago
Jeff Becker 0f21eeccb0
* rework exit codepath to allow multiple exits
* rework net code for ip ranges to be cleaner
* clean up endpoint auth code
* refactor config to validate network configs before setting up endpoints
* remove buildone from path/pathbuilder.cpp so we don't spam connection attempts
4 years ago
Jeff Becker 3cdca30a74
more auth shit 4 years ago
Jeff Becker f4971a88fd
use lokimq workers instead of llarp:🧵:ThreadPool 4 years ago
Jeff Becker 5abf111159
endpoint auth whitelist 4 years ago
Jeff Becker 9f11b03016
enable exit node again 4 years ago
Jeff Becker a42d3d51c3
more 4 years ago
Jeff Becker 1e8368b636
make it compile 4 years ago
Jeff Becker 61c5808765
exit authentication (initial) 4 years ago
Jeff Becker ad882d0d70
initial working code 4 years ago
Rick V 6d5155def4
jeff pls 4 years ago
Jeff Becker 800668348a
add regression test for key backup bug 4 years ago
Jeff Becker ac26037c34
when in 1 hop mode we where hitting a case where we were failing to build paths
this was because we were trying to diversify the endpoints used which is not
appicable in 1 hop mode because first hops are sticky.
4 years ago
Jeff Becker f40ffc0fd6
simplify header for tom. 4 years ago
Jeff Becker c6885ec285
remove Endpoint::GetExitRouters() 4 years ago
Jeff Becker a45f92dca7
use random good path for outbound traffic so that it uses an even spread accross
all paths
4 years ago
Jeff Becker 6af498092b
exit traffic via loki addresses 4 years ago
Jason Rhinelander 3bb24580a4 make format 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 7f9160bb6e Untangle some interdependencies
macOS doing a shared library build is not working without untangling
some of the interdependencies.  This commit does that, at least enough
to get macOS to compile.

This isn't the cleanest as currently implemented (we have some net/
things in `liblokinet-platform` and some in `liblokinet`, and likewise
ev/vpnio.cpp is in `liblokinet` while the rest of `ev/*` is in
`liblokinet-platform`).
4 years ago
Jason Rhinelander 26ecf23ad8 Silence various warnings 4 years ago
Stephen Shelton ed31cdaacf
Cosmetic fixes 4 years ago
Jeff Becker 555b9721ce
keyfile was being initialized before being set by configure call.
this made it so that snapps always use ephemeral keys.
this fixes this.
4 years ago
Jeff Becker 635dc4fe13
unbreak router hive
llarp/config/config.cpp:
respect [network]:type option

llarp/handlers/exit.cpp:
when [network]:type is null dont init tun interface

llarp/service/context.cpp:
respect [network]:type option
change endpoint name back to "default"

llarp/tooling/router_hive.cpp:
dont use LogicCall for obtaining RCs from underlying relays, it crashes the mainloop and it's probably safe to readonly access RCs.

pybind/common.hpp:
remove typecasters as we use C++17 now

pybind/llarp/config.cpp:
remove SnappConfig
wire up NetworkConfig

pybind/llarp/handlers/pyhandler.hpp:
remove SnappConfig from constructor

pybind/llarp/handlers/pyhandler.cpp:
update constructor implementation to match header

test/hive/hive.py:
remove broke endpoint related code
wire up null endpoint option using NetworkConfig
use index at 0 for relays and clients instead of 1
dont add a python endpoint to all clients
4 years ago
Stephen Shelton 5f0cbb4625
Don't forget to load your keys 4 years ago
Stephen Shelton 9ba0f117c7
Revert to previous "if hops > 0" logic in Configure() 4 years ago
Stephen Shelton 960dc37c1f
Refactor TunEndpoint::Configure() (partially) 4 years ago
Stephen Shelton f2a26adcaa
Move all [endpoint] options to [network] 4 years ago
Stephen Shelton dd9ab0f1d5
Remove ability to have multiple endpoints/snodes from config 4 years ago
Stephen Shelton b7451b7632
Rip out tag, prefetch tags/addrs from Endpoint 4 years ago
Stephen Shelton 3198a8b139
Handle blacklist-snode validation in config 4 years ago
Stephen Shelton fde93ac02d
Don't take EndpointConfig by value 4 years ago
Stephen Shelton 21ad442b55
Remove NetConfig_t 4 years ago
Stephen Shelton df01770466
Rename SnappConfig -> EndpointConfig 4 years ago
Stephen Shelton 93b35c92a7
Eradicate service::Config 4 years ago
Jason Rhinelander 5cf2126bb9 make format 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
Jeff 54a7843bc5
Merge pull request #1186 from notlesh/config-cleanup-2020-03-13
Config cleanup
4 years ago
Jason Rhinelander 3c6aa002b8 Fix errors and warnings compiling on mac 4 years ago
Stephen Shelton de8e44ba21
Re-apply clang-format rules after rebasing 4 years ago
Stephen Shelton 9d71228e74
Replace config visit pattern with explicit lookups
This is an initial pass at doing explicit value checks when handling
config parsing, as opposed to using a visiting pattern. The latter
made it difficult to check for conditions such as missing required
values, multiple values, etc.

It was also generally less readable (think declarative) which further
made it difficult to get a grasp for what our actual configuration file
requirements were.
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.
4 years ago
Jeff d3091cf9fc
Merge pull request #1167 from tewinget/tooling
RouterHive initial PR
4 years ago
jeff 7089996ac5 discard unknown fields in introset for future use 4 years ago
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.
4 years ago
Stephen Shelton 6664202868
Add FindRouterSentEvent and FindRouterReceivedEvent to RouterHive 4 years ago
Jeff f3d23d6fb6
strip rr from dns reply for .snode and .loki (#1172)
fix dns replies so that extra RR for edns are not included.
4 years ago
Thomas Winget 84a1d7dbcc clang format....... 4 years ago
Thomas Winget 695784b2b6 more hive things
DHT PubIntroSentEvent
some helper functions added to RouterHive (C++ class) as well as RouterHive(Python class)
hive.py main() continues to be a testbed for new event types
some more internal classes in pybind
4 years ago
Jason Rhinelander c87fd66386 Fix lookup filter to filter second, not first, lookup 4 years ago
Jeff Becker 32dbe6b1ad more shiz 4 years ago
Jeff Becker 877443d95c more introspection code 4 years ago
Jeff Becker d4ccf895e3
Merge branch 'fix-up-introset-lookup-fails-2020-03-02' of ssh://github.com/majestrate/loki-network into fix-up-introset-lookup-fails-2020-03-02 4 years ago
Jeff Becker 79746e3719
remote lookup limiting of 500ms per address 4 years ago
Stephen Shelton 9be8050854
Make format 4 years ago
Stephen Shelton 886a981997
Consolidate introset publishing constants 4 years ago
Jeff Becker a09bb89d15
dont put multiple outbound contexts 4 years ago
Jeff Becker 158a9018f3
rename variable 4 years ago
Jeff Becker 9ff31f6402
spelling is hard 4 years ago
Jeff Becker 8f4362f092
fix up introset lookups 4 years ago
Jason Rhinelander 806d43c34e
Merge pull request #1147 from notlesh/diagnose-pubintro-round2-2020-02-28
Diagnose pubintro round2
4 years ago
Jason Rhinelander b60adc909d Make IntroSet publish confirmed less verbose
Essentially just rate limit the confirmation message to one message per
second.
4 years ago
Jason Rhinelander cfee824a79 Don't republish when we have extra paths
This caused some unwanted behaviour:

- on initial startup we often get two publishes in quick succession
because we're publishing and building paths at the same time

- at the 10m mark we enter a publish loop every 5 seconds because we
have paths with lifetimes < 10min that was triggering this condition,
and yet those paths will never actually be included in the introset
because they are expiring in <10m.
4 years ago
Jason Rhinelander 823c17206f Add min intro set paths, slightly increase spread speed
This should ensure that we have enough shortly after startup for initial
path builds.

The spread speed here gets slightly increased to lifetime/5 (=4min)
instead of lifetime/4 (=5min) so that our "normal" number of paths is 5
with occassional momentary drops to 4, but should always keep us >= the
new minimum of 4.

Because the path spread happens over time, this shouldn't result in a
rebuild of several paths: we'll build 4 quickly, then another at +4m,
another at +8m, etc.  When the initial 4 expire, we'll be dropping from
9 to 5 established but that's still above the minimum (4) so we won't
need to reconnect to several at once, and the spread builds should keep
us at 5 all the time.
4 years ago
Jason Rhinelander 27b8743107 Add warns for introset publish failures 4 years ago
Stephen Shelton 62014de91c
Handle PubIntro relayOrder logic on client-side 4 years ago
Stephen Shelton 61d19179f7
Remove dead code 4 years ago
Jeff Becker ce335dc47d
remove convotags on dead outbound context 4 years ago
Jeff 19a751c41b
Merge pull request #1127 from notlesh/spread-snapp-path-builds-evenly-2020-02-24
Spread snapp path builds evenly
4 years ago
Jeff 4f29405e9e
Merge pull request #1115 from majestrate/handle-multiple-responses-per-lookup-2020-02-20
handle multiple responses per hidden service lookup
4 years ago
Stephen Shelton abe4015986
Use constants for path build timing 4 years ago
Stephen Shelton 230037b9f3
Increase default path timeout from 10min to 20min 4 years ago
Stephen Shelton f0374eb2b7
Use existing 'lastBuild' var for spacing path builds 4 years ago
Stephen Shelton c2c010dbad
Make format 4 years ago
Stephen Shelton c1b5e453c7
Big I, little i, what begins with I? 4 years ago
Stephen Shelton 1db6c6ae3b
Make format 4 years ago
Stephen Shelton c2f719c996
Build endpoint paths at even[ish] intervals 4 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 4 years ago
Jeff Becker 524726e4cc
cast interval to std::chrono::milliseconds before dividing by 4 4 years ago
Jeff Becker d2d109e92c
llarp_time_t is now using std::chrono 4 years ago
Jeff Becker f4520ac920
make decaying hashset use llarp::Time_t and move unit tests to use catch2 4 years ago
Jeff Becker 39cdc9e6dd
shift intro on introset update 4 years ago
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.
4 years ago
Jason Rhinelander 089056ca5b Remove all ABSL_ATTRIBUTE_UNUSED uses 4 years ago
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).
4 years ago
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
4 years ago
Jeff 7c5a721457
Merge pull request #1114 from notlesh/redundant-introset-lookup-improvements-2020-02-20
Redundant introset lookup improvements
4 years ago
Jeff Becker 748be8eec8
handle multiple responses per hidden service lookup 4 years ago
Stephen Shelton 0429bafbb3
Merge pull request #1111 from notlesh/redundant-introset-propagation-2020-02-19
Redundant introset propagation
4 years ago
Stephen Shelton 66cb30fa58
Refactor: remove recursionDepth from DHT lookups 4 years ago
Jeff 6ac5f19b3a
Merge pull request #1110 from jagerman/no-abseil-optional
De-abseil, part 1: remove absl::optional
4 years ago
Stephen Shelton 4c499fb076
Make format 4 years ago
Stephen Shelton dff9aeb250
Propagate Introset publishing redundantly 4 years ago
Jeff Becker dc7828941f
add log statement 4 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").
4 years ago
Jeff 20bc168d1c
Merge pull request #1093 from majestrate/toggle-publishing-introsets-2020-02-11
make publishing introsets optional
4 years ago
Jeff Becker 1874f439b7
add comment 4 years ago
Jeff Becker e907d2ae19
handover fixes 4 years ago
Jeff Becker f7f5d893a5
use endpoint path for lookup because outboundcontext does not implement pathset::HandleGotIntroMessage 4 years ago
Jeff Becker c9866b6a0b
simplify 4 years ago
Jeff Becker 9aeee37347
short circuit 4 years ago
Jeff Becker 6a495dd090
ammend outbound context logic 4 years ago
Jeff Becker 02228ded08
spread out path builds 4 years ago
Jason Rhinelander 9e096d1996 Reduce introset publishing interal to 2.5min instead of 1.25min
We want to have some redundancy, but having 8 active at once seems
extreme; reduce to 4.
4 years ago
Jason Rhinelander c3637c81fd Remove another unused randomize parameter 4 years ago
Jason Rhinelander 24469daefb Remove unused parameter
We always randomize now.
4 years ago
Stephen Shelton 9dfcfbc3ac Bencode/decode relayOrder in lexigraphical order, make it uint64_t 4 years ago
Stephen Shelton 906803e387 Refactor DHT introset lookups to use redundant lookup strategy 4 years ago
Jeff Becker 4d4b33607f dont use optional 4 years ago
Jeff Becker 23bcfa4abb revert change 4 years ago
Jeff Becker df8c56343d refactor GetManyPathsWithUniqueEndpoints to go into service/endpoint_util.hpp 4 years ago
Jeff Becker fc5e6b4d77 log location 4 years ago
Jeff Becker 3cc2adae31 paralell publish and lookups 4 years ago
Jeff Becker e30c720446 redundant publish for service endpoint 4 years ago
Jeff Becker 2b6f27d60d
remove connect back logic for dead inbound sessions 4 years ago
Jeff 671c765161
Merge pull request #1085 from majestrate/check-for-initial-current-introset-2020-02-06
check for current introset being zero (initial state)
4 years ago
Jeff Becker 792fd4132c
only make default endpoint non-reachable if no keyfile option presented 4 years ago
Jeff Becker 6c67cc1f01
make default endpoint non reachable by default 4 years ago
Jeff Becker 70eb353c42
make publishing introsets optional using reachable=false to disable 4 years ago
Jeff Becker 5b87a9419e
default recursion depth to 2 not 12 4 years ago
Jeff Becker 8c698a1cd1
* rename i to foundIntro
* check for zero timestamp
* use > not >=
4 years ago
Jeff Becker 41210a8ae1
check for current introset being zero (initial state) 4 years ago
Stephen Shelton 37e4f26be1
s/LogInfo/LogDebug @ 'signed/verify encrypted introset' 4 years ago
Jeff Becker e6174efa21
don't derive x25519 key from ed25519 key 4 years ago
Jason Rhinelander f1171ed7a2 make format 😠 🤮 4 years ago
Jason Rhinelander 46f3459b79 Fixed EncryptedIntroSet signing to use PrivateKey
We can generate both root and derived signatures from a PrivateKey, but
only root from a SecretKey, so just change it to use a PrivateKey.
4 years ago
Jason Rhinelander 860c5efd47 Derived key fixes
The reason things weren't working here is because libsodium does
something completely unintuitive and called the seed the "secret key"
when it isn't, it's the seed.

This adds a new PrivateKey class (alongside the existing SecretKey and
PubKey) that holds just a private key value but no seed -- which we need
to do because there is no way we can get a seed after calculating a
derived keypair.

With these changes, we now generate exactly the same keys and subkeys as
Tor (and a new test case uses values generated in Tor to verify this).

This is incomplete -- the subkey signing code is still not implemented;
it has to be adapted to create a signature from a PrivateKey rather than
a SecretKey which will probably requiring working around/reimplementing
some of what libsodium does for creating a signature since it expects
"secret keys" i.e. the seed.
4 years ago
Jeff Becker 0f13591802
does not work 4 years ago
Jeff Becker 99eb7726ff
initial dht key blinding 4 years ago