Commit Graph

614 Commits (dev)

Author SHA1 Message Date
dan 13b01c86a6 Updated RpcServer Initialization and Logic
-- Moved all RPCServer initialization logic to rpcserver constructor
    -- Fixed config logic, fxn binding to rpc address, fxn adding rpc cats
    -- router hive failed CI/CD resulting from outdated reference to rpcBindAddr
    -- ipc socket as default hidden from windows (for now)
refactored config endpoint
    - added rpc call script (contrib/omq-rpc.py)
    - added new fxns to .ini config stuff
    - added delete .ini file functionality to config endpoint
    - added edge case control for config endpoint

add commented out line in clang-form for header reorg later
1 year ago
Jason Rhinelander f9db657f64
Make Default&Required or Required&Hidden compilation failures
Default & Required makes no sense: if we have a default it makes no
sense to make it required.  The previous behaviour when this was
specified was to force an (uncommented) value in the config with the
value, but this was only used in the test suite.

Required & Hidden makes no sense either: if it's required to be
specified we definitely don't want to hide it from the generated config
file.

These are now compile-time failures.
1 year ago
Jason Rhinelander 68bb74a95d
Make [lokid]:rpc setting required in SN mode
When running as a service node we can't do anything without a lokid rpc
URL, and we don't necessarily have a good default for it.

This makes it required so that we fail with an appropriate error message
(rather than connect timeouts) if it is not specified.
1 year ago
Jeff Becker 4103908a8d
system layer manager (llarp::sys::service_manager)
the win32 and sd_notify components provided a disjointed set of
similar high level functionality so we consolidate these duplicate
code paths into one that has the same lifecycle regardless of platform
to reduce complexity of this feature.

this new component is responsible for reporting state changes to the
system layer and optionally propagating state change to lokinet
requested by the system layer (used by windows service).
2 years ago
Jeff Becker 1e5b5ca1f5
proper handling of public ips
in service node mode make sure that when overriding public ip we only
fail when using 2 different public ip.
2 years ago
Jason Rhinelander 9a2cd19eb8
Fix obsolete oxenmq/hex.h usage 2 years ago
Jeff Becker 379ac755ec
make unit tests pass
changes to how config defaults, specifically allowing defaults to be a
vector, broke unit test compilation. this makes them compile again.
2 years ago
Jeff Becker 24dcffabe5
unit tests 2 years ago
Jeff 871c3e3281
changeset for windows port
* wintun vpn platform for windows
* bundle config snippets into nsis installer for exit node, keyfile persisting, reduced hops mode.
* use wintun for vpn platform
* isolate all windows platform specific code into their own compilation units and libraries
* split up internal libraries into more specific components
* rename liblokinet.a target to liblokinet-amalgum.a to elimiate ambiguity with liblokinet.so
* DNS platform for win32
* rename llarp/ev/ev_libuv.{c,h}pp to llarp/ev/libuv.{c,h}pp as the old name was idiotic
* split up net platform into win32 and posix specific compilation units
* rename lokinet_init.c to easter_eggs.cpp as that is what they are for and it does not need to be a c compilation target
* add cmake option STRIP_SYMBOLS for seperating out debug symbols for windows builds
* intercept dns traffic on all interfaces on windows using windivert and feed it into lokinet
2 years ago
Jeff 74362149eb
refactor dns subsystem
we want to be able to have multiple locally bound dns sockets in lokinet so
i restructured most of the dns subsystem in order to make this easier.

specifically, we have a new structure to dns subsystem:

* dns::QueryJob_Base

base type for holding a dns query and response with virtual methods
in charge of sending a reply to whoever requested.

* dns::PacketSource_Base

base type for reading and writing dns messages to and from wherever they came from

* dns::Resolver_Base

base type for filtering and handling of dns messages asynchronously.

* dns::Server

contextualized per endpoint dns object, responsible for all dns related isms.

this change hides all impelementation details of all of the dns components.
adds some more helper functions for parsing dns and dealing with OwnedBuffer.

overall dns becomes less of a pain with this new structure. probably.
2 years ago
Jason Rhinelander 57cebe5c9f Don't build peerstats tests when peer stats disabled 2 years ago
Jeff 8d1d1d0b57 make unit tests happy 2 years ago
Jeff 23fd46c0db
add directory specific readmes 2 years ago
majestrate 769bc1e8df
Merge pull request #1962 from jagerman/dns-parsing-fixes
DNS message parsing fixes and cleanup
2 years ago
Jason Rhinelander 9ea82edc07
DNS message parsing fixes and cleanup
Fixes:

