rust-ipfs
rust-ipfs copied to clipboard
Implement IPNS
The base of IPNS was removed (giving some example in commits df8a12e111192f312665049934e4da2ffdcc51db, af7d88b42155aeb02083e99ad6bc1e7bbd9ae550, etc) leaving only dnslink portion in tack. Since libp2p have came a long way since then, we should be able to make use of DHT to put IPNS records.
- [x] Import newer IPNS proto file
- [x] Create functions to create, sign (both sigv1 and sigv2), encode and decode the IPNS Record (see #88)
- [x] Implement functions to publish IPNS to DHT (see #88)
- [ ] Test for go-ipfs and js-ipfs interop
- [ ] Implement IPNS over Pubsub(?) - Low priority and research would be needed
Note: This will be done in a separate crate that would be imported into rust-ipfs
My app uses/bundles Kubo, but I need to switch to a pure rust implementation of IPFS so it can go mobile, etc. It relies heavily on IPNS functionality, so I'm interested in contributing to this issue. Your write up here is very helpful and should get me on the right track, but I'm curious if you have any additional info or suggestions that might help.
Hey! Thank you for your response. IPNS, to say the least, been low priority for me since I been focusing on cleaning up and improving the overall functionality before focusing on IPNS (which i will say may be able to solve some of the things I use this project for too). As to when I will actually get to IPNS is hard to say, especially since I do need to review changes made in rust-libp2p again from https://github.com/libp2p/rust-libp2p/pull/2712 to make sure im understanding the API changes.
At this time, however, I dont have any additional info for this. Regardless, all contributions are welcome. If you do have questions feel free to ask!
Hello, I'm having difficulties as well. It seems ipns does not publish properly? Here is my set up.
let transport_config = TransportConfig {
enable_websocket: true,
enable_secure_websocket: true,
..Default::default()
};
let ipfs: rust_ipfs::Ipfs = rust_ipfs::UninitializedIpfsDefault::new()
.with_default()
.set_transport_configuration(transport_config)
.set_keypair(&ipfs_keypair)
.fd_limit(rust_ipfs::FDLimit::Max)
.with_mdns()
.set_default_listener()
.add_listening_addr(format!("/ip4/0.0.0.0/tcp/{}/ws", 32412).parse().unwrap())
.swarm_events(|_, event| {
if let libp2p::swarm::SwarmEvent::NewListenAddr { address, .. } = event {
log::info!("Listening on {}", address);
}
})
.default_record_key_validator()
.with_relay(true)
.with_relay_server(Default::default())
.listen_as_external_addr()
.with_upnp()
.with_bitswap()
.with_pubsub(rust_ipfs::p2p::PubsubConfig::default())
.with_rendezvous_server()
.start()
.await
.unwrap();
// Perform default bootstrap
ipfs.default_bootstrap().await.unwrap();
// derive ipns name
let ipns_name = cid::Cid::new_v1(0x72, *ipfs.keypair().public().to_peer_id().as_ref())
.to_string_of_base(Base::Base36Lower)
.unwrap();
let cid = ipfs
.add_unixfs(format!("kofi otuo {system_time:?}").into_bytes())
.await
.unwrap();
log::info!("Got dag cids {}", cid);
let cid = IpfsPath::from(cid);
let publish = ipfs.publish_ipns(&cid).await.unwrap();
// print logs
While the cids work, getting from ipns does not. In another terminal, I started the Kubo ipfs node. ipfs cat /ipfs/cid works, however, ipfs cat /ipns/k51... does not work
ipfs cat /ipns/k51qzi5uqu5dgd4ahjbbs734qtabdrj8wism8w9ks03zcicebjvzzlyner9zg4
Error: could not resolve name
I tried connecting both nodes but only ipfs cat /ipfs/cid works
Am I missing a configuration for the ipfs node to enable ipns?