Commit Graph

227 Commits (b81f7025c9a619409bb1c3f39e0c56e2084fd7be)

Author SHA1 Message Date
Jason Rhinelander b81f7025c9
Replace logging with oxen-logger
Replaces custom logging system with spdlog-based oxen logging.  This
commit mainly replaces the backend logging with the spdlog-based system,
but doesn't (yet) convert all the existing LogWarn, etc. to use the new
format-based logging.

New logging statements will look like:

    llarp::log::warning(cat, "blah: {}", val);

where `cat` should be set up in each .cpp or cluster of .cpp files, as
described in the oxen-logging README.

As part of spdlog we get fmt, which gives us nice format strings, where
are applied generously in this commit.

Making types printable now requires two steps:
- add a ToString() method
- add this specialization:

      template <>
      constexpr inline bool llarp::IsToStringFormattable<llarp::Whatever> = true;

This will then allow the type to be printed as a "{}" value in a
fmt::format string.  This is applied to all our printable types here,
and all of the `operator<<` are removed.

This commit also:
- replaces various uses of `operator<<` to ToString()
- replaces various uses of std::stringstream with either fmt::format or
  plain std::string
- Rename some to_string and toString() methods to ToString() for
  consistency (and to work with fmt)
- Replace `stringify(...)` and `make_exception` usage with fmt::format
  (and remove stringify/make_exception from util/str.hpp).
2 years ago
Pebu 9db192079b
Update error message
Message is paths must be >= 2 but condition is checking for < 3
2 years ago
Jeff 98b3860655
set source ip on service nodes for outbound link to not use all interfaces 2 years ago
Jeff 5050cd0299 add hashed password capability to endpoint auth by file 2 years ago
Jeff a082ba4e77 add file auth for tokens 2 years ago
Jeff 9a6bfe6013 static endpoint auth codes 2 years ago
Jeff ac9fb9d479 use quad nine as default upstream dns 2 years ago
Jeff b3d9cd463f route poker: allow not blackholing routes.
allow runtime configuration to disable ip blackholing.
2 years ago
Jeff Becker 061aebc964
reword auto-routing config comment 2 years ago
Jeff Becker 14ffdb6639
configurable route poker
this allows you to use exit nodes without forcing routes over the interface, useful for using lokinet with an exit and selectively routing over the lokinet interface using an external socks proxy or binding to device explicitly.

* make route poker configurable, defaults to enabled but allows disabling it on runtime if desired
* add config option [network]:auto-routing to enable/disable route poker
2 years ago
Jeff Becker da887dc559
implement exit node pooling, allows users to use multiple exits for an address range.
mappings per ip stick to the same exit, each new ip is mapped to a random exit in the specified pool.

make exit-auth multi value
2 years ago
Jeff 388fc53380
match io loop event order on windows/apple to match linux.
on win32/apple reading packets from the interface does not count as an io operation.
manually trigger pump on win32/apple to pretend that it is an io event.
add platform quark function MaybeWakeUpperLayers on vpn::Interface to manaully wake up the other components on platforms that need that (ones on which packet io is not done via io events).
on non linux platforms, use uv_prepare_t instead of uv_check_t as the former triggers before blocking for io, instead of after. this better matches linux's order of operations in libuv.
2 years ago
Jeff Becker 5e9f9686e7
set base v6 address to nullopt when explicit empty string is provided 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
Jeff Becker 37dde7da05
format 3 years ago
Jason Rhinelander f39084bffa
Merge pull request #1714 from jagerman/remove-broken-split
Remove unneeded split(str, char) method
3 years ago
Jason Rhinelander 1b878e348b
Merge pull request #1715 from jagerman/default-upstream-dns-port
Fix default upstream DNS not working
3 years ago
Jason Rhinelander 73f0432b28 Fix default upstream DNS not working
The default upstream DNS was being set to 1.1.1.1:0, which doesn't work.
This fixes it to also set the port so that default upstream resolution
(i.e. with an empty config) works again.
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
Jason Rhinelander ae1243e9d9 Remove unused defaults.hpp
The definitions in here aren't actually used anywhere anymore, so just
drop it.
3 years ago
Jeff Becker a0505d8e85
mitigate lto compiler bug with lto 3 years ago
Jeff Becker a6fbaa7c7a
add dns hosts file option for user side dns filtering 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 c9b4ca85b2
[feature] optionally keep inbound convos mapped to same IP on restart (#1672)
* add option to persist address mappings between restarts using [network]:persist-addrmap-file

* make it work

* only persist address map for inbound convos

* turn persisting address map on by default

* dont load addrmap file if it has been modified last over a minute ago to prevent foot cannons fired from loading a really old version of it
3 years ago
Jeff Becker 4199f2f52b
fix an assert fail in gcc 11. 3 years ago
Jeff d514f30eaa
Merge pull request #1620 from majestrate/default-log-level-warn-2021-05-01
make default log level warn
3 years ago
Jeff Becker ed707eecf9
change granularity to seconds 3 years ago
Jeff Becker 2968caf7af
make default log level warn fixes #1593 3 years ago
Jeff Becker 54f9e1b44e
make path alignment timeout configuable
adds [network] section parameter called path-alignment-timeout that allows configring the timeout
for optional name lookup + introset lookup + aligned path build, used by tun endpoint dns, provided
as milliseconds.
3 years ago
Jeff Becker b721b8d65b
finish wiring up config for #1595 3 years ago
Jeff Becker fedc56e3f1
initial commit for #1595 3 years ago
Jeff Becker 545021aa3d
temp commit 3 years ago
Jeff Becker 94ecf02a62
add option to run lokinet traffic only with no exit and drop all non lokinet traffic
triggered by: exit-node=null
3 years ago
Jeff Becker 2188b443e9
more liblokinet api stuff
* add lokinet_wait_for_ready to wait until we have published introsets and such
* optionally expose ports in lnproxy
* dont save profiles by default
3 years ago
Jeff Becker 95cd275cdd
liblokinet additions:
* add lokinet_add_bootstrap_rc function for adding an rc from memory
* prevent stack overflow on error closing connection in quic
* add in memory nodedb
* refactor how convotags are set as active
* add initial stubs for endpoint statistics
* refactor time stuff to be a bit cleaner
* update lnproxy script with more arguments
3 years ago
Jeff Becker 8bc60a59ac
fix up liblokinet api to be more friendly to ffi
add lnproxy exmaple of use of liblokinet
3 years ago
Jeff Becker 853cc52efb
wire up liblokinet 3 years ago
Jason Rhinelander 752879d712
QUIC lokinet integration refactor
Refactors how quic packets get handled: the actual tunnels now live in
tunnel.hpp's TunnelManager which holds and manages all the quic<->tcp
tunnelling.  service::Endpoint now holds a TunnelManager rather than a
quic::Server.  We only need one quic server, but we need a separate quic
client instance per outgoing quic tunnel, and TunnelManager handles all
that glue now.

Adds QUIC packet handling to get to the right tunnel code.  This
required multiplexing incoming quic packets, as follows:

Adds a very small quic tunnel packet header of 4 bytes:

    [1, SPORT, ECN] for client->server packets, where SPORT is our
    source "port" (really: just a uint16_t unique quic instance
    identifier)

or

    [2, DPORT, ECN] for server->client packets where the DPORT is the SPORT
    from above.

(This also reworks ECN bits to get properly carried over lokinet.)

We don't need a destination/source port for the server-side because
there is only ever one quic server (and we know we're going to it when
the first byte of the header is 1).

Removes the config option for quic exposing ports; a full lokinet will
simply accept anything incoming on quic and tunnel it to the requested
port on the the local endpoint IP (this handler will come in a following
commit).

Replace ConvoTags with full addresses: we need to carry the port, as
well, which the ConvoTag can't give us, so change those to more general
SockAddrs from which we can extract both the ConvoTag *and* the port.

Add a pending connection queue along with new quic-side handlers to call
when a stream becomes available (TunnelManager uses this to wire up
pending incoming conns with quic streams as streams open up).

Completely get rid of tunnel_server/tunnel_client.cpp code; it is now
moved to tunnel.hpp.

Add listen()/forget() methods in TunnelManager for setting up quic
listening sockets (for liblokinet usage).

Add open()/close() methods in TunnelManager for spinning up new quic
clients for outgoing quic connections.
3 years ago
Jeff Becker a1a1b2e2bc
remove superflous include 3 years ago
Jeff Becker 1885b1cae9
more 3 years ago
Jeff Becker cf85ea6f2b
add warning and note in documenation of config option 3 years ago
Jeff Becker a83428297e
make ipv6 range used by exit traffic configurable.
* add ip6-range option to network section to control which range we want to use for ipv6 traffic
* make ip6-range able to disable ipv6 exits ( i dont like this but eh )
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
Jeff f2b234d6c3
Merge pull request #1539 from majestrate/path-algorithm-flavors-2021-02-18
add option to enforce unique netblocks per path.
3 years ago
Thomas Winget 4c630e0437 Large collection of changes to make android work
- Previous android java and jni code updated to work, but with much love
  still needed to make it work nicely, e.g. handling when the VPN is
  turned off.

- DNS handling refactored to allow android to intercept and handle DNS
  requests as we can't set the system DNS to use a high port
  (and apparently Chrome ignores system DNS settings anyway)

- add packet router structure to allow separate handling of specific
  intercepted traffic, e.g. UDP traffic to port 53 gets handled by our
  DNS handler rather than being naively forwarded as exit traffic.

- For now, android lokinet is exit-only and hard-coded to use exit.loki
  as its exit.  The exit will be configurable before release, but
  allowing to not use exit-only mode is more of a challenge.

- some old gitignore remnants which were matching to things we don't
  want them to (and are no longer relevant) removed

- some minor changes to CI configuration
3 years ago
Jeff Becker a88aec5f01
fix typo 3 years ago
Jeff Becker a3585caa70
add value 0 to disable unique-range-size 3 years ago
Jeff Becker f7424b8bbe
dont use std::optional 3 years ago
Jeff Becker 3425069b41
feedback from jason
* use emplace in PeerSectionConfig::Acceptable use insert everywhere else
* use const l-value references
* fix typos and spelling mistakes
3 years ago