- tighten reserved name detection to not match fooloki.loki, but instead
  only match "foo.loki.loki" and "loki.loki" (and similar for reserved
  name "snode.loki").
- IPv6 PTR parsing was completely broken.
- Added tests for the above two issues.

Cleanups:

- Eliminate llarp::dns::Name_t typedef for std::string
- Use optional return instead of bool + output param
- Use string_views; we were doing a *lot* of string substr's during
  parsing, each of which allocates a new string.
- Use fmt instead of stringstream
- Simplify IPv4 PTR parsing
2 years ago
Jeff 68148e098f
* add mockable network functions
* add unit tests with ability to pretend to be different network setups
2 years ago
Jason Rhinelander f6019210c3
oxen-logging update to handle level/type parsing exceptions 2 years ago
Jason Rhinelander eec8244a6c
Remote util::Printer and related cruft 2 years ago
Jason Rhinelander c82ade2d81
Make test code work with new logging 2 years ago
Jeff 1eba0f836e
replace LLARP_PROTO_VERSION macro 2 years ago
Jeff 7a8410b375 make more platforms ignore libcrypt 2 years ago
Jeff ee12ba51d5 disable hashed auth on windows 2 years ago
Jeff 5050cd0299 add hashed password capability to endpoint auth by file 2 years ago
Jason Rhinelander f63fff37a3 Remove broken test
This test isn't very useful, but also broken with the other changes on
this branch.
2 years ago
Jeff Becker 6c70022dcc
check for intersecting ip ranges correctly, add unit test 3 years ago
Jason Rhinelander 0a9b020555 Update Catch2 to latest to fix build on impish 3 years ago
Jeff Becker 5c457ff486
refactor logging to use std::source_location
* use std::source_location instead of godawful macros in logging
* remove unused/absolutely haram af json logstream
* fix bug in android logger where it doesn't respect eLogNone
3 years ago
Jason Rhinelander 9950adf472 Remove unneeded split(str, char) method
This function had a bug in stable (fixed in dev) when `last` returns
npos, but the function also appears to basically be duplicating what the
next split version can do, so this just removes it and uses the single
more generic split(strview, strview) method.
3 years ago
Jeff Becker a24b82119b
fix #1655
* make it so that we don't set up unbound resolver when we have no resolvers provided by config
* clean up dns codepath and make it use llarp::SockAddr instead of llarp::IpAddress
3 years ago
Jeff Becker e4ed53224c
use weak_ptr on a path to reference its parent pathset instead of a bare pointer so crashes dont happen 3 years ago
Jeff Becker 8f588c9638
remove test case 3 years ago
Jeff Becker 3e7137ad96
fix regression: llarp::Context::CallSafe was not deferring call on startup 3 years ago
Jeff Becker fedc56e3f1
initial commit for #1595 3 years ago
Jeff Becker 44d7fa0ab1
remove untracked file 3 years ago
Jeff Becker 4520e7fe6c
remove deprecated test 3 years ago
Jason Rhinelander 2ca7ef7f5f
Rename isRouter -> isSNode
The isRouter wording was quite confusing, especially in a call such as:

    router->Configure(config, opts.isRouter, nodedb)
3 years ago
Jeff Becker e11249d158
remove llarp.h header references 3 years ago
Jeff cb2254ba46
Merge pull request #1573 from jagerman/more-code-refactors
More code refactors
3 years ago
Jeff Becker 54c56a6d28
remove references to lokimq namespace
these were not found during the first passes and now that lokimq is gone from my machine this failed to compile
3 years ago
Jason Rhinelander 181953b4a6 Replace ::Hash nested structs with std::hash specializations 3 years ago
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
3 years ago
Jason Rhinelander 6e05dc693f Remove unused arguments (and ants) 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
Jason Rhinelander dfb62d06ce Shut up noisy catch tests 3 years ago
Jeff db515e48ec
Merge pull request #1561 from majestrate/catch2_migrate-2021-03-03
totally remove gtest/gmock from unit tests.
3 years ago
Jeff Becker 4cf0f1ee35
decaying hashset unit test fixes 3 years ago
Jeff Becker 5fd15fa044
generate keys in unit test 3 years ago
Jeff Becker 6c8e5256d6
catchAll -> testAll 3 years ago
Jeff Becker 60bfdacc23
get rid of the rest of gtest/gmock 3 years ago