Commit Graph

366 Commits (4723b532eb85784e0e643fcd2233253a8e775fc1)

Author SHA1 Message Date
Jeff Becker 37a9bd768e
fix linking on win32 for lokinet.dll
only apply static link flags for executables
3 years ago
Jason Rhinelander 73a29d3b07 Link lokinet-bootstrap against libssl as well
Just crypto apparently isn't enough, at least on some arches/distros.
3 years ago
Jeff Becker c547cd0118
fixes for lokinet-bootstrap
* use schannel on windows platforms
* load ca bundle for non windows platforms
* use geteuid for detecting root user when finding default data dir
3 years ago
Jeff Becker 3d87dbff91
bullshit for windows and openssl with CPR
* windows static cross compile is wonky af so we add some hacks to make it work
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
Jason Rhinelander 1d6ad7284c
Fix cursed formatting 3 years ago
Jeff Becker c92894804c
Merge remote-tracking branch 'origin/stable' into dev 3 years ago
Jeff Becker 68826f10bb use binary mode for writing files 3 years ago
Jeff Becker 4daebc0141
catch exception and print out error 3 years ago
Jeff Becker a0d3ab125a
throw on failed writing and port fs namespace changes from oxen-core 3 years ago
Jeff Becker a80d8b95b3
update lokinet-bootstrap
* compat with old shell script curl wrapper's arguments
* do lazy validation of fetched data
3 years ago
Jeff Becker 77de60af91
require openssl explicitly for lokinet-bootstrap 3 years ago
Jeff Becker 27c80a2638
add include directory for daemon directory so llarp/* includes work 3 years ago
Jeff Becker e8178a032e
lokinet-bootstrap native binary 3 years ago
Jeff Becker 0c37cc7f60
lokinet-bootstrap native binary 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
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
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
Jeff Becker 4540c964f5
rework cmake install targets
* redo setcap on linux so that it's required to do install targets on linux
* add -DWITH_SETCAP=OFF option to bypass setcap requirement on linux
* remove lokinet-bootstrap.ps1 as we bundle the bootstrap in the win32 installer now
* remove references to lokinet-bootstrap.ps1 in cmake
3 years ago
Jeff Becker d4112b157c
add explicit check for setcap binary when doing setcap so when it's missing it's not a nop / silent failure 3 years ago
Jeff Becker ffef3bc48f
wire up sigusr1 to reset libunbound dns resolver 3 years ago
Jeff Becker bd93a8f828
initial v6 exits 3 years ago
Jeff Becker d112a50096
minidump fix 3 years ago
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
3 years ago
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
3 years ago
Jeff 6407733c8e
* make llarp.halt rpc call actually return a reply (#1488)
* add --kill flag to lokinet-vpn that calls llarp.halt
* make macos uninstaller kill lokinet via lokinet-vpn --kill
4 years ago
Jeff 0e1e0aaef3
allow for relative file paths in config (#1432)
* llarp::Config constructor can take an empty fs::path now and it will default to fs::current_path
* llarp::ensureConfig now throws on fs error
* updates to daemon/main.cpp to reflect changes to llarp::ensureConfig's new throwability
* dowse parts of the code with holy water for the 0.8.1 tag
4 years ago
Jeff f4e2f93c8e
use correct path for windows service (#1418) 4 years ago
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
4 years ago
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
4 years ago
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>
4 years ago
Jeff 03d6f191d1
add status command to lokinet-vpn (#1393) 4 years ago
Jason Rhinelander 63a876cc78
Allow -DWITH_SETCAP=OFF to disable setcap during make install (#1363)
The debs don't want it (and so this will save needing to patch it out),
nor do you need it if running via a systemd service file that sets the
capabilities.
4 years ago
Rick V 7136f77c2e
allow running lokinet as root on windows (#1347)
* - allow running lokinet as root on windows
  ($PROGRAMDATA/.lokinet/lokinet.ini)
- oops forgot to eat my own command line args

* cursed windows

* now that we eat our own startup options the entry in cxxopts is fully
ded

* aha our command line options get smashed up

* revert plus DRY fix
4 years ago
Jeff dfd8df5e7f
add uninstall target (#1340)
* add uninstall target

* * redo cmake uninstall
* remove lokinet-vpn python script
* don't install lokinet-vpn twice
4 years ago
jeff bbc749294e fix windows build typo 4 years ago
Jeff Becker 21bc3bd9a0
format 4 years ago
jeff f6f56029d3
working netlink route poker 4 years ago
jeff 099831719a
update macos command for default route poker. 4 years ago
jeff 528340e056
dont include sys/wait.h on windows 4 years ago
jeff d0374ce083
windows does not have fork/wait 4 years ago
jeff 6d91ac8e4e
rename r flag to router 4 years ago
jeff f5e4d8bd1b
execv needs program name as first argument 4 years ago
jeff 0ee1c4a60a
use full path for ip on linux and report exit code 4 years ago
jeff bc8e867dfb
use exec for lokinet-vpn 4 years ago
Rick V f283c565e7
make x.x.x.y+1 the default router on windows 4 years ago
Jeff Becker 400f5d3902
windows uses multiple commands for default route. 4 years ago
Jeff Becker d1abee84d1
windows route hack because lol windows 4 years ago
Jeff Becker b2e5a178a4
verbose logging of executed commands 4 years ago