Commit Graph

4337 Commits

Author SHA1 Message Date
Jeff Becker
e1f90e5e5a
use rx id on snode side of paths
set protocol on reply routing messages
2021-04-19 07:02:44 -04:00
Jeff Becker
e058b873b6
Revert "tweak timeout parameters for link layer."
This reverts commit eef192b37aec070d624e84cedfc94f522fd0a346.
2021-04-19 07:02:44 -04:00
Jeff Becker
1677ed40f6
dont persist sessions if we failed to build 2021-04-19 07:02:44 -04:00
Jeff Becker
657c39a91c
tweak timeout parameters for link layer.
have different timeouts for service node vs client
2021-04-19 07:02:44 -04:00
Jeff Becker
6b2c311800
cover special case for 1 hop path builders 2021-04-19 07:02:44 -04:00
Jeff Becker
2e8f47a7fa
various cleanups 2021-04-19 07:02:44 -04:00
Jeff Becker
b36f87a4d2
stop crashing when we send dns reply for snode on service nodes 2021-04-19 07:02:44 -04:00
Jeff Becker
b01e20b4cb
add forgotten file again 2021-04-19 07:02:44 -04:00
Jeff Becker
2fa24b5eae
add untracked file 2021-04-19 07:02:44 -04:00
Jeff Becker
5eda4addc2
correctly discard invalid data on transfer traffic message 2021-04-19 07:02:43 -04:00
Jeff Becker
25e338d621
srv records
* add srv records in RCs if we have any
* add mechanism to add SRV records for plainquic exposed ports
* resign and republish rc or introset on srv record changes
2021-04-19 07:02:43 -04:00
Jeff Becker
a2285730b8
reduce log level 2021-04-19 07:00:27 -04:00
Jeff Becker
de1b0c9d14
add forgotten header 2021-04-19 07:00:27 -04:00
Jeff Becker
94ecf02a62
add option to run lokinet traffic only with no exit and drop all non lokinet traffic
triggered by: exit-node=null
2021-04-19 07:00:27 -04:00
Jeff Becker
2ed0ab1ca1
liblokinet and lnproxy updates
* add lokinet_status function to get the current status of the context, aka are we ready to send or not.
* catch some exceptions in lnproxy
2021-04-19 07:00:27 -04:00
Jeff Becker
e005b34169
fix up some retarded bullshit
* llarp::service::NameIsValid was not checking that the tld was .loki, add this check.
* make link layer initial connection timeout 5s not the session activity timeout which happens to be 60 god damn seconds.
2021-04-19 07:00:26 -04:00
Jeff Becker
0046de3e7a
service node logic change: simplify transit hop behavior to send protocol frames directly from a path transfer message 2021-04-19 06:59:07 -04:00
Jeff Becker
3f9e51e391
more liblokinet api functions
* get/set netid
* set log level
2021-04-19 06:59:07 -04:00
Jeff Becker
cf7603f20e
temp commit, closeReset -> close 2021-04-19 06:59:07 -04:00
Jeff Becker
48ce77ed1f
XXX: single threaded mode 2021-04-19 06:59:07 -04:00
Jeff Becker
bac9341ae0
fix: if we have not used a session yet we only check the intro for expiration 2021-04-19 06:59:07 -04:00
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
2021-04-19 06:59:07 -04:00
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
2021-04-19 06:59:07 -04:00
Jason Rhinelander
354f0f63e5
Reduce max number of per-connection active streams to 32
This is the max number of simultaneous open connections to the same port
on the remote.  100 was fairly arbitrary and seems a bit high.
2021-04-19 06:59:07 -04:00
Jason Rhinelander
5e912600f8
Fix connection close handling
Replace stream_reset (which typically isn't called) with a stream_close
handler (which is already called whether or not it was a reset).  Most
importantly, the server side needs to extend the max bidi streams
counter during stream_close (otherwise we run out when we hit the
limit and new connections just stall).
2021-04-19 06:59:07 -04:00
Jeff Becker
8bc60a59ac
fix up liblokinet api to be more friendly to ffi
add lnproxy exmaple of use of liblokinet
2021-04-19 06:59:06 -04:00
Jeff Becker
853cc52efb
wire up liblokinet 2021-04-19 06:59:06 -04:00
Jason Rhinelander
2a809c7a30
Add trace debugging of inbound packet type 2021-04-19 06:59:06 -04:00
Jason Rhinelander
35ead9dc6b
Remove superfluous block (FIXME: squash this with earlier "FIXME") 2021-04-19 06:59:06 -04:00
Jason Rhinelander
a2045cd966
Fix debug message 2021-04-19 06:59:06 -04:00
Jason Rhinelander
80d3738531
Increase null_iv to 8 bytes to avoid ngtcp2 stack corruption 2021-04-19 06:59:06 -04:00
Jeff Becker
309a899c9f
mark loopback convotags as forever
make null handler mark discard data as activity for convotag
2021-04-19 06:59:06 -04:00
Jeff Becker
f310778f81
dont regenerate convotag on loopback when we have one already 2021-04-19 06:59:06 -04:00
Jeff Becker
abf8d2fb17
fix loopback convotag 2021-04-19 06:59:06 -04:00
Jeff Becker
5b05d22bad
refactors
* add path sequence numbers on routing messages
* reduce log level in debug mode
* wire up loopback style sending to ourself
2021-04-19 06:59:06 -04:00
Jeff Becker
f86a2daf83
fixes
* Add service::Endpoint::HasOutboundConvo
* dont mark outbound convos as inbound
* order quic packets
2021-04-19 06:59:06 -04:00
Jeff Becker
59c9e997f2
build paths faster and limit path builds at edge router instead of via a time counter for all edges 2021-04-19 06:59:05 -04:00
Jason Rhinelander
ff2e79ce38
Remove superfluous log statement
The send_packet() we call here already prints the buffer.
2021-04-19 06:59:05 -04:00
Jason Rhinelander
312222e881
Properly handle ngtcp2 returning UINT64_MAX 2021-04-19 06:59:05 -04:00
Jason Rhinelander
2ea84a61f9
Replace timer->again() with stop/start()
repeat()/again() sets a repeating timer, which we don't want; stop and
start it instead so that it fires just once.
2021-04-19 06:59:05 -04:00
Jason Rhinelander
68e96a4e5d
Remove obsolete fixme
Remote addr and ecn are handled.
2021-04-19 06:59:05 -04:00
Jason Rhinelander
7982581cfd
Revisit/reduce quic logging
Demote many things to Trace.
2021-04-19 06:59:05 -04:00
Jason Rhinelander
3c630b260a
Don't install stream forwarding here
Stream forward on the client-side TCP connection gets set up within in
initial_client_data_handler (which also handles reading the initial
stream version byte).
2021-04-19 06:59:05 -04:00
Jason Rhinelander
f534103971
Simplify/fix expiry timer logic
Also fix a potential transmission delay because `again()` wasn't being
called when the expiry is already passed (i.e. meaning we should run
immediately).
2021-04-19 06:59:05 -04:00
Jason Rhinelander
ac34835c12
Fix/refactor stream closing
Make stream closing with expiring connections work better.  Fixes an
issue where the stream's uv_async could outlive the stream and/or
connection and segfault.
2021-04-19 06:59:05 -04:00
Jason Rhinelander
60c813d306
Schedule retransmit after blocked send
In the standalone plainquic code we triggered a retransmit when the
socket became writeable again, but that doesn't work here, so just
schedule it right away to let ngtcp2 worry about retrying.
2021-04-19 06:59:05 -04:00
Jason Rhinelander
71beae5923
Stop retransmit timer when destroying a connection
Otherwise we segfault because it outlives the Connection.
2021-04-19 06:59:05 -04:00
Jason Rhinelander
027243cbcc
Remove obsolete fixme 2021-04-19 06:59:04 -04:00
Jason Rhinelander
233cb86191
Sever tunnel links earlier
When we get an error on the tcp connection immediately sever the link to
the quic tunnel so that it doesn't keep trying to forward data to it.
2021-04-19 06:59:04 -04:00
Jeff Becker
73572b317b
stuff 2021-04-19 06:59:04 -04:00
Jason Rhinelander
4cea33a139
Fix Server's missing opt-out of ring buffer
For now we still steal buffers from uvw.

In the future I'd like to change that, but it's still uvw
work-in-progress to support custom data allocators, and so for now we
still steal data buffers from uvw.
2021-04-19 06:59:04 -04:00
Jason Rhinelander
99954f7501
Add some more useful debug logging 2021-04-19 06:59:04 -04:00
Jason Rhinelander
b8be889291
Add missing client TCP accept/forwarding handlers
Somehow the TCP client connection accept and stream forwarding got
dropped in the quic refactor.
2021-04-19 06:59:04 -04:00
Jason Rhinelander
738f16366b
Try outbound convos if no inbound convos work (FIXME)
FIXME - eliminate this block of code that used to be an `else` before
PR'ing.
2021-04-19 06:59:04 -04:00
Jason Rhinelander
183abd58aa
Add more checks and logging
Most of the logging here is Trace level so needs a Debug build to not
get compiled away.
2021-04-19 06:59:04 -04:00
Jason Rhinelander
44fc941c32
Set port properly in server-to-client reply packets
ngtcp2 was rejecting them because we have the port when constructing,
but then it was 0 on the return packet (which ngtcp2 drops because it's
coming from an unknown/invalid path).
2021-04-19 06:59:04 -04:00
Jeff Becker
6bb23aa956
patch 2021-04-19 06:58:38 -04:00
Jeff Becker
3977c12da6
dont try to build untracked file 2021-04-19 06:58:38 -04:00
Jeff Becker
708e408c30
various fixups and cleanups
* wire up last of the quic stuff
* clean up udp packet generation code
* pass EndpointBase not quic tunnel for quic stuff
* add {n,h}uint16_t::FromString
* add nuint_t::FromString
* make AlignedBuffer::IsZero non constant time call for speed
2021-04-19 06:58:37 -04:00
Jeff Becker
100a953a23
make the lokinet endpoint code work
still needs the quic sides to work
2021-04-19 06:58:37 -04:00
Jeff Becker
7098f46d60
rpc endpoint for triggering quic tunnel 2021-04-19 06:58:37 -04:00
Jeff Becker
838b968d8f
re add static build for all internal lokinet libs 2021-04-19 06:58:37 -04:00
Jeff Becker
c88406fb27
move lokinet-quic into the big giant amalgum of liblokinet 2021-04-19 06:58:37 -04:00
Jeff Becker
4dafe973c2
comment out member 2021-04-19 06:58:37 -04:00
Jeff Becker
883005d7db
variable is unused for now but i dont want to remove it yet 2021-04-19 06:58:37 -04:00
Jeff Becker
2360700911
add virtual default destructor to appease clang 2021-04-19 06:58:37 -04:00
Jeff Becker
8b95f9945a
fix compiler errors 2021-04-19 06:58:37 -04:00
Jeff Becker
f5700c560e
try inbound paths first 2021-04-19 06:58:37 -04:00
Jeff Becker
59891d5d5f
wire up snode traffic to quic 2021-04-19 06:58:36 -04:00
Jeff Becker
58bec09232
fix compile error 2021-04-19 06:58:36 -04:00
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.
2021-04-19 06:58:36 -04:00
Jason Rhinelander
158ea4a951
Add isIPv4/isIPv6 to SockAddr 2021-04-19 06:58:36 -04:00
Jason Rhinelander
2ca7ef7f5f
Rename isRouter -> isSNode
The isRouter wording was quite confusing, especially in a call such as:

    router->Configure(config, opts.isRouter, nodedb)
2021-04-19 06:58:36 -04:00
Jason Rhinelander
d588f777c7
Fix logging of std::byte values
They were failing to compile if output because implicit integer
promotion doesn't work for std::byte's (but rather needs an explicit
std::to_integer call).
2021-04-19 06:58:36 -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
Jason Rhinelander
104f63543f
Change MaybeGetLoop to a virtual member func
Minor simplification.
2021-04-19 06:58:36 -04:00
Jeff Becker
a1a1b2e2bc
remove superflous include 2021-04-19 06:58:36 -04:00
Jeff Becker
a61f846d33
* add convotags to ensure path to snode
* add service::Endpoint::EnsurePathTo which gives you a std::optional<Convotag>
2021-04-19 06:58:35 -04:00
Jeff Becker
fe32475cad
use more variants 2021-04-19 06:58:35 -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
e4ca7ce4de
get rid of uneeded type 2021-04-19 06:58:35 -04:00
Jeff Becker
618881e65c
update ngtcp2 address/path structs 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
Jeff Becker
1885b1cae9
more 2021-04-19 06:58:05 -04:00
Jeff Becker
4446f2fc16
fix and format.
* start moving quic code to use lokinet internals
2021-04-19 06:57:46 -04:00
Jason Rhinelander
39d31df059
no-op LogTrace(); print chars as ints
- LogTrace() (and LogTraceTag, etc.) are now no-ops for release builds.
(hoping there are no side effects in trace logging!)
- renamed llarp::_Log to llarp::_log because _Log is a reserved keyword
- change logging code to implicitly convert 1-byte types (char, unsigned
char, uint8_t) to ints so that we print them as numeric values rather
than raw chars because, more often than not, printing a single char is
trying to log an 8-bit value.
2021-04-19 06:57:46 -04:00
Jason Rhinelander
b61bd82b4b
Add llarp::buffer_printer for pretty buffer logs 2021-04-19 06:57:46 -04:00
Jason Rhinelander
818b4042e9
Migrate plainquic logging to llarp logging 2021-04-19 06:57:46 -04:00
Jason Rhinelander
5d897781ef
Replace custom random with llarp/sodium random 2021-04-19 06:57:45 -04:00
Jason Rhinelander
aa0f54fa07
WIP plainquic tunnels 2021-04-19 06:57:45 -04:00
Jason Rhinelander
46c619c49f
Move external/ cmake bits into external/CMakeLists.txt
- Move uvw target to external instead of llarp/CMakeLists.txt

- Add sqlite_orm headers via interface library rather than shoving it
  into the global include search path.

- Find sqlite3 as part of the sqlite_orm target deps rather than linking
  it separately.  (Also don't link it into lokinet-util, which doesn't
  appear to actually need it).
2021-04-19 06:57:45 -04:00
Jeff Becker
b45a268dbc
fix windows dll link-ism 2021-04-19 06:52:24 -04:00
Jeff Becker
2fa7a54e86
fix pybind layer compile errors from missing llarp.h header 2021-04-19 06:52:24 -04:00
Jeff Becker
e4841917ba
redo cmake parts
* add liblokinet.so target
* make every library we build except liblokinet.so static
* wire up parts of liblokinet
2021-04-19 06:52:24 -04:00
Jeff Becker
a6715a1f75
remove old vpnio bits 2021-04-19 06:52:23 -04:00
Jeff Becker
c92894804c
Merge remote-tracking branch 'origin/stable' into dev 2021-04-17 09:18:37 -04:00
Jeff Becker
a0d3ab125a
throw on failed writing and port fs namespace changes from oxen-core 2021-04-16 14:47:17 -04:00
Jeff Becker
e8178a032e
lokinet-bootstrap native binary 2021-04-15 20:06:15 -04:00
Jeff Becker
0c37cc7f60
lokinet-bootstrap native binary 2021-04-15 13:39:45 -04:00
Jeff Becker
7a1ffc2df4
* lessen replay filter window
* dont have transit hops use a replay filter
* formatting
2021-04-12 13:14:59 -04:00