ferristseng / rust-ipfs-api

IPFS HTTP client in Rust
Apache License 2.0
246 stars 68 forks source link

A critical bug in IpfsClient.id() #143

Open Ayana-chan opened 7 months ago

Ayana-chan commented 7 months ago

I got a trouble when I want to obtain IPFS node's information. I use IpfsClient like:

let client = IpfsClient::from_ipv4(
    "http".parse().unwrap(),
    SocketAddrV4::new(Ipv4Addr::new(192, 168, 177, 134), 5001),
).unwrap();
let data = Cursor::new("Hello World!");

match client.add(data).await {
    Ok(res) => println!("{}", res.hash),
    Err(e) => eprintln!("error adding file: {:?}", e)
}

match client.id(None).await {
    Ok(res) => println!("{:?}", res),
    Err(e) => eprintln!("error search id: {:?}", e)
}

log in console:

2024-01-13T04:28:28.215302Z DEBUG hyper::client::connect::http: connecting to 192.168.177.134:5001
2024-01-13T04:28:28.218332Z DEBUG hyper::client::connect::http: connected to 192.168.177.134:5001
2024-01-13T04:28:28.219355Z DEBUG hyper::proto::h1::io: flushed 282 bytes
2024-01-13T04:28:28.221537Z DEBUG hyper::proto::h1::io: parsed 9 headers
2024-01-13T04:28:28.221562Z DEBUG hyper::proto::h1::conn: incoming body is chunked encoding
2024-01-13T04:28:28.221658Z DEBUG hyper::proto::h1::decode: incoming chunked header: 0x7E (126 bytes)
2024-01-13T04:28:28.221807Z DEBUG hyper::proto::h1::conn: incoming body completed
2024-01-13T04:28:28.222229Z DEBUG hyper::client::connect::http: connecting to 192.168.177.134:5001
2024-01-13T04:28:28.242367Z DEBUG hyper::client::connect::http: connected to 192.168.177.134:5001
2024-01-13T04:28:28.242886Z DEBUG hyper::proto::h1::io: flushed 57 bytes
2024-01-13T04:28:28.244702Z DEBUG hyper::proto::h1::io: parsed 8 headers
2024-01-13T04:28:28.244722Z DEBUG hyper::proto::h1::conn: incoming body is chunked encoding
2024-01-13T04:28:28.244754Z DEBUG hyper::proto::h1::decode: incoming chunked header: 0x87E (2174 bytes)
2024-01-13T04:28:28.244846Z DEBUG hyper::proto::h1::conn: incoming body completed
Qmf1rtki74jvYmGeqaaV51hzeiaa6DyWc98fzDiuPatzyy
error search id: IpfsClientError(Parse(Error("missing field `ProtocolVersion`", line: 1, column: 2173)))

I can't find where the ProtocolVersion is needed, while there are no any problem in add() or log_ls(). Very confused.

In addition, the 192.168.177.134:5001 is on my Ubuntu 22.04 in Vmware, and the IPFS node is Kubo in Docker.

Ayana-chan commented 6 months ago

I found the reason. IdResponse should be updated. The "protocol_version" is not responded now. Instead, a array "Protocols" is responded.

ehsan6sha commented 5 months ago

I found the reason. IdResponse should be updated. The "protocol_version" is not responded now. Instead, a array "Protocols" is responded.

Could you get around the error?