Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support libsodium #383

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ default = ["zmq_has"]
# this feature is a no-op and only present for backward-compatibility;
# it will be removed in the next API-breaking release.
zmq_has = []
libsodium = ["zmq-sys/libsodium"]

[dependencies]
bitflags = "1.0"
libc = "0.2.15"
zmq-sys = { version = "0.12.0", path = "zmq-sys" }
zmq-sys = { version = "0.12.1", path = "zmq-sys" }

[dev-dependencies]
trybuild = { version = "1" }
Expand Down
4 changes: 3 additions & 1 deletion zmq-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zmq-sys"
version = "0.12.0"
version = "0.12.1"
authors = [
"a.rottmann@gmx.at",
"erick.tryzelaar@gmail.com",
Expand All @@ -14,9 +14,11 @@ build = "build/main.rs"
links = "zmq"

[features]
libsodium = ["dep:libsodium-sys-stable"]

[dependencies]
libc = "0.2.15"
libsodium-sys-stable = { version = "1.0", optional = true }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that 1.0 is not a valid version number for libsodium-sys-stable: https://crates.io/crates/libsodium-sys-stable/versions

Maybe change to the latest, 1.20.4? After changing the version value, I was able to set CURVE keys without errors being returned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of semver, 1.0 really means >=1.0.0, which includes 1.18.1 and above.

That said it might make sense to validate that things actually build with that version, with i.e. cargo +nightly -Zminimal-versions generate-lockfile.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I was not aware of that, thanks for educating me!

I wonder why changing the version number to something explicitly in their version list seemed to make a difference on my local setup though? I can no longer recall how things were failing (build issues vs. issues with my runtime testing). I was pretty sure that this change actually resolved whatever the issue was, but perhaps I changed multiple things... I simply don't remember anymore.


[build-dependencies]
system-deps = "6"
Expand Down
15 changes: 14 additions & 1 deletion zmq-sys/build/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::env;

pub fn configure() {
println!("cargo:rerun-if-changed=build/main.rs");
println!("cargo:rerun-if-env-changed=PROFILE");
Expand All @@ -6,8 +8,19 @@ pub fn configure() {
// relying on `tweetnacl`. However since this `tweetnacl` [has never been
// audited nor is ready for production](https://github.com/zeromq/libzmq/issues/3006),
// we link against `libsodium` to enable `ZMQ_CURVE`.
let maybe_libsodium = if cfg!(feature = "libsodium") {
let lib_dir = env::var("DEP_SODIUM_LIB")
.expect("build metadata `DEP_SODIUM_LIB` required");
let include_dir = env::var("DEP_SODIUM_INCLUDE")
.expect("build metadata `DEP_SODIUM_INCLUDE` required");

Some(zeromq_src::LibLocation::new(lib_dir, include_dir))
} else {
None
};

zeromq_src::Build::new()
.with_libsodium(None)
.with_libsodium(maybe_libsodium)
.build();
}

Expand Down