Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
ae62216b
Commit
ae62216b
authored
11 months ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
rust: update to 2021, fix memory issues
parent
cd92eeaa
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
rust/Cargo.toml
+5
-5
5 additions, 5 deletions
rust/Cargo.toml
rust/src/dhtrunner.rs
+9
-8
9 additions, 8 deletions
rust/src/dhtrunner.rs
rust/src/ffi.rs
+1
-1
1 addition, 1 deletion
rust/src/ffi.rs
with
15 additions
and
14 deletions
rust/Cargo.toml
+
5
−
5
View file @
ae62216b
...
...
@@ -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
"
libc
=
"0.2"
os_socketaddr
=
"0.2.3"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
This diff is collapsed.
Click to expand it.
rust/src/dhtrunner.rs
+
9
−
8
View file @
ae62216b
...
...
@@ -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
())
}
}
...
...
This diff is collapsed.
Click to expand it.
rust/src/ffi.rs
+
1
−
1
View file @
ae62216b
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment