diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 7227d0fa558c4b319c6f2f65768326f06cde2c21..47a6400fbf7600df119c0b5164ac510ead2f5ddf 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -2,10 +2,10 @@ name = "opendht" version = "0.1.0" authors = ["Sébastien Blin <sebastien.blin@savoirfairelinux.com>"] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +edition = "2021" [dependencies] -libc="0.2.0" -os_socketaddr="0.2.3" \ No newline at end of file +libc="0.2" +os_socketaddr="0.2.3" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/rust/src/dhtrunner.rs b/rust/src/dhtrunner.rs index 3ff9f212e82fdb90d6e25c4ff68f53eff6012833..1292fce5626f96af338f23af080017c7a5f0ea98 100644 --- a/rust/src/dhtrunner.rs +++ b/rust/src/dhtrunner.rs @@ -56,6 +56,7 @@ impl DhtRunnerConfig { privatekey: ptr::null_mut(), certificate: ptr::null_mut(), }, + log: true, }); unsafe { dht_runner_config_default(&mut *config); @@ -64,23 +65,23 @@ impl DhtRunnerConfig { } pub fn set_proxy_server(&mut self, proxy_server: &str) { - self.proxy_server = CString::new(proxy_server).unwrap().as_ptr(); + self.proxy_server = CString::new(proxy_server).unwrap().into_raw(); } pub fn set_push_node_id(&mut self, push_node_id: &str) { - self.push_node_id = CString::new(push_node_id).unwrap().as_ptr(); + self.push_node_id = CString::new(push_node_id).unwrap().into_raw(); } pub fn set_push_token(&mut self, push_token: &str) { - self.push_token = CString::new(push_token).unwrap().as_ptr(); + self.push_token = CString::new(push_token).unwrap().into_raw(); } pub fn set_push_topic(&mut self, push_topic: &str) { - self.push_topic = CString::new(push_topic).unwrap().as_ptr(); + self.push_topic = CString::new(push_topic).unwrap().into_raw(); } pub fn set_push_platform(&mut self, push_platform: &str) { - self.push_platform = CString::new(push_platform).unwrap().as_ptr(); + self.push_platform = CString::new(push_platform).unwrap().into_raw(); } pub fn set_identity(&mut self, certificate: Box<DhtCertificate>, privatekey: Box<PrivateKey>) { @@ -93,7 +94,7 @@ impl DhtRunnerConfig { impl DhtNodeConfig { pub fn set_persist_path(&mut self, persist_path: &str) { - self.persist_path = CString::new(persist_path).unwrap().as_ptr(); + self.persist_path = CString::new(persist_path).unwrap().into_raw(); } } @@ -197,8 +198,8 @@ impl DhtRunner { pub fn bootstrap(&mut self, host: &str, service: u16) { unsafe { dht_runner_bootstrap(&mut *self, - CString::new(host).unwrap().as_ptr(), - CString::new(service.to_string()).unwrap().as_ptr()) + CString::new(host).unwrap().into_raw(), + CString::new(service.to_string()).unwrap().into_raw()) } } diff --git a/rust/src/ffi.rs b/rust/src/ffi.rs index f14ffaa8da70b0effae357912d0abd15cc5e98ae..3ae928c59a9e79879c09a6729c78b32b97857cfd 100644 --- a/rust/src/ffi.rs +++ b/rust/src/ffi.rs @@ -124,9 +124,9 @@ pub struct DhtRunnerConfig pub peer_publish: bool, pub server_ca: *mut DhtCertificate, pub client_identity: DhtIdentity, + pub log: bool, } - #[link(name = "opendht-c")] extern { // dht::Value