Commit Graph

612 Commits

Author SHA1 Message Date
Jeff Becker
bb9bd25059
get rid of use of llarp::IpAddress from hotpaths 2021-02-22 10:01:05 -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
b484d9bebb
update route poker logic to include "up" 2021-02-17 13:36:57 -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
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
242e56507c
proper lokimq -> oxenmq refactor 2021-02-03 13:12:21 -05:00
Jeff Becker
df4ea34a56
nodedb refactor
* bump zmq static dep
* lokimq -> oxenmq
* llarp_nodedb -> llarp::NodeDB
* remove all crufty api parts of NodeDB
* make NodeDB rc selection api not suck
* make path builder api not suck
* propagate all above changes so that unit tests work and it all compiles
2021-02-02 09:35:40 -05:00
Jeff
49b9ad7197
tun code refactor (#1495)
* partial tun code refactor

* take out the trash

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

* fix hive build

* fix win32

* fix memory leak on win32

* reduce cpu use

* make macos compile

* win32 patches:

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

* fix zmq patch for windows

* clean up cmake for win32

* add uninstall before reinstall option to win32 installer

* more ipv6 stuff

* make it compile

* fix up route poker

* remove an unneeded code block in macos wtf

* always use call to system

* fix route poker behavior on macos

* disable ipv6 on windows for now

* cpu perf improvement:

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

* set up THEN add addresses

* emulate proactor event loop on win32

* remove excessively verbose error message

* fix issue #1499

* exclude uv_poll from win32 so that it can start up

* update logtag to include directory

* create minidump on windows if there was a crash

* make windows happy

* use dmp suffix on minidump files

* typo fix

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

* address feedback from tom

* remove llarp/ev/pipe
* add comments for clairification
* make event loop queue size constant named
2021-01-11 18:13:22 -05:00
Jeff
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
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
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
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
c81b6049f1
fix crashes on shutdown (#1433) 2020-10-29 10:19:45 -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
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
38f13533df
always use data directory for bootstrap.signed (#1405) 2020-10-12 13:03:39 -04:00
Jason Rhinelander
d10fee87c7
Don't report a huge negative elapsed time on startup (#1401) 2020-10-09 11:40:04 -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
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
Jeff Becker
79dfb6d357
kill lmq before stopping links/ 2020-10-02 11:09:13 -04:00
Jeff
503a92c992 un limit lmq 2020-10-02 05:51:52 -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
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
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
2020-09-03 18:22:22 -04:00
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
2020-09-01 17:22:22 -04:00
jeff
1537ad18df format 2020-08-28 11:35:10 +00:00
jeff
75f550434c change assert to throw an exception instead when service node has no peer stats enable.
update unit tests so it passes on debian sid
2020-08-28 11:26:50 +00:00
jeff
5391e6a66a initial config overriding on runtime 2020-08-27 12:43:53 +00:00
jeff
f6f56029d3
working netlink route poker 2020-08-24 20:23:26 -04:00
jeff
b0bb0b7609
initial route poking 2020-08-24 20:21:55 -04:00
jeff
2aaed895f3
disable exits in RCs 2020-08-24 20:19:51 -04:00
Jeff Becker
ff130e2b5e
die if we are a relay and don't have any inbound links 2020-08-24 20:19:51 -04:00
Stephen Shelton
4699280d97
Crude attempt at retrying lokid connection 2020-07-23 10:54:39 -06:00
Stephen Shelton
0f074cff8c
Remove ambguity WRT loading and passing of Config 2020-07-06 13:38:02 -06:00
Stephen Shelton
f607b99dbe
Fixes to Context::Configure with default config 2020-07-02 12:25:16 -06:00
Stephen Shelton
cdaa28bfd3
Use QueueDiskIO instead of diskworker for db flushing 2020-07-02 10:36:12 -06:00
Stephen Shelton
552dcce5fd
Use inheritance to handle Hive injection 2020-07-02 10:25:10 -06:00
Stephen Shelton
84c83a2400
Add specialized subclass of Router for Hive 2020-07-02 10:22:57 -06:00
Stephen Shelton
0ecdda7a89
make format 2020-07-02 10:22:04 -06:00
Stephen Shelton
aeb0c2be3a
Remove ability to stop routers from gossiping for now 2020-07-02 10:22:03 -06:00
Stephen Shelton
bdac43e19f
Peer stats test which artificially stops a router from gossiping its RC 2020-07-02 10:22:03 -06:00
Stephen Shelton
d1b629f494
RouterHive ConnectionAttemptEvent 2020-07-02 10:22:02 -06:00
Stephen Shelton
b2a72dd46a
Initial test_peer_stats hive test 2020-07-02 10:16:19 -06:00
Stephen Shelton
2453fff10b
Piggyback on link callbacks to add peer stats 2020-07-02 10:13:26 -06:00
Stephen Shelton
023e061146
Make [router]:enable-peer-stats only valid for client 2020-07-02 10:13:25 -06:00
Stephen Shelton
d897099e1d
Track traffic peerstats 2020-07-02 10:13:24 -06:00
Stephen Shelton
5e05defc76
Add API query for peer stats, other related fixes 2020-07-02 10:13:22 -06:00
Stephen Shelton
595288e046
Add PeerDb::handleGossipedRC 2020-07-02 10:13:22 -06:00
Stephen Shelton
2a30e7dac2
Add PeerDb to Router 2020-07-02 10:13:21 -06:00
Jeff Becker
d7ff6c579c
address feedback from jason
* split up ipv6 netmask
* revert iwp ack interval change
* c++17-isms in ip range map
* lambda-ize nodedb
* mutable lambdas in transit hops
* perfect forwarding of args in abstract router
* mutable lambdas in lokid rpc client
* notes in readme about nproc
2020-07-02 11:13:32 -04:00
Jeff Becker
a9109aa91b
* deprecate old unused lokid rpc options
* use lokimq::address in config and in lokid rpc
* bump lokimq submodule
2020-07-02 11:13:31 -04:00
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
2020-07-02 11:13:31 -04:00
Jason Rhinelander
a7c42ab2bd
Use lokimq's hex/base32z encoding/decoding 2020-07-02 11:13:31 -04:00
Jeff Becker
e13e886df9
fix up event loop crap so that unit tests pass 2020-07-02 11:10:06 -04:00
Jeff Becker
1779f33506
fix makefile fromat target
use lokimq::address instead of std::string or std::string_view
2020-07-02 11:07:34 -04:00
Jeff Becker
397d558af8
wtf 2020-07-02 11:07:34 -04:00
Jeff Becker
59eb1b0842
make format 2020-07-02 11:07:34 -04:00
Jeff Becker
f1e7fc2cba
make format and update submodule 2020-07-02 11:07:34 -04:00
Jeff Becker
f4971a88fd
use lokimq workers instead of llarp:🧵:ThreadPool 2020-07-02 11:07:34 -04:00
Jeff Becker
be01808a6b
more 2020-07-02 11:07:33 -04:00
Jeff Becker
c5dbb670ca
set sane defaults for config, implement lmq rpc server, update lokinetmon 2020-07-02 11:07:33 -04:00
Jeff Becker
6bbf7beaf5
add stubs for lmq rpc server 2020-07-02 11:07:33 -04:00
Jeff Becker
1175a583d2
initial working code 2020-07-02 11:07:32 -04:00
Jeff Becker
9bfff61d08
initial wack at lokimq 2020-07-02 11:07:32 -04:00
Stephen Shelton
fd4b03f896
WIP: LokidRpcClient 2020-07-02 11:07:32 -04:00
Stephen Shelton
17026a0b21
Remove libabyss and rpc::Caller/rpc::Server 2020-07-02 11:07:32 -04:00
Jeff Becker
d5b4dbe052
more 2020-07-02 11:07:32 -04:00
Jeff Becker
b1259e25c5
set sane defaults for config, implement lmq rpc server, update lokinetmon 2020-07-02 11:07:31 -04:00
Jeff Becker
fb8b8e2e56
add stubs for lmq rpc server 2020-07-02 11:07:31 -04:00
Jeff Becker
ad882d0d70
initial working code 2020-07-02 11:07:31 -04:00
Jeff Becker
0006751d80
initial wack at lokimq 2020-07-02 11:07:31 -04:00
Stephen Shelton
91725a8530
WIP: LokidRpcClient 2020-07-02 11:07:31 -04:00
Stephen Shelton
11951510bf
Remove libabyss and rpc::Caller/rpc::Server 2020-07-02 11:07:30 -04:00
Jeff Becker
800668348a
add regression test for key backup bug 2020-06-08 08:42:10 -04:00
Jeff Becker
019168fef0
remove unused local variable 2020-06-05 11:40:19 -04:00
Jeff Becker
1899debfb5
unfug transit hops 2020-06-05 11:40:18 -04:00
Stephen Shelton
193060d602
Undo client-related changes to RC creation
This partially reverts changes from
1497b829bd and intsead only prevents
clients from saving their RC to disk.
2020-06-04 15:02:05 -06:00
Stephen Shelton
980853804d
Remove log statement 2020-06-04 13:34:15 -06:00
Stephen Shelton
cecafb3215
Undo unintentional revert? 2020-06-04 13:32:38 -06:00
Stephen Shelton
d8b12ce764
Let KeyManager assemble key filenames 2020-06-04 12:38:35 -06:00
Stephen Shelton
1497b829bd
Ignore our self.signed file if we're a client 2020-06-04 11:05:23 -06:00
Jeff
45cda241f0
Merge pull request #1272 from majestrate/exit-nodes-2020-05-16
exit traffic via snapps
2020-06-01 14:42:43 -04:00
Jeff Becker
acecb23eb3
make libuv event loop logic queue size configurable.
remove logic constructor that is no-op.
add constant for default logic queue size
add constant for transit hop queue size
2020-06-01 09:17:44 -04:00
Rick V
1340cd0dce remove some string conversions entirely 2020-05-26 23:09:16 -05:00
Rick V
f62214cf8c
first pass fix wstring path conversions 2020-05-26 20:48:07 -05:00
Jeff Becker
39f8f17b53
dont set callback if non provided 2020-05-23 16:07:21 -04:00
Jeff Becker
c826d0a0b1
increase transit hop limits 2020-05-23 16:07:20 -04:00
Jason Rhinelander
3bb24580a4 make format 2020-05-20 19:48:13 -03:00