An open-source cross-platform alternative to AirDrop
feat: change to paired-v2.json
Tien Do Nam62d5ca968723
diff --git a/cli/src/app/receive.rs b/cli/src/app/receive.rsindex 6328f7c4..148dea71 100644--- a/cli/src/app/receive.rs+++ b/cli/src/app/receive.rs@@ -5,9 +5,9 @@ use super::App;use crate::ui::Category;use crate::util::{self, SpeedMeter};use localsend::http::client::v2::LsHttpClientV2;-use localsend::model::discovery::ProtocolType;use localsend::http::server::common::save::FileUploadTarget;use localsend::http::server::v2::{PrepareUploadDecisionV2, ServerEventV2, SessionEndReasonV2};+use localsend::model::discovery::ProtocolType;use localsend::model::transfer::FileDto;use std::collections::{HashMap, HashSet};use std::sync::Arc;diff --git a/cli/src/send_task.rs b/cli/src/send_task.rsindex 61982bea..4351401f 100644--- a/cli/src/send_task.rs+++ b/cli/src/send_task.rs@@ -7,8 +7,8 @@ use futures_util::StreamExt;use localsend::discovery::StatefulDevice;use localsend::http::client::ClientError;use localsend::http::client::v2::LsHttpClientV2;-use localsend::model::discovery::ProtocolType;use localsend::http::dto_v2::PrepareUploadRequestDtoV2;+use localsend::model::discovery::ProtocolType;use localsend::model::transfer::{FileContent, FileDto};use localsend::reqwest;use std::collections::HashMap;diff --git a/cli/src/storage/identity.rs b/cli/src/storage/identity.rsindex 6eeaba36..64d94ca1 100644--- a/cli/src/storage/identity.rs+++ b/cli/src/storage/identity.rs@@ -3,10 +3,10 @@use anyhow::Context;use localsend::crypto::cert::fingerprint_from_cert_der;use localsend::http::dto_v2::RegisterDtoV2;-use localsend::model::discovery::{PROTOCOL_VERSION_V2, ProtocolType};use localsend::http::server::TlsConfig;use localsend::http::state::ClientInfo;use localsend::model::discovery::DeviceType;+use localsend::model::discovery::{PROTOCOL_VERSION_V2, ProtocolType};use localsend::multicast::MulticastDevice;use std::path::Path;diff --git a/cli/src/storage/mod.rs b/cli/src/storage/mod.rsindex 28704614..16e0fd5f 100644--- a/cli/src/storage/mod.rs+++ b/cli/src/storage/mod.rs@@ -6,7 +6,7 @@//! is written on the first run.//! - `identity.pem` ([`identity`]): this device's certificate and private//! key.-//! - `paired.json` ([`paired`]): paired devices; machine-written.+//! - `paired-v2.json` ([`paired`]): paired devices; machine-written.mod config;mod identity;@@ -33,7 +33,7 @@ pub struct Repository {pub identity: Arc<Identity>,/// Devices whose transfer requests are auto-accepted; persisted across- /// runs as `paired.json`.+ /// runs as `paired-v2.json`.pub paired: PairedDevices,}diff --git a/cli/src/storage/paired.rs b/cli/src/storage/paired.rsindex 6cc80271..29093e6d 100644--- a/cli/src/storage/paired.rs+++ b/cli/src/storage/paired.rs@@ -1,17 +1,18 @@-//! `paired.json`: paired devices; machine-written.-use anyhow::Context;use serde::{Deserialize, Serialize};use std::collections::BTreeMap;use std::io::ErrorKind;use std::path::{Path, PathBuf};-/// Current schema version of `paired.json`. On a schema change,-/// bump this and migrate the old versions in [`PairedDevices::load`].+/// Current schema version of `paired-v2.json`. On a schema change within+/// this file, bump this and migrate the old versions in+/// [`PairedDevices::load`].///-/// Planned v2: trust the peer's permanent ed25519 public key (see-/// `crypto::token` in the core crate) instead of its certificate-/// fingerprint; certificates (RSA) then become ephemeral.+/// The file name tracks the trust model, not this schema version: a new+/// trust model gets a new file, so a downgraded build still finds its own+/// file intact. Planned `paired-v3.json`: trust the peer's permanent+/// ed25519 public key (see `crypto::token` in the core crate) instead of+/// its certificate fingerprint; certificates (RSA) then become ephemeral.const PAIRED_DEVICES_VERSION: u32 = 1;#[derive(Serialize, Deserialize)]@@ -19,15 +20,14 @@ pub struct PairedDevice {pub alias: String,}-/// The on-disk format of `paired.json`.+/// The on-disk format of `paired-v2.json`,+/// keyed by certificate fingerprint.#[derive(Serialize, Deserialize)]struct PairedDevicesFile {version: u32,devices: BTreeMap<String, PairedDevice>,}-/// The paired devices from `paired.json`, keyed by certificate-/// fingerprint. Their transfer requests are accepted without asking.pub struct PairedDevices {path: PathBuf,file: PairedDevicesFile,@@ -35,7 +35,7 @@ pub struct PairedDevices {impl PairedDevices {pub fn load(dir: &Path) -> anyhow::Result<Self> {- let path = dir.join("paired.json");+ let path = dir.join("paired-v2.json");let devices = match std::fs::read_to_string(&path) {Ok(text) => {// Read the version on its own first: old versions are parsed