Skip to content

Commit

Permalink
Moved openssl to snxcore
Browse files Browse the repository at this point in the history
  • Loading branch information
ancwrd1 committed Jan 8, 2025
1 parent 96ae6b7 commit f6f718a
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions snx-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,3 @@ libc = "0.2"
tracing-subscriber = "0.3"
clap = { version = "4.5.4", features = ["derive"] }
ipnet = { version = "2", features = ["serde"] }
openssl-sys = "0.9"
openssl = "0.10"

[features]
vendored-openssl = ["openssl/vendored"]
18 changes: 1 addition & 17 deletions snx-rs/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(unexpected_cfgs)]

use std::{collections::VecDeque, future::Future, sync::Arc};

use anyhow::anyhow;
Expand Down Expand Up @@ -58,20 +56,6 @@ where
}
}

fn init_openssl() {
#[cfg(openssl3)]
{
use openssl::provider::Provider;
use std::sync::OnceLock;

static LEGACY_PROVIDER: OnceLock<Provider> = OnceLock::new();

if let Ok(provider) = Provider::try_load(None, "legacy", true) {
let _ = LEGACY_PROVIDER.set(provider);
}
}
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cmdline_params = CmdlineParams::parse();
Expand All @@ -80,7 +64,7 @@ async fn main() -> anyhow::Result<()> {
return Err(anyhow!("Please run me as a root user!"));
}

init_openssl();
platform::init();

let mode = cmdline_params.mode;

Expand Down
5 changes: 5 additions & 0 deletions snxcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ secret-service = { version = "4", features = ["rt-tokio-crypto-rust"] }
uuid = { version = "1", features = ["v4", "v5"] }
opener = { version = "0.7"}
cached = { version = "0.54", features = ["async"] }
openssl-sys = "0.9"
openssl = "0.10"

[dev-dependencies]
tempfile = "3"

[features]
vendored-openssl = ["openssl/vendored"]

File renamed without changes.
2 changes: 2 additions & 0 deletions snxcore/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unexpected_cfgs)]

pub mod browser;
pub mod ccc;
pub mod controller;
Expand Down
1 change: 1 addition & 0 deletions snxcore/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use tokio::net::UdpSocket;
#[cfg(target_os = "linux")]
use linux as platform_impl;
pub use platform_impl::{
init,
acquire_password, configure_device, delete_device, get_machine_uuid,
net::{
add_route, add_routes, get_default_ip, is_online, poll_online, remove_default_route, setup_default_route,
Expand Down
14 changes: 14 additions & 0 deletions snxcore/src/platform/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ pub mod xfrm;

const UDP_ENCAP_ESPINUDP: libc::c_int = 2; // from /usr/include/linux/udp.h

pub fn init() {
#[cfg(openssl3)]
{
use openssl::provider::Provider;
use std::sync::OnceLock;

static LEGACY_PROVIDER: OnceLock<Provider> = OnceLock::new();

if let Ok(provider) = Provider::try_load(None, "legacy", true) {
let _ = LEGACY_PROVIDER.set(provider);
}
}
}

#[async_trait::async_trait]
impl UdpSocketExt for UdpSocket {
fn set_encap(&self, encap: UdpEncap) -> anyhow::Result<()> {
Expand Down

0 comments on commit f6f718a

Please sign in to comment.