Skip to content

Commit

Permalink
transfer: Soft-deprecrate old send and receive methods
Browse files Browse the repository at this point in the history
  • Loading branch information
felinira committed Jul 13, 2024
1 parent d23d6b4 commit c5c872a
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 45 deletions.
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- \[lib\]\[breaking\] refactor `magic_wormhole::transfer::` methods to take an `OfferSend` and `OfferReceive` instead of using separate methods for files and folders. Use `transfer::send()` and `transfer::receive()`.

## Version 0.7.0

- \[all\]\[breaking\] By default websocket TLS support is now disabled in the library crate. TLS is required for secure websocket connections to the mailbox server (`wss://`). As the handshake protocol itself is encrypted, this extra layer of encryption is superfluous. Most WASM targets however refuse to connect to non-TLS websockets. For maximum compatibility with all mailbox servers, or for web browser support, select a TLS implementation by specifying the feature flag `tls` for a statically linked implementation via the `ring` crate, or `native-tls` for dynamically linking with the system-native TLS implementation.
Expand All @@ -9,9 +13,9 @@
- \[lib\]\[breaking\] replaced `transfer::AppVersion` with a struct with private fields that implements `std::default::Default`
- \[lib\]\[breaking\] split `Wormhole` in `MailboxConnection` and `Wormhole`. `Wormhole` now uses accessor methods for the previously exposed fields.
- \[lib\]\[breaking\] `WormholeWelcome` now uses accessor methods for the previously exposed fields.
- \[lib\]\[breaking\] refactor `magic_wormhole::transfer::` methods to take an `OfferSend` and `OfferReceive` instead of using separate methods for files and folders. Use `transfer::send()` and `transfer::receive()`.
- \[lib\]\[breaking\] struct `transfer::ReceiveRequest` became an enum to prepare for transfer v2
- \[lib\]\[breaking\] removed `transit::log_transit_connection` and implemented `Display` on `TransitInfo` instead.
- \[lib\]\[breaking\] `ReceiveRequest.filename` is now of type `String`,

## Version 0.6.1

Expand Down
8 changes: 5 additions & 3 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ async fn send(
) -> eyre::Result<()> {
let pb = create_progress_bar(0);
let pb2 = pb.clone();
#[allow(deprecated)]
transfer::send(
wormhole,
relay_hints,
Expand Down Expand Up @@ -892,6 +893,7 @@ async fn send_many(
async_std::task::spawn(async move {
let pb2 = pb.clone();
let result = async move {
#[allow(deprecated)]
transfer::send(
wormhole,
relay_hints,
Expand Down Expand Up @@ -1016,8 +1018,8 @@ async fn receive_inner_v1(
return req
.accept(
&transit_handler,
&mut file,
create_progress_handler(pb),
&mut file,
ctrl_c(),
)
.await
Expand All @@ -1042,8 +1044,8 @@ async fn receive_inner_v1(
.await?;
req.accept(
&transit_handler,
&mut file,
create_progress_handler(pb),
&mut file,
ctrl_c(),
)
.await
Expand Down Expand Up @@ -1101,7 +1103,7 @@ async fn receive_inner_v2(

/* Accept the offer and receive it */
let answer = offer.accept_all(&tmp_dir);
req.accept(&transit_handler, answer, on_progress, ctrl_c())
req.accept(&transit_handler, on_progress, answer, ctrl_c())
.await
.context("Receive process failed")?;

Expand Down
13 changes: 10 additions & 3 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,12 @@ pub struct Wormhole {
phase: u64,
key: key::Key<key::WormholeKey>,
appid: AppID,
verifier: Box<secretbox::Key>,
our_version: Box<dyn std::any::Any + Send + Sync>,
peer_version: serde_json::Value,
#[deprecated(since = "0.7.0", note = "Use the verifier() method")]
pub verifier: Box<secretbox::Key>,
#[deprecated(since = "0.7.0", note = "Use the our_version() method")]
pub our_version: Box<dyn std::any::Any + Send + Sync>,
#[deprecated(since = "0.7.0", note = "Use the peer_version() method")]
pub peer_version: serde_json::Value,
}

impl Wormhole {
Expand Down Expand Up @@ -368,6 +371,7 @@ impl Wormhole {
log::info!("Found peer on the rendezvous server.");

/* We are now fully initialized! Up and running! :tada: */
#[allow(deprecated)]
Ok(Self {
server,
appid: config.id,
Expand Down Expand Up @@ -491,13 +495,15 @@ impl Wormhole {
* attack vector.
*/
pub fn verifier(&self) -> &secretbox::Key {
#[allow(deprecated)]
&self.verifier
}

/**
* Our "app version" information that we sent. See the [`peer_version`] for more information.
*/
pub fn our_version(&self) -> &(dyn std::any::Any + Send + Sync) {
#[allow(deprecated)]
&self.our_version
}

Expand All @@ -507,6 +513,7 @@ impl Wormhole {
* (e.g. by the file transfer API).
*/
pub fn peer_version(&self) -> &serde_json::Value {
#[allow(deprecated)]
&self.peer_version
}
}
Expand Down
15 changes: 9 additions & 6 deletions src/core/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub async fn test_file_rust2rust_deprecated() -> eyre::Result<()> {
let mut answer =
(answer.into_iter_files().next().unwrap().1.content)(false).await?;

let transfer::ReceiveRequest::V1(req) = transfer::request_new(
let transfer::ReceiveRequest::V1(req) = transfer::request(
wormhole,
default_relay_hints(),
magic_wormhole::transit::Abilities::ALL_ABILITIES,
Expand All @@ -257,8 +257,8 @@ pub async fn test_file_rust2rust_deprecated() -> eyre::Result<()> {
};
req.accept(
&log_transit_connection,
&mut answer,
|_received, _total| {},
&mut answer,
futures::future::pending(),
)
.await?;
Expand Down Expand Up @@ -293,6 +293,7 @@ pub async fn test_file_rust2rust() -> eyre::Result<()> {
code_tx.send(mailbox_connection.code.clone()).unwrap();
let wormhole = Wormhole::connect(mailbox_connection).await?;
eyre::Result::<_>::Ok(
#[allow(deprecated)]
transfer::send(
wormhole,
default_relay_hints(),
Expand Down Expand Up @@ -320,7 +321,7 @@ pub async fn test_file_rust2rust() -> eyre::Result<()> {
let mut answer =
(answer.into_iter_files().next().unwrap().1.content)(false).await?;

let transfer::ReceiveRequest::V1(req) = transfer::request_new(
let transfer::ReceiveRequest::V1(req) = transfer::request(
wormhole,
default_relay_hints(),
magic_wormhole::transit::Abilities::ALL_ABILITIES,
Expand All @@ -332,8 +333,8 @@ pub async fn test_file_rust2rust() -> eyre::Result<()> {
};
req.accept(
&log_transit_connection,
&mut answer,
|_received, _total| {},
&mut answer,
futures::future::pending(),
)
.await?;
Expand Down Expand Up @@ -377,6 +378,7 @@ pub async fn test_send_many() -> eyre::Result<()> {
let wormhole = Wormhole::connect(mailbox).await?;
senders.push(async_std::task::spawn(async move {
eyre::Result::Ok(
#[allow(deprecated)]
crate::transfer::send(
wormhole,
default_relay_hints(),
Expand Down Expand Up @@ -405,6 +407,7 @@ pub async fn test_send_many() -> eyre::Result<()> {
let gen_offer = gen_offer.clone();
senders.push(async_std::task::spawn(async move {
eyre::Result::Ok(
#[allow(deprecated)]
crate::transfer::send(
wormhole,
default_relay_hints(),
Expand Down Expand Up @@ -432,7 +435,7 @@ pub async fn test_send_many() -> eyre::Result<()> {
)
.await?;
log::info!("Got key: {}", &wormhole.key);
let transfer::ReceiveRequest::V1(req) = crate::transfer::request_new(
let transfer::ReceiveRequest::V1(req) = crate::transfer::request(
wormhole,
default_relay_hints(),
magic_wormhole::transit::Abilities::ALL_ABILITIES,
Expand All @@ -455,8 +458,8 @@ pub async fn test_send_many() -> eyre::Result<()> {

req.accept(
&log_transit_connection,
&mut answer,
|_, _| {},
&mut answer,
futures::future::pending(),
)
.await?;
Expand Down
Loading

0 comments on commit c5c872a

Please sign in to comment.