Commit Graph

81 Commits

Author SHA1 Message Date
Jeff Becker 4508c59cd3
redo includes to be consistent 2023-01-20 13:26:22 -05:00
drouhana 0edfe8ff83
IPC Socket Fixes (#2111)
* 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)
2023-01-20 14:15:18 -04:00
Jason Rhinelander d011f8fb4a
Bump clang-format to 14 2022-10-20 19:53:52 -03:00
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
2022-09-08 14:24:59 -04:00
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.
2022-09-08 14:23:52 -04:00
Jeff 68148e098f
* add mockable network functions
* add unit tests with ability to pretend to be different network setups
2022-07-20 13:36:03 -04:00
Jason Rhinelander f9371233ee
hive fmt/spdlog updates 2022-07-19 15:27:31 -03:00
Jeff 98b3860655
set source ip on service nodes for outbound link to not use all interfaces 2022-05-27 13:26:30 -04:00
Jason Rhinelander d02558350a
Crank oxen-mq to (1.2.)11; switch to oxen-encoding
- Update oxen-mq submodule to latest stable
- Add oxen-encoding submodule
- Convert all oxenmq encoding usage to oxenc
- Modernize cmake handling of oxenmq/oxenc
2022-02-17 16:30:17 -04:00
Jeff Becker c655a21d68 typofix 2022-01-31 10:53:48 -05:00
Jeff Becker f8768488ed make pybind compile 2022-01-31 10:53:48 -05:00
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.
2021-12-15 15:25:53 -05:00
Jeff Becker e4ed53224c
use weak_ptr on a path to reference its parent pathset instead of a bare pointer so crashes dont happen 2021-06-08 14:36:32 -04:00
Jeff Becker 7df184eb54
pybind fixes 2021-04-20 09:45:06 -04:00
Jason Rhinelander e27fdf4c9a
Simplify/unify SendTo* methods
Overload them to the same name to make it easier to call and/or visit
them with either a RouterID, Address, Variant, or ConvoTag.
2021-04-19 06:58:36 -04:00
Jeff Becker 9d483a12db
* add protocol type to snode traffic
* make path::PathSet::SendPacketToRemote know about protocol type
2021-04-19 06:58:35 -04:00
Jeff Becker fc9b09bdbc
clean up address/ip management code to use std::variant and std::optional 2021-04-19 06:58:05 -04:00
Jason Rhinelander 0339bd941a Convert protocol type to enum class 2021-03-10 11:16:55 -04:00
Thomas Winget 43bd6a9842 remove vestigal file
a file that was accidentally committed after being moved was
suddenly being chosen as an include target over the correct
one due to an amusing coincidence of cmake configuration.  that
file is now gone.
2021-03-09 20:09:29 -05:00
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.
2021-03-09 19:01:41 -05:00
Jason Rhinelander d995766436 Android & hive fixes 2021-03-04 16:51:18 -04:00
Jeff Becker ed97d29c97
fix up pyllarp parts
* expose paths config in pyllarp
* fix up pyllarp unit tests
2021-03-02 07:20:29 -05:00
Jeff Becker 1e58715e0b
fix pybind layer 2021-02-02 13:16:34 -05: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
Jeff 50aea744f6
order packets when writing to network interface (#1372)
* order packet writes on userside

* make it compile

* fix pybind
2020-10-08 07:59:01 -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 b0bb0b7609
initial route poking 2020-08-24 20:21:55 -04:00
jeff 75f9643776
attempt to fix snode traffic ip rewrite bug 2020-08-24 20:19:52 -04:00
Stephen Shelton 607d04a314
Use str instead of lokimq::ConnectionID in pybind 2020-07-23 10:52:53 -06:00
Stephen Shelton 56e2bc2c47
Acquire python's Global Interpreter Lock in callbacks 2020-07-06 17:40:42 -06:00
Stephen Shelton a88dc9f026
Prevent pybind from deleting HiveRouter pointers 2020-07-06 17:39:22 -06:00
Stephen Shelton 305795315b
Specify disabling RC gossiping (testing only) properly 2020-07-06 17:38:41 -06:00
Stephen Shelton 0e99f5bc86
Configure HiveContext it pybind correctly 2020-07-06 16:10:42 -06:00
Stephen Shelton 343252c48d
Use HiveContext and HiveRouter properly 2020-07-02 10:26:53 -06:00
Stephen Shelton 552dcce5fd
Use inheritance to handle Hive injection 2020-07-02 10:25:10 -06:00
Stephen Shelton b0d8568452
Remove llarp C API usage from RouterHive 2020-07-02 10:24:19 -06:00
Stephen Shelton 84c83a2400
Add specialized subclass of Router for Hive 2020-07-02 10:22:57 -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 3b6f84c68c
Peek at peer stats db in test_peer_stats 2020-07-02 10:22:02 -06:00
Stephen Shelton d1b629f494
RouterHive ConnectionAttemptEvent 2020-07-02 10:22:02 -06:00
Stephen Shelton d69d538f1a
Add missing files 2020-07-02 10:16:19 -06:00
Stephen Shelton b2a72dd46a
Initial test_peer_stats hive test 2020-07-02 10:16:19 -06:00
Jeff Becker 26f62bc260
make pybind compile 2020-07-02 11:13:32 -04:00
Jason Rhinelander a7c42ab2bd
Use lokimq's hex/base32z encoding/decoding 2020-07-02 11:13:31 -04:00
Jeff Becker 6984cda3a6
add pybind and router hive to ci 2020-06-08 15:50:12 -04: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 93b35c92a7
Eradicate service::Config 2020-05-04 11:05:51 -04: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