Commit Graph
183 Commits
Author SHA1 Message Date
Floris Bruynooghe eb18a89fa6 fix: Output writing (#804)
This simply delegates to eprintln! for writing output.  This ensures
writes happen more synchronously and the flaky integration tests are
fixed.

While in theory these are blocking operations on the async executor,
this is acceptable because:

- We already use println!() without any problems.  Arguably this is
  more of an issue since we also write data to stdout but it isn't
  because we don't do that at the same time.

- We print a small number of messages, not large amounts of data.  Any
  blocking from this will be small.

- This acquires a sync mutex while writing, that's fine because it is
  acquired and released in the same chunk of async code and not held
  across await points.  This is unlikely to block much as only main
  writes and only one write happens at a time.

- When logging via tracing is enabled this will also end up logging on
  here and will compete for the lock.  This is slightly higher
  contention but doesn't really interfere with the logging here.
2023-02-28 18:34:54 +01:00
Floris Bruynooghe e80051e43d ref: Remove duplicate read_lp implementation (#801)
Seems like we ended up with two bits of code doing exactly the same.
Clean it up.

This settles on read_lp() as name since this is symmetric with
write_lp() which writes bytes.  This implementation inlines the
functions a bit more as well, the entire function is still small and
it is used often.
2023-02-28 18:10:34 +01:00
Rüdiger Klaehn 7cf2a3a621 No out writer (#797)
* refactor: replace out_writer with a out_println! macro

* refactor: rename out_println! to progress!

It does not really write to stdout but to stderr, so out...anything is a
bit misleading.
2023-02-27 14:25:21 +02:00
Asmir Avdicevic 1a68106d07 feat(ci): push data to metro (#794) 2023-02-26 15:33:41 -05:00
Kasey 61ba002855 test: cli integration test for provide-get loop (#781)
Tests the provide-get loop, transferring a single file, a folder of multiple files, and data from stdin of the provider to stdout if the better, ensuring that the content is transferred successfully.

The tests also test the stdout of the provider and stderr of the getter, using regex matching on each line of the respective output.
2023-02-24 11:35:05 -05:00
Ar Nazeh a12de97431 docs: fix typo (#792)
I assume it is a typo.
2023-02-24 11:00:33 +01:00
Asmir Avdicevic 7fb888d699 fix(ci): format output as table (#791) 2023-02-24 10:06:30 +01:00
Floris Bruynooghe 33c0482874 fix: Improve listening addr output (#789)
This fixes the log message output which had an extraneous newline in
it and needlessly used debug output.

It also adds the listening address to the normal provider output: This
is universally useful since you can specify addresses with -a but
don't otherwise know which one is used if using OS-allocated ports.
This can also be useful for testing.
2023-02-24 09:52:44 +01:00
Floris Bruynooghe a0b7c26e5a feat: Show more numbers in human readable form (#790)
This shows sizes in KiB, MiB etc.  Also adds a few totals and transfer
summaries.
2023-02-23 19:46:24 +01:00
Floris Bruynooghe 907644345f fix: Avoid other output between contents when printing (#786)
This makes sure the OutWriter writes the newline as part of the same
buffer as the output.  This makes it less likely that the output will
be interrupted between the content and the newline.  E.g. without this
and enabling logging, log messages will be injected between the
content and the newline, making the output garbled.

Unfortunately this isn't entirely correct and is more of a heuristic
because most of our output is small enough that they fit in a single
write.  In the blocking world you'd lock Stderr while printing the
messages, in the tokio world however I don't know how to safely do
this.
2023-02-23 19:45:11 +01:00
Asmir Avdicevic 6a5c13e31c fix(ci): move from sendme to iroh (#788) 2023-02-23 09:42:33 +01:00
Floris Bruynooghe d9aed3ca78 ref: Rename --token to --auth-token for get (#785)
This is consistent with the naming for the provide subcommand and is
more descriptive as well.
2023-02-22 18:51:58 +01:00
dignifiedquire 7923829538 chore: Release iroh version 0.3.0 v0.3.0 2023-02-22 15:27:10 +01:00
dignifiedquire c8855f8cba chore: add changelog for 0.3.0 2023-02-22 15:24:34 +01:00
Friedel Ziegelmayer 70f991230d docs: updates for release 2023-02-22 15:19:35 +01:00
Floris Bruynooghe fd37cab02c feat: Remove Request.id from the protocol (#782)
Since we now only issue a single request per stream this field was not
used.  Using it in the provider to identify requests would introduce
complexity and overhead for the bookkeeping of request IDs.  Instead
remove the field from the protocol.

The provider still has a use-case for identifying which request events
relate to.  It now uses the QUIC stream ID for this, but does not
promise so on an API-level.  This also simplifies the events since
this new request_id is always known, while previously it was only
known after having decoded the request message.
2023-02-22 10:58:22 +01:00
Floris Bruynooghe 42a6235690 feat: Remove MAX_DATA_LIMIT (#780)
We used to limit the maximum amount of data that can be transferred,
both the total size as well as single blob size.  There is no real
benefit to this, we pass through the reader and do not buffer all this
data at once.  And avoiding to fill up the user's disk space is not
our concern.
2023-02-22 09:47:32 +01:00
Floris Bruynooghe c28a3783c5 feat: Make get work on IPv6 network (#777)
Maybe the way deciding it's not available is not great, but it's
probably good enough.

I also wish rust had a "skipped" test outcome.
2023-02-21 19:42:01 +01:00
Floris Bruynooghe 7fbeb4fef4 ref: Improve safety of BytesMut buffer usage (#778)
The implementation uses a BytesMut buffer to efficiently read protocol
messages from the network connections.  The way read_lp was combining
both reading the length-prefixed message and decoding it resulted in
the caller having to remember to advance the BytesMut buffer before
using it again.  That is error prone.

This reduces the function of the read_lp() function to only read the
raw message from the network.  It returns a new Bytes object and the
passed in BytesMut is in a safe state with all internal indexes
correctly advanced.

The caller is now responsible for calling postcard::from_bytes using
the returned Bytes, read_lp() can not both create the Bytes and return
a parsed struct from it due to lifetimes.  Overall this isn't any more
complicated to use and results in less error-prone code.
2023-02-21 19:41:29 +01:00
Floris Bruynooghe feeefa9ded feat: Move --keylog to common flags (#776)
All subcommands take this option, so repeating it like that is a bit
silly.  Move it to the toplevel.
2023-02-21 16:38:03 +01:00
Friedel Ziegelmayer e3012f0cb4 feat: rename to iroh 2023-02-20 16:53:58 +01:00
Asmir Avdicevic 3a3fc46ba9 feat: netsim CI (#135) 2023-02-20 15:06:39 +01:00
Floris Bruynooghe 2991cbb6bb feat: Use our own ALPN (#155) 2023-02-20 12:17:13 +01:00
Floris Bruynooghe d64d12db44 feat: Add option to use SSLKEYLOGFILE env var (#153)
This adds support for the SSLKEYLOGFILE environment variable which is
a common standard used by browsers to log the TLS keys used for
connections.  It allows traffic inspectors like tcpdump and wireshark
to use the logged keys and decrypt the traffic.  Using this is a first
step to allowing us to observe our protocol on the wire.

The support is still hidden behind a commandline option so that it can
not be accidentally enabled by only having an environment variable
set.
2023-02-20 10:47:30 +01:00
Kasey 19e2b058c5 fix: ensure we emit TransferAborted event if anything goes wrong during the transfer (#150)
This refactor splits the `handle_stream` function up into smaller
(logical) functions. If these functions error, we can emit a
`TransferAborted` event before returning the error.

This has the added benefit of making the `handle_stream` function a bit
easier to take in. None of these new functions have any code changes,
the only difference is how errors are handled and when we return.
2023-02-17 13:53:39 -05:00
Friedel ZiegelmayerandFloris Bruynooghe 153073a937 start debugging earyl close (#148)
When finished with a stream you have to read to EOF. Sometimes the
sender could be sending the FIN bit in an empty STREAM frame after all
the data is sent, if the receiver did not read EOF in this case the
receiver will still implicitly call `RecvStream::stop` on drop, making
the stream error for the sender.

Co-authored-by: Floris Bruynooghe <flub@devork.be>
2023-02-16 13:52:08 +01:00
Floris Bruynooghe 2edb528007 fix: MSRV in CI (#145)
There's even a comment.  But I seem to have ignored that.
2023-02-15 16:00:40 +01:00
Rüdiger Klaehn 21a5cfd47e Merge pull request #138 from n0-computer/multi-threaded-add
refactor: use multi threading when computing outboards
2023-02-15 15:19:39 +02:00
Floris Bruynooghe c0fafdbcba Fix QUIC stream completion (#143)
Sending a STOP_STREAM frame from the receiver is the way for a receiver
to go to the reset state. It involves sending an extra frame, the
receiver will then send its own RESET_STREAM frame and the stream is
considered ended in an error state.

Instead the right way to end a stream is to set the FIN bit on the final
STREAM frame, ideally not even resulting in an extra frame or packet
sent. This is done on the sender side.
2023-02-15 14:04:51 +01:00
Rüdiger Klaehn 1c6c75fd38 Merge pull request #144 from n0-computer/integrated-bao
ref: use our own bao crate abao
2023-02-15 12:03:47 +02:00
Ruediger Klaehn 659d2d2225 ref: use our own bao crate
Requires just a tiny code change since bao takes a reference of a hash
instead of the value.
2023-02-15 10:44:31 +02:00
Floris Bruynooghe f3086a9576 ref: Allow older rust version (#142)
This matches the rust-version from deltachat and everything still
seems to work.  Not sure why we have the more recent version.
2023-02-14 15:48:43 +01:00
Floris Bruynooghe d09a78636b feat: Add generic progress emitter utility (#141)
This adds a generic utility which can be used to track progress of
data transfers by emitting progress via a tokio broadcast channel.

This is extracted from the deltachat PR:
https://github.com/deltachat/deltachat-core-rust/pull/4007
2023-02-14 13:17:21 +01:00
Kasey c266ab5d9d fix: fail if an on_blob function does not read all the content (#139)
closes #127
2023-02-13 13:32:36 -05:00
Asmir Avdicevic fc8fbeb65c fix(ci): run clippy directly (#140) 2023-02-13 19:30:36 +01:00
Floris Bruynooghe 5bd545d8eb feat: Do not error when the provider closes the connection (#124)
This makes it so that the provider is allowed to close the connection
after a transfer is completed, without the getter resulting in an
error.

It modifies the provider to only emit the transfer completed once the
data has actually reached the client.
2023-02-13 16:34:49 +01:00
Floris Bruynooghe 8e42874a23 deps: Remove duplicate tokio dependency (#137)
The tokio feature of tracing-futures seems crazy outdated and not
needed.  Enabling it pulls in an ancient version of tokio for no
reason whatsoever.  Get rid of it.
2023-02-13 14:12:42 +01:00
Floris Bruynooghe eac7b65a67 ref: on_collection doesn't need to be FnMut (#136)
It is only called once, adding FnMut is a needless restriction.

Closes #133
2023-02-13 14:11:55 +01:00
Ruediger Klaehn a4a3d546d1 docs: add some comments 2023-02-13 14:48:34 +02:00
Ruediger Klaehn 34cf223098 refactor: use multi threading when computing outboards
I did not do this previously because something wasn't ready.
But now I think it is time.
2023-02-13 14:07:19 +02:00
Kasey b3ee39f92f fix: display CIDs in the CLI for the Collection (#131)
closes #130
2023-02-10 02:30:40 -05:00
Kasey 82e2f5649b fix: catch ctrl-c to allow a normal shutdown & clean up any tempfiles that are created (#122)
closes #102
2023-02-08 12:12:02 -05:00
Rüdiger Klaehn 145ec43eb1 Merge pull request #126 from n0-computer/collection-by-ref
refactor: make on_collection take a reference
2023-02-08 16:53:10 +02:00
Ruediger Klaehn 34aa8e1514 refactor: make on_collection take a reference
This way we avoid a clone
2023-02-08 16:31:25 +02:00
Rüdiger Klaehn 1a127fac65 Merge pull request #123 from n0-computer/cid
Add newtype wrapper for Hash that is compatible with Cid
2023-02-07 16:40:38 +02:00
Ruediger Klaehn 2e3d5777ea Merge branch 'main' into cid 2023-02-07 16:00:42 +02:00
Ruediger Klaehn f780d253c8 pr review: some renaming 2023-02-07 15:44:58 +02:00
Ruediger Klaehn 838fa5cb7e docs: add docs for the 4 prefix bytes 2023-02-07 15:17:01 +02:00
Ruediger Klaehn 7158bc047c refactor: move Blake3Cid to main for now 2023-02-07 14:58:40 +02:00
Floris Bruynooghe 13f703f0ef feat: Allow shutdown of Provider (#121)
This adds Provider::shutdown allowing to stop the Provider without
having to abort it.  On the wire however it still does not do anything
graceful: all the connections are stopped and any in-transit data is
lost.

Additionally this adds tracing spans to the connection handling.

Finally it fixes a bug where read_lp would not return None if the
connection was closed normally.

Part of #77 but this is not very graceful on the wire yet.
2023-02-07 12:56:35 +01:00