1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
Commit graph

541 commits

Author SHA1 Message Date
Jeff Becker
3d2990f90d
use llarp::LogSilencer to shut up loging in unit tests 2020-06-08 09:26:53 -04:00
Jeff Becker
a73335579a
silence logging in regression test 2020-06-08 09:07:49 -04:00
Jeff Becker
800668348a
add regression test for key backup bug 2020-06-08 08:42:10 -04:00
Stephen Shelton
1497b829bd
Ignore our self.signed file if we're a client 2020-06-04 11:05:23 -06:00
Jeff Becker
328c7a398e
make sure event loop owns logic so that logic call does not use seperate thread 2020-05-23 16:07:20 -04:00
Jeff Becker
00143e63f4
put replay filters on transit hops to reduce retransmissions. 2020-05-23 16:07:20 -04:00
Jason Rhinelander
d05e6716cb Remove llarp::str(string_view)
It was a workaround for pre-C++17 std::string which didn't support
passing a string_view to various functions/operators.  There's only one
place left that needs an explicit conversion, and that's where it is
used as a map key; so just be explicit there and remove llarp::str()
everywhere else.
2020-05-21 17:05:30 -03:00
Jason Rhinelander
ebd2142114 Don't use std::optional::value() because f u macos
This replaces all use of std::optional's `opt.value()` with `*opt`
because macOS is great and the ghost of Steve Jobs says that actually
supporting std::optional's value() method is not for chumps before macOS
10.14.  So don't use it because Apple is great.

Pretty much all of our use of it actually is done better with operator*
anyway (since operator* doesn't do a check that the optional has a
value).

Also replaced *most* of the `has_value()` calls with direct bool
context, except for one in the config section which looked really
confusing at a glance without a has_value().
2020-05-20 19:18:28 -03:00
Jason Rhinelander
bdc9c7bfa8 Move IPRange out of net.hpp; free up TruncateV6 etc.
- Move IPRange into its own net/ip_range.hpp

- Move the static net::IPPacket::TruncateV6, etc. functions to free
net::TruncateV6, etc. functions (now from net/ip.hpp instead of
net/ip_packet.hpp).

- Make net::TruncateV6 and net::ExpandV4 constexpr.

- Add IPRange::FromIPv4 factory function (to replace the iprange_ipv4
free function)
2020-05-20 19:18:27 -03:00
Stephen Shelton
807bfc5302
Initialize Config with LoadConfig in all key manager tests 2020-05-20 15:54:23 -06:00
Stephen Shelton
fa6845b206
Use global RC file paths instead of redefining them 2020-05-20 15:54:23 -06:00
Stephen Shelton
ac225eb65e
Testing: explicitly initialize variable 2020-05-20 15:54:22 -06:00
Stephen Shelton
7167b4ad02
Properly initialize config in unit test 2020-05-20 15:54:21 -06:00
Rick V
918a09c0cf fix sockaddr win32 and collapse headers on the unix side 2020-05-18 15:13:45 -05:00
Jason Rhinelander
c5faa86926 cmake refactor
Refactors many things in cmake to improve and simplify:

- don't use variable indirection for target names; target names are
*already* a variable of sorts.  (e.g. ${UTIL_LIB} is now just
lokinet-util).  cmake/basic_definitions.cmake is now gone.

- fix LTO enabling to use the standard cmake (3.9+) LTO mechanism rather
than shoving a bunch of flag hacks through link_libraries and
add_compile_options.  This also now enables LTO when building a shared
library (because previously the -flto hacks were only turned on in the
static code for some reason).

- build liblokinet as *either* shared library or static library, but not
both.  Building both makes things more complicated because they had
different names (lokinet-shared or lokinet-static) and seems pointless:
you generally want one or the other.  Now there is just the liblokinet
target, which will be shared or static depending on the value of
BUILD_SHARED_LIBS.

- Simplify lokinet-cryptography AVX2 code: just build *one* library, and
add in the additional AVX2 files when possible, rather than building two
and needing to merge them.

- Compress STATIC_LINK and STATIC_LINK_RUNTIME into just STATIC_LINK.
It makes no sense to use one of these (_RUNTIME) on Windows and the
other on non-Windows when they appear to try to do the same thing.

- remove a bunch of annotations from `endif(FOO)` -> `endif()`.

- move all the tuntap compilation code (including OS-specific source
file selection) into vendor/CMakeLists.txt and build tuntap as an
intermediate OBJECT library rather than keeping a global variable in 5
different files.

- move release motto define to root cmake; it made no sense being
duplicated in both unix.cmake and win32.cmake

- fix add_log_tag to not stomp on any existing source compile flags with
its definition.  Also use proper compile definition property instead of
cramming it into compile flags.

- make optimization/linker flags less hacky.  There's no reason for us
to force particular optimization flags because the cmake build type
already does that (e.g. -DCMAKE_BUILD_TYPE=Release does -O3).  Not doing
that also silences a bunch of cmake warnings because it thinks "-O0 -g3"
etc.  are link libraries (which is reasonable: that's what the code was
telling cmake they are).

- sets the default build type to RelWithDebInfo which gives us `-O2 -g`
if you don't specify a build type.

- Move PIC up (so that the things loaded in unix.cmake, notably libuv,
have it set).

- Add a custom `curl` interface library that carries the correct link
target and include paths for curl (system or bundled).
2020-05-17 23:31:23 -03:00
Jason Rhinelander
26ecf23ad8 Silence various warnings 2020-05-17 21:28:17 -03:00
Jason Rhinelander
bc4573c447 Disable empty string SockAddr throw test
The code intentionally no longer throws and handles this as a special
case (resulting in an empty SockAddr).
2020-05-17 17:08:11 -03:00
Jeff Becker
1780e86faa
fix up unit tests, make them all pass 2020-05-15 08:38:04 -04:00
Jeff
a5b09c47e1
Merge pull request #1262 from notlesh/bandaids-for-sockaddr-refactor-2020-05-11
Bandaids for sockaddr refactor 2020 05 11
2020-05-12 12:04:59 -04:00
Stephen Shelton
174c9ec740
log-- 2020-05-08 16:52:46 -06:00
Stephen Shelton
78d09f2ae5
Support SockAddr in from sockaddr and friends 2020-05-08 16:52:00 -06:00
Stephen Shelton
e944bcb28a
Unit tests and fixes for SockAddr::fromString() 2020-05-08 14:33:44 -06:00
Stephen Shelton
0b54087689
Begin implementing SockAddr 2020-05-08 11:23:21 -06:00
Stephen Shelton
bcf473757d
Fix broken config-related test cases 2020-05-08 08:43:25 -06:00
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
2020-05-06 10:45:30 -04:00
Stephen Shelton
42a7bcd434
Less invasive fix for Addr 2020-05-04 11:08:25 -04:00
Stephen Shelton
d3b248e004
Add test for broken Addr::from_char_array() 2020-05-04 11:07:22 -04:00
Stephen Shelton
779658edd0
Refactor ExitEndpoint's config, mv dns ops from [network] to [dns] 2020-05-04 11:05:51 -04:00
Stephen Shelton
21ad442b55
Remove NetConfig_t 2020-05-04 11:05:51 -04:00
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.
2020-05-01 17:43:27 -03:00
Stephen Shelton
5c6c7c7020
Expand on ConfigDefinition truthy/falsy unit test 2020-04-29 12:40:29 -06:00
Stephen Shelton
320564d792
Specialize ConfigOption for bool to accept "truthy" / "falsy" values 2020-04-29 12:32:07 -06:00
Stephen Shelton
936fbb2424
Fix config not falling back to undeclared handler for missing option 2020-04-29 09:41:07 -06:00
Stephen Shelton
526b1320b7
Some maybe-fixes for RouterHive post config cleanup 2020-04-24 11:18:25 -06:00
Stephen Shelton
dfcf8fb62e
Update RouterHive to reflect config changes 2020-04-07 17:50:50 -06:00
Stephen Shelton
0a9515a94a
Proper support for multiple values @ ConfigDefinition 2020-04-07 14:25:20 -06:00
Stephen Shelton
a6787657be
Refactor config comments to take list of strings 2020-04-07 14:24:49 -06:00
Stephen Shelton
a8671cf9c7
Rename config classes for clarity
ConfigDefinition -> OptionDefiniton
Configuration -> ConfigDefinition
2020-04-07 14:24:49 -06:00
Stephen Shelton
9e850705b4
Add 'AssignmentAcceptor' convenience for simple config acceptors 2020-04-07 14:20:59 -06:00
Stephen Shelton
733efbab40
Reflect removal of accessors on config structs 2020-04-07 14:20:31 -06:00
Stephen Shelton
028e55e997
Remove pre-refactor config test 2020-04-07 14:14:33 -06:00
Stephen Shelton
14e7789847
Add padding to config file generated output 2020-04-07 14:12:31 -06:00
Stephen Shelton
18ee23c2a3
Support for comments in config definition 2020-04-07 14:11:58 -06:00
Stephen Shelton
c5ff672c79
Use 'undeclared handler' for multi-valued 'add-node' config option 2020-04-07 14:10:11 -06:00
Stephen Shelton
9a1b7b20de
Add "undeclared value" handler to Configuration 2020-04-07 14:09:14 -06:00
Stephen Shelton
e9708a5d1c
Add split(string_view, char) util function 2020-04-07 14:09:14 -06:00
Stephen Shelton
ffc58fcedb
Remove dead code (serverOptions) 2020-04-07 14:09:13 -06:00
Stephen Shelton
2e47262350
Demystify LinksConfig 2020-04-07 14:08:45 -06:00
Stephen Shelton
a44eb73baa
Add config INI output unit tests 2020-04-07 14:01:46 -06:00
Stephen Shelton
69331f1571
Remove multiValued as an argument to ConfigDefinition 2020-04-07 14:01:45 -06:00
Stephen Shelton
f6d000838f
Clarity and convenience for defining config options 2020-04-07 14:01:45 -06:00
Stephen Shelton
02e31f3867
Introduce acceptor function in ConfigDefinition 2020-04-07 14:01:44 -06:00
Stephen Shelton
60d0bf2a9b
Rename function for clarity 2020-04-07 14:01:44 -06:00
Stephen Shelton
8352de7bd4
Config documentation, clarity 2020-04-07 14:01:43 -06:00
Stephen Shelton
1b19314278
Implement Configuration::generateDefaultConfig(), maintain insertion order 2020-04-07 14:01:43 -06:00
Stephen Shelton
105dd30fd9
More ConfigDefinition unit tests, fixes, support std::string as type 2020-04-07 14:01:42 -06:00
Stephen Shelton
25212b929c
Add ConfigDefinition unit tests, fixes 2020-04-07 14:01:41 -06:00
Stephen Shelton
0fb888890f
First pass at Configuration definition classes 2020-04-07 14:01:41 -06:00
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.
2020-04-07 14:01:40 -06:00
Jeff
d3091cf9fc
Merge pull request #1167 from tewinget/tooling
RouterHive initial PR
2020-04-07 13:13:02 -04:00
Jeff Becker
99c814e6b0
fix dns rebinding vuln in jsonrpc 2020-03-04 13:59:33 -05:00
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
2020-03-04 00:57:26 -05:00
Thomas Winget
7e0e8ab7bf hive.py upgrades, now with more cli args! 2020-03-03 19:57:09 -05:00
Thomas Winget
a58a8c9a61 hive.py now defaults to 1000 relays because f your box.
also check for error on uv_async_init...

may want to `ulimit -Sn $(ulimit -Hn)`...
2020-03-03 19:57:09 -05:00
Thomas Winget
c8c66f0a5f some refactoring of tooling code, added RCGossipReceivedEvent 2020-03-03 19:57:09 -05:00
Thomas Winget
912e4267e4 I'm a muppet. 2020-03-03 19:57:09 -05:00
Thomas Winget
df0380e746 LRSM RouterEvent, added to hive test and test passes. 2020-03-03 19:57:09 -05:00
Thomas Winget
771d0b4489 hive pytest framework in place (and path build test works)! 2020-03-03 19:57:09 -05:00
Jeff Becker
e3b5fb4dd9
add local publish intro message to send reply down path 2020-03-01 12:30:05 -05:00
Stephen Shelton
deac8e74ea
Remove dead unit tests 2020-02-28 17:05:58 -07:00
Stephen Shelton
6b906de00d
Judicious removal of dead code 2020-02-28 16:26:45 -07:00
Jeff Becker
dea78d2326
change function signature for dht context to exclude time parameter 2020-02-27 11:37:23 -05:00
Jeff Becker
e8f262ba1c
disable flawed unit test 2020-02-25 17:43:08 -05:00
Jeff
a8a6c175fc
Merge pull request #1128 from majestrate/use-std-chrono-2020-02-24
make llarp_time_t use std::chrono::milliseconds
2020-02-25 15:36:00 -05:00
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 2020-02-25 12:05:13 -05:00
Jason Rhinelander
3bd400f6fe Fix string_view C++17 compatibility
string_view was implicitly convertible to std::string, but
std::string_view is only explicitly convertible.  This makes the
`operator std::string` explicit to be more compatible, and re-adds a
bunch of explicit string casts to the code where needed.

(This also fixes the build if changing the standard to c++17)
2020-02-25 11:52:43 -04:00
Jeff Becker
d2d109e92c
llarp_time_t is now using std::chrono 2020-02-24 15:25:03 -05:00
Jeff Becker
f4520ac920
make decaying hashset use llarp::Time_t and move unit tests to use catch2 2020-02-24 15:22:49 -05:00
Jason Rhinelander
18a2444c50 Add gcc5 workaround for catch2 GENERATE(table
stdlibc++'s before v6 erroneously have the tuple constructor as
explicit, which causes the initializer lists here to fail.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
1232f34f90 Rewrite generate expressions to make clang-7 happy 2020-02-24 14:27:44 -04:00
Jason Rhinelander
0839c16f19 Final abseil purge
Bye-bye Google Boost.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
46242ba69b TrimWhiteSpace -> TrimWhitespace
Fix my dumb initial capitalization choice.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
74d4afad51 Remove metric config parsing 2020-02-24 14:27:44 -04:00
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.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
561bfe24c0 Add cmake "check" target to run all tests
Renames the cmake Catch2 test target to "catch" (instead of "check") and
adds a "rungtest" for gtest (because the "gtest" target is already taken
by the gtest library itself), and then repurposes the "check" target to
run both test suite binaries.

Also updates the top-level Makefile to do the same thing, except that
there the gtest target is just "gtest" instead of "rungtest".
2020-02-24 14:27:44 -04:00
Jason Rhinelander
98c34d995b De-abseil: Add our own llarp::TrimWhiteSpace
Adds a TrimWhiteSpace instead of using abseil's.

Adds Catch2 tests for it, and also converts the existing str tests to
catch (which look much, much nicer than the gtest ones).
2020-02-24 14:27:44 -04:00
Jason Rhinelander
fe61367a87 Vastly simplified llarp::util::memFn
There is a huge pile of unnecessary machinery here that can be solved
with a few lambdas and some member function pointer type deduction.
2020-02-21 23:24:33 -04:00
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
2020-02-21 23:22:47 -04:00
Stephen Shelton
16be86a5c3
Merge pull request #1116 from tewinget/short-path-names
path builder prints hops, rest print short name
2020-02-21 08:58:05 -08:00
Thomas Winget
fc56a018e5 path builder prints hops, rest print short name 2020-02-20 16:37:39 -05:00
Jeff
7c5a721457
Merge pull request #1114 from notlesh/redundant-introset-lookup-improvements-2020-02-20
Redundant introset lookup improvements
2020-02-20 15:25:09 -05:00
Stephen Shelton
0429bafbb3
Merge pull request #1111 from notlesh/redundant-introset-propagation-2020-02-19
Redundant introset propagation
2020-02-20 10:50:06 -08:00
Stephen Shelton
66cb30fa58
Refactor: remove recursionDepth from DHT lookups 2020-02-20 11:18:05 -07:00
Stephen Shelton
dff9aeb250
Propagate Introset publishing redundantly 2020-02-19 17:07:46 -07:00
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").
2020-02-19 18:21:25 -04:00
Jeff Becker
827ca0bda7
make catch2 a submodule 2020-02-17 08:26:20 -05:00
Stephen Shelton
7842889fef Add NodeDB tests around FindClosestTo() 2020-02-14 17:45:22 -04:00
Stephen Shelton
9dfcfbc3ac Bencode/decode relayOrder in lexigraphical order, make it uint64_t 2020-02-14 17:43:13 -04:00
Stephen Shelton
906803e387 Refactor DHT introset lookups to use redundant lookup strategy 2020-02-14 17:43:13 -04:00
Jeff Becker
e35d17764a * add path::Path::UniqueEndpointSet_t
* start using check2 for new unit tests
* unit test for path::Path::UniqueEndpointSet_t
2020-02-14 17:41:31 -04:00