Commit Graph

36 Commits

Author SHA1 Message Date
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
fe30193a97
revive android build system (#1339)
* it lives?

* clean up

* add readme and add x86_64 to abi filters

* disable route poking on android

* make it compile on android

* it compiles!!111

* typofix

* re-enable ccache for android
2020-09-22 15:04:15 -04: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
Stephen Shelton
273270916e
The Great Wall of Blame
This commit reflects changes to clang-format rules. Unfortunately,
these rule changes create a massive change to the codebase, which
causes an apparent rewrite of git history.

Git blame's --ignore-rev flag can be used to ignore this commit when
attempting to `git blame` some code.
2020-04-07 12:38:56 -06:00
Jeff Becker
1fbafab9b2
remove unused file 2019-10-09 09:25:29 -04:00
jeff
58a25602f5 more fixes, implemenmt missing functions 2019-10-09 09:08:38 -04:00
jeff
d80633a975 typo fix 2019-10-09 08:43:25 -04:00
jeff
043bf505bc typofix 2019-10-09 08:42:05 -04:00
jeff
9a49c77647 cast 2019-10-09 08:41:34 -04:00
jeff
bcf792d772 more fixups 2019-10-09 08:40:40 -04:00
jeff
4c584dd2da pass template arguments in, fix typo 2019-10-09 08:16:57 -04:00
jeff
7823fd5084 typofix 2019-10-09 08:13:40 -04:00
jeff
6202baf5b1 fix cmakelists.txt file paths 2019-10-09 08:13:04 -04:00
jeff
c26b67c379 finish wiring up jni shizz 2019-10-08 10:52:01 -04:00
jeff
313898999d initial jni wrapper stuff 2019-10-07 06:05:12 -04:00
Jeff Becker
43cb62af16
fix android compile, have makefile pull in libuv for cmake on android 2019-07-24 11:25:40 -04:00
Jeff Becker
909e0399d6
make android compile 2019-07-24 10:17:54 -04:00
Jeff Becker
3da6551e82
make android compile 2019-04-08 11:54:19 -04:00
Michael
67b5d48095
Replace usage of new/delete with unique_ptr/stack allocation 2019-02-11 16:24:05 +00:00
Michael
85dde7b6b0
Move remaining include/llarp headers to llarp/ 2018-12-12 02:53:02 +00:00
Jeff Becker
7e4d74cbfc
add initial jni stuff for lokinet android. i fucking hate android so god damn much. 2018-11-26 17:46:22 -05:00
Jeff Becker
b323665140
update android jni 2018-11-26 09:31:52 -05:00
Jeff Becker
f1cca956f9
make android compile again 2018-11-06 09:06:09 -05:00
Jeff Becker
ff07fb1184 ensure config 2018-08-06 14:43:23 +10:00
Jeff Becker
fe489b0280 god damnit 2018-08-06 14:24:25 +10:00
Jeff Becker
145d32a051 another attempt 2018-08-06 14:23:08 +10:00
Jeff Becker
c3092bf474 jni fixes 2018-08-06 14:20:00 +10:00
Jeff Becker
3a4ca9badf snytax error 2018-08-06 11:54:24 +10:00
Jeff Becker
a2e339a8ce make it compile 2018-08-06 11:52:46 +10:00
Jeff Becker
464d373f74 update native call 2018-08-06 11:48:15 +10:00
Jeff Becker
f93f40693e fix function name 2018-08-06 10:14:39 +10:00
Jeff Becker
458fd9a388 typo fix 2018-08-06 10:13:08 +10:00
Jeff Becker
b16a76afbe more android 2018-08-06 10:12:19 +10:00
Jeff Becker
d186fea9f5 fix build 2018-08-06 10:07:32 +10:00
Jeff Becker
863ef1f71e more android code 2018-08-06 10:06:00 +10:00
Jeff Becker
b8fb220b3b add jni files 2018-08-06 09:49:23 +10:00