Commit Graph

104 Commits

Author SHA1 Message Date
Jeff
5b5bd6b44e
dns features (#1404)
* add some dns txt records for stuff we want to expose

* fix txt records

* txt records for snode info

* dont send cname as it mangles the response

* check for 3 parts not 3 characters
2020-10-12 12:18:46 -04:00
Jeff
3b70b99dd2
fix empty config case (#1400)
* fix empty config case

* * fix case for empty ifname / ifaddr on relay
* bail if no dns server bound

* use AssignmentAcceptor
2020-10-09 11:39:39 -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
Jason Rhinelander
4faaf9082c Fix broken unbound resolver when including upstream port
unbound breaks when given "1.2.3.4:53" as it expects only an IP.
2020-10-02 20:19:53 -03:00
Jeff
21930cf667
LNS (#1342)
* initial relay side lns

* fix typo

* add reserved names and refactor test for dns

* lns name decryption

* all wired up (allegedly)

* refact to use service::EncryptedName for LNS responses to include nonce with ciphertext

* fully rwemove tag_lookup_job

* replace lns cache with DecayingHashTable

* check for lns name validity against the following rules:

* not localhost.loki, loki.loki, or snode.loki

* if it contains no dash then max 32 characters long, not including the .loki tld (and also assuming a leading subdomain has been stripped)

* These are from general DNS requirements, and also enforced in
registrations:

* Must be all [A-Za-z0-9-]. (A-Z will be lower-cased by the RPC call).

* cannot start or end with a -

* max 63 characters long if it does contain a dash

* cannot contain -- in the third and fourth characters unless it starts with xn--

* handle timeout in name lookup job by calling the right handler with std::nullopt
2020-09-17 15:18:08 -04:00
Thomas Winget
2c6e7b86c3
SRV records fixes (#1332)
* fix a log print log level

* correctly match SRV record service and protocol...

* tests for new dns question functions
2020-08-31 19:25:58 -04:00
Thomas Winget
b1c14af938
SRV Record handling for introsets (#1331)
* update loki-mq submodule for tuple support

* srv record reply implementation

still need to encode srv records into intro sets / router contacts
as well as decode from them and match against queried service.proto

* inverted condition fix in config code

* SRV record struct (de-)serialization for intro sets

* parsing and using srv records from config (for/in introsets)

* adopt str utils from core and use for srv parsing

* changes to repeat requests

no longer drop repeat requests on the floor, but do not make
an *actual* request for them if one is in progress.

do not call reply hook for each reply for a request, as
each userland request is actually made into several lokinet
requests and this would result in duplicate replies.

* fetch SRVs from introsets for .loki

* make format

* dns and srv fixes, srv appears to be working
2020-08-31 16:07:17 -04:00
Jeff Becker
4bb214eba0
attempt fix for libunbound on win32
* run unbound stuff in another thread because LOL windows
* because unbound runs in another thread callbacks for libunbound need to be wrapped in a deferred call so they are done in the logic thread
* bump sqlite3 dep because it's gone, repin hash.
2020-08-04 10:53:32 -04:00
Thomas Winget
8f0330c9f2 std::vector instead of std::array 2020-06-15 18:32:57 -04:00
Thomas Winget
b875d40491 restructure how upstream dns replies are handled
llarp::dns::Message does not fully support DNS packets,
so converting the upstream response to one will not work
for all query types.  Also it is kinda silly to begin with,
as the upstream reply is already a network packet, ready to go.
2020-06-15 18:32:57 -04:00
Thomas Winget
221e9ff5de make format 2020-06-15 18:32:57 -04:00
Thomas Winget
c2a30692cf Implement upstream DNS using libunbound 2020-06-15 18:32:57 -04:00
Jason Rhinelander
bdc9c7bfa8 Move IPRange out of net.hpp; free up TruncateV6 etc.
- Move IPRange into its own net/ip_range.hpp

- Move the static net::IPPacket::TruncateV6, etc. functions to free
net::TruncateV6, etc. functions (now from net/ip.hpp instead of
net/ip_packet.hpp).

- Make net::TruncateV6 and net::ExpandV4 constexpr.

- Add IPRange::FromIPv4 factory function (to replace the iprange_ipv4
free function)
2020-05-20 19:18:27 -03:00
Stephen Shelton
aee96e53a3
Refactor Addr -> IpAddress/SockAddr 2020-05-06 14:38:44 -06:00
Jason Rhinelander
1697bf90fe C++17
Compiles with C++17, replaces ghc::filesystem with std::filesystem,
nonstd::optional with std::optional, and llarp::string_view with
std::string_view.
2020-05-01 17:43:27 -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
a6a3d77bb4
Merge pull request #1174 from notlesh/reduce-rr-decode-fail-verbosity-2020-03-09
Reduce log verbosity when DNS RR decode fails
2020-03-09 17:47:57 -04:00
Jeff Becker
51516f751b return NS record for localhost.loki to squash errors in host lookups 2020-03-09 17:48:13 -03:00
Jeff
f3d23d6fb6
strip rr from dns reply for .snode and .loki (#1172)
fix dns replies so that extra RR for edns are not included.
2020-03-09 17:47:27 -03:00
Stephen Shelton
f40ce505a8
Reduce log verbosity when DNS RR decode fails 2020-03-09 14:20:27 -06:00
Jeff Becker
9c30ff7a26
handle snode and clean up codepath for hooked dns 2020-02-25 17:43:08 -05:00
Jeff Becker
1d5c712adb
monkey patch upstream dns to rewrite .loki cname answers 2020-02-25 17:43:08 -05:00
Jason Rhinelander
f84ce61d66 Removed empty cpp files
These aren't needed: CMake already knows how to follow #includes and
rebuild when headers change as long as the headers are included
*somewhere*.  The extra .cpp files here just require building a bunch of
.cpp files with just header content that we just end up throw away
during linking (since the same things will also be compiled in whatever
other compilation units include the same headers).
2020-02-21 23:39:11 -04:00
Jeff Becker
fcf0ae2b9e
prune unused files. 2019-12-15 07:02:17 -05:00
Jeff Becker
56dce90de9
add trace log level for tracking logic thread jobs 2019-11-22 16:23:19 -05:00
Jeff
9ace1b2398
Merge pull request #870 from majestrate/disable-doh-using-isp-backdoor-provided-by-mozilla-thanks-from-nsa
disable DoH
2019-11-01 10:54:00 -04:00
Jeff Becker
d2be8ac384
fix issue #894 2019-11-01 09:40:31 -04:00
Jeff Becker
bd07845dd3
make format 2019-10-28 10:44:56 -04:00
jeff
37d7f2b1e7 disable DoH using mozilla's ISP backdoor record. 2019-10-21 09:32:24 -04:00
Michael
edd0ec398f
Move thread stuff to subdirectory 2019-09-03 20:52:28 +01:00
Michael
1aec0dfa2b
Move logging to subdirectory 2019-09-03 20:52:27 +01:00
Michael
16cdfbd5f0
clang-tidy modernize pass 2019-08-12 16:52:58 +01:00
Jeff Becker
1fd6b5ae74
Merge remote-tracking branch 'origin/master' into ipv6-tun 2019-07-12 09:53:52 -04:00
Michael
488695047f
Remove redundant else blocks 2019-07-09 22:54:46 +01:00
Jeff Becker
c60099002b
reverse dns for ipv6 2019-06-12 09:48:14 -04:00
Jeff Becker
2403ab8f86
ipv6 2019-06-11 12:44:05 -04:00
Jeff Becker
b679dd7341
fixit 2019-05-22 13:38:02 -04:00
Jeff Becker
c355d37beb
use limited size queue for logic and singled threaded threadpool 2019-05-22 13:18:19 -04:00
Jeff Becker
64c7ed42fc
make format 2019-05-22 12:20:50 -04:00
Jeff Becker
9c96aecf3f
move llarp::Logic to std::shared_ptr
add sequence numbers to HSD messages

begin work on network isolation code

add more docs
2019-05-22 12:20:03 -04:00
Jeff Becker
92ad98be8b
refactor hooks to be have more c++isms
make path build timeouts use log level warning
2019-05-05 09:51:48 -04:00
Jeff Becker
241dba0476
fix dns for smaller domains 2019-05-03 14:56:31 -04:00
Jeff Becker
e060082441
hook every dns for .loki and .snode when applicable
make {n,h}uint{32,16}_t templated type.
2019-05-01 09:40:10 -04:00
Jeff
01906c5d94 Merge remote-tracking branch 'origin/master' 2019-04-28 13:33:27 -04:00
Jeff Becker
fea64eaf12
handle subdomains 2019-04-26 08:14:29 -04:00
Jeff Becker
d20ba9ceab
handle subdomains 2019-04-26 08:11:34 -04:00
Michael
9ee525a006
Fix shadowing warnings 2019-04-26 00:21:19 +01:00
Jeff Becker
0529e45ebe
more 2019-04-25 13:15:56 -04:00
Jeff Becker
af1529fa72
Merge remote-tracking branch 'origin/master' 2019-04-25 07:25:22 -04:00
Michael
4143472a17
Add cmake module to target a library as 'system', and fix a few warnings 2019-04-25 00:27:31 +01:00