Skip to content

Commit da03edb

Browse files
feat: update to [email protected]
1 parent 11a35bf commit da03edb

File tree

21 files changed

+1763
-1710
lines changed

21 files changed

+1763
-1710
lines changed

Cargo.lock

Lines changed: 1168 additions & 1081 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iroh-ffi"
3-
version = "0.31.0"
3+
version = "0.35.0"
44
edition = "2021"
55
publish = false
66
readme = "README.md"
@@ -11,7 +11,7 @@ repository = "https://github.com/n0-computer/iroh-ffi"
1111
homepage = "https://iroh.computer"
1212
documentation = "https://iroh.computer/docs"
1313

14-
rust-version = "1.81"
14+
rust-version = "1.83"
1515

1616
[workspace]
1717
members = ["iroh-js"]
@@ -33,14 +33,14 @@ async-trait = "0.1.80"
3333
blake3 = "1.3.3"
3434
bytes = "1"
3535
data-encoding = { version = "2.3.3" }
36-
iroh = { version = "0.31" }
37-
iroh-base = { version = "0.31", features = ["ticket"] }
36+
iroh = { version = "0.35" }
37+
iroh-base = { version = "0.35", features = ["ticket"] }
3838
iroh-io = { version = "0.6" }
39-
iroh-gossip = { version = "0.31", features = ["rpc"] }
40-
iroh-docs = { version = "0.31", features = ["rpc"] }
41-
iroh-blobs = { version = "0.31", features = ["rpc"] }
42-
iroh-metrics = { version = "0.31" }
43-
iroh-node-util = { version = "0.31", features = [] }
39+
iroh-gossip = { version = "0.35", features = ["rpc"] }
40+
iroh-docs = { version = "0.35", features = ["rpc"] }
41+
iroh-blobs = { version = "0.35", features = ["rpc"] }
42+
iroh-metrics = { version = "0.34" }
43+
iroh-node-util = { version = "0.35", features = [] }
4444
libc = "0.2.141"
4545
num_cpus = { version = "1.15.0" }
4646
range-collections = "0.4.0"
@@ -56,7 +56,7 @@ serde = { version = "1.0.196", features = ["derive"] }
5656
serde_json = "1.0.113"
5757
futures-lite = "2.3.0"
5858
derive_more = { version = "1.0.0", features = ["debug"] }
59-
quic-rpc = "0.17"
59+
quic-rpc = "0.20"
6060
rand = "0.8"
6161

6262

IrohLib.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = "IrohLib"
3-
spec.version = "0.31.0"
3+
spec.version = "0.35.0"
44
spec.summary = "iroh is a toolkit for building distributed apps"
55
spec.description = <<-DESC
66
Build distributed apps that raise the status quo for your users.

iroh-js/Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
edition = "2021"
33
name = "number0_iroh"
4-
version = "0.31.0"
4+
version = "0.35.0"
55
license = "MIT OR Apache-2.0"
66
authors = ["n0 team"]
77
repository = "https://github.com/n0-computer/iroh-ffi"
@@ -10,20 +10,20 @@ repository = "https://github.com/n0-computer/iroh-ffi"
1010
crate-type = ["cdylib"]
1111

1212
[dependencies]
13-
napi = { version = "=3.0.0-alpha.22", default-features = false, features = ["napi8", "error_anyhow", "async", "chrono_date"] }
14-
napi-derive = "=3.0.0-alpha.21"
13+
napi = { version = "=3.0.0-beta.2", default-features = false, features = ["napi8", "error_anyhow", "async", "chrono_date"] }
14+
napi-derive = "=3.0.0-beta.2"
1515
anyhow = "1.0.69"
1616
async-trait = "0.1.80"
1717
blake3 = "1.3.3"
1818
bytes = "1"
1919
data-encoding = { version = "2.3.3" }
20-
iroh-base = { version = "0.31", features = ["ticket"] }
21-
iroh-gossip = { version = "0.31", features = ["rpc"] }
22-
iroh-docs = { version = "0.31", features = ["rpc"] }
23-
iroh-blobs = { version = "0.31", features = ["rpc"] }
24-
iroh-metrics = { version = "0.31" }
25-
iroh-node-util = { version = "0.31", features = [] }
26-
iroh = "0.31"
20+
iroh-base = { version = "0.35", features = ["ticket"] }
21+
iroh-gossip = { version = "0.35", features = ["rpc"] }
22+
iroh-docs = { version = "0.35", features = ["rpc"] }
23+
iroh-blobs = { version = "0.35", features = ["rpc"] }
24+
iroh-metrics = { version = "0.34" }
25+
iroh-node-util = { version = "0.35", features = [] }
26+
iroh = "0.35"
2727
iroh-io = { version = "0.6" }
2828
libc = "0.2.141"
2929
num_cpus = { version = "1.15.0" }
@@ -38,8 +38,8 @@ tracing = "0.1.40"
3838
tracing-subscriber = { version = "0.3.17" }
3939
chrono = "0.4.38"
4040
derive_more = { version = "1.0.0", features = ["debug"] }
41-
quic-rpc = "0.17"
41+
quic-rpc = "0.20"
4242

4343

4444
[build-dependencies]
45-
napi-build = "2"
45+
napi-build = "2.2"

iroh-js/index.d.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,13 @@ export declare class Blobs {
181181
* It is a single item which can be easily serialized and deserialized.
182182
*/
183183
export declare class BlobTicket {
184-
/** The provider to get a file from. */
185-
readonly nodeAddr: NodeAddr
186184
/** The format of the blob. */
187185
readonly format: BlobFormat
188186
/** The hash to retrieve. */
189187
readonly hash: string
190188
constructor(nodeAddr: NodeAddr, hash: string, format: BlobFormat)
191189
static fromString(str: string): BlobTicket
190+
get nodeAddr(): NodeAddr
192191
/** Checks if the two tickets are equal */
193192
isEqual(other: BlobTicket): boolean
194193
toString(): string
@@ -219,12 +218,11 @@ export declare class Collection {
219218
export declare class Connecting {
220219
connect(): Promise<Connection>
221220
alpn(): Promise<Buffer>
222-
localIp(): Promise<string | null>
223-
remoteAddress(): Promise<string>
224221
}
225222

226223
export declare class Connection {
227-
getRemoteNodeId(): PublicKey
224+
alpn(): Buffer | null
225+
remoteNodeId(): PublicKey
228226
openUni(): Promise<SendStream>
229227
acceptUni(): Promise<RecvStream>
230228
openBi(): Promise<BiStream>
@@ -234,11 +232,8 @@ export declare class Connection {
234232
closeReason(): string | null
235233
close(errorCode: bigint, reason: Uint8Array): void
236234
sendDatagram(data: Uint8Array): void
237-
sendDatagramWait(data: Uint8Array): Promise<void>
238235
maxDatagramSize(): bigint | null
239236
datagramSendBufferSpace(): bigint
240-
remoteAddress(): string
241-
localIp(): string | null
242237
rtt(): bigint
243238
stableId(): bigint
244239
setMaxConcurrentUniStream(count: bigint): void
@@ -330,10 +325,9 @@ export declare class DocTicket {
330325
readonly capability: string
331326
/** The capabillity kind */
332327
readonly capabilityKind: CapabilityKind
333-
/** A list of nodes to contact. */
334-
readonly nodes: Array<NodeAddr>
335328
static fromString(str: string): DocTicket
336329
toString(): string
330+
get nodes(): Array<NodeAddr>
337331
}
338332

339333
/** Download policy to decide which content blobs shall be downloaded. */
@@ -1365,7 +1359,7 @@ export declare const enum Origin {
13651359
export declare function pathToKey(path: string, prefix?: string | undefined | null, root?: string | undefined | null): Array<number>
13661360

13671361
export interface ProtocolHandler {
1368-
accept: ((err: Error | null, arg: Connecting) => void)
1362+
accept: ((err: Error | null, arg: Connection) => void)
13691363
shutdown?: ((err: Error | null, ) => void)
13701364
}
13711365

@@ -1456,9 +1450,6 @@ export declare const enum SortDirection {
14561450
Desc = 'Desc'
14571451
}
14581452

1459-
/** Initialize the global metrics collection. */
1460-
export declare function startMetricsCollection(): void
1461-
14621453
/** Outcome of a sync operation */
14631454
export interface SyncEvent {
14641455
/** Peer we synced with */

iroh-js/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ const isMuslFromFilesystem = () => {
3535
}
3636

3737
const isMuslFromReport = () => {
38-
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
38+
let report = null
39+
if (typeof process.report?.getReport === 'function') {
40+
process.report.excludeNetwork = true
41+
report = process.report.getReport()
42+
}
3943
if (!report) {
4044
return null
4145
}
@@ -60,7 +64,13 @@ const isMuslFromChildProcess = () => {
6064
}
6165

6266
function requireNative() {
63-
if (process.platform === 'android') {
67+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
68+
try {
69+
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
70+
} catch (err) {
71+
loadErrors.push(err)
72+
}
73+
} else if (process.platform === 'android') {
6474
if (process.arch === 'arm64') {
6575
try {
6676
return require('./iroh.android-arm64.node')
@@ -364,6 +374,7 @@ if (!nativeBinding) {
364374
throw new Error(`Failed to load native binding`)
365375
}
366376

377+
module.exports = nativeBinding
367378
module.exports.Author = nativeBinding.Author
368379
module.exports.AuthorId = nativeBinding.AuthorId
369380
module.exports.Authors = nativeBinding.Authors
@@ -412,6 +423,5 @@ module.exports.setLogLevel = nativeBinding.setLogLevel
412423
module.exports.ShareMode = nativeBinding.ShareMode
413424
module.exports.SortBy = nativeBinding.SortBy
414425
module.exports.SortDirection = nativeBinding.SortDirection
415-
module.exports.startMetricsCollection = nativeBinding.startMetricsCollection
416426
module.exports.SyncReason = nativeBinding.SyncReason
417427
module.exports.verifyNodeAddr = nativeBinding.verifyNodeAddr

iroh-js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"network",
1313
"protocol"
1414
],
15-
"version": "0.31.0",
15+
"version": "0.35.0",
1616
"type": "commonjs",
1717
"main": "iroh-js/index.js",
1818
"types": "iroh-js/index.d.ts",
@@ -42,7 +42,7 @@
4242
},
4343
"license": "MIT OR Apache-2.0",
4444
"devDependencies": {
45-
"@napi-rs/cli": "^3.0.0-alpha.64"
45+
"@napi-rs/cli": "^3.0.0-alpha.80"
4646
},
4747
"scripts": {
4848
"artifacts": "napi artifacts",

iroh-js/src/endpoint.rs

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -63,38 +63,27 @@ impl Connecting {
6363
None => Err(anyhow::anyhow!("already used").into()),
6464
}
6565
}
66-
67-
#[napi]
68-
pub async fn local_ip(&self) -> Result<Option<String>> {
69-
match &*self.0.lock().await {
70-
Some(conn) => {
71-
let ip = conn.local_ip();
72-
Ok(ip.map(|ip| ip.to_string()))
73-
}
74-
None => Err(anyhow::anyhow!("already used").into()),
75-
}
76-
}
77-
78-
#[napi]
79-
pub async fn remote_address(&self) -> Result<String> {
80-
match &*self.0.lock().await {
81-
Some(conn) => {
82-
let addr = conn.remote_address();
83-
Ok(addr.to_string())
84-
}
85-
None => Err(anyhow::anyhow!("already used").into()),
86-
}
87-
}
8866
}
8967

9068
#[napi]
9169
pub struct Connection(endpoint::Connection);
9270

71+
impl From<endpoint::Connection> for Connection {
72+
fn from(value: endpoint::Connection) -> Self {
73+
Self(value)
74+
}
75+
}
76+
9377
#[napi]
9478
impl Connection {
9579
#[napi]
96-
pub fn get_remote_node_id(&self) -> Result<PublicKey> {
97-
let id = endpoint::get_remote_node_id(&self.0)?;
80+
pub fn alpn(&self) -> Option<Buffer> {
81+
self.0.alpn().map(Into::into)
82+
}
83+
84+
#[napi]
85+
pub fn remote_node_id(&self) -> Result<PublicKey> {
86+
let id = self.0.remote_node_id()?;
9887
Ok(id.into())
9988
}
10089

@@ -162,15 +151,6 @@ impl Connection {
162151
Ok(())
163152
}
164153

165-
#[napi]
166-
pub async fn send_datagram_wait(&self, data: Uint8Array) -> Result<()> {
167-
self.0
168-
.send_datagram_wait(data.to_vec().into())
169-
.await
170-
.map_err(anyhow::Error::from)?;
171-
Ok(())
172-
}
173-
174154
#[napi]
175155
pub fn max_datagram_size(&self) -> Option<usize> {
176156
self.0.max_datagram_size()
@@ -181,16 +161,6 @@ impl Connection {
181161
self.0.datagram_send_buffer_space()
182162
}
183163

184-
#[napi]
185-
pub fn remote_address(&self) -> String {
186-
self.0.remote_address().to_string()
187-
}
188-
189-
#[napi]
190-
pub fn local_ip(&self) -> Option<String> {
191-
self.0.local_ip().map(|s| s.to_string())
192-
}
193-
194164
#[napi]
195165
pub fn rtt(&self) -> BigInt {
196166
self.0.rtt().as_millis().into()
@@ -327,14 +297,18 @@ impl RecvStream {
327297
#[napi]
328298
pub async fn read(&self, mut buf: Uint8Array) -> Result<Option<usize>> {
329299
let mut r = self.0.lock().await;
330-
let res = r.read(&mut buf).await.map_err(anyhow::Error::from)?;
300+
let buffer_mut_ref: &mut [u8] = unsafe { buf.as_mut() };
301+
let res = r.read(buffer_mut_ref).await.map_err(anyhow::Error::from)?;
331302
Ok(res)
332303
}
333304

334305
#[napi]
335306
pub async fn read_exact(&self, mut buf: Uint8Array) -> Result<()> {
336307
let mut r = self.0.lock().await;
337-
r.read_exact(&mut buf).await.map_err(anyhow::Error::from)?;
308+
let buffer_mut_ref: &mut [u8] = unsafe { buf.as_mut() };
309+
r.read_exact(buffer_mut_ref)
310+
.await
311+
.map_err(anyhow::Error::from)?;
338312
Ok(())
339313
}
340314

iroh-js/src/lib.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use iroh_metrics::core::Metric;
21
use napi::bindgen_prelude::*;
32
use napi_derive::napi;
43
use tracing_subscriber::filter::LevelFilter;
@@ -64,20 +63,6 @@ pub fn set_log_level(level: LogLevel) {
6463
.init();
6564
}
6665

67-
/// Initialize the global metrics collection.
68-
#[napi]
69-
pub fn start_metrics_collection() -> Result<()> {
70-
iroh_metrics::core::Core::try_init(|reg, metrics| {
71-
metrics.insert(iroh::metrics::MagicsockMetrics::new(reg));
72-
metrics.insert(iroh::metrics::NetReportMetrics::new(reg));
73-
metrics.insert(iroh::metrics::PortmapMetrics::default());
74-
metrics.insert(iroh_blobs::metrics::Metrics::new(reg));
75-
metrics.insert(iroh_gossip::metrics::Metrics::new(reg));
76-
metrics.insert(iroh_docs::metrics::Metrics::new(reg));
77-
})
78-
.map_err(|e| anyhow::Error::from(e).into())
79-
}
80-
8166
/// Helper function that translates a key that was derived from the [`path_to_key`] function back
8267
/// into a path.
8368
///

0 commit comments

Comments
 (0)