Commit Graph

6820 Commits

Author SHA1 Message Date
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
db2344505f
Update ngtcp2 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
Jason Rhinelander
a1a152b5c3
Disable building ngtcp2 example code 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
211a051444
add quic_tester.py script for hitting rpc endpoints to test quic 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
1d6ad7284c
Fix cursed formatting 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