mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-20 21:33:57 -07:00
progress
This commit is contained in:
parent
9ef75c0e13
commit
6393a4beec
3 changed files with 87 additions and 16 deletions
|
@ -5,11 +5,17 @@ use crate::{AuthInfo, ZeroIDC};
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn zeroidc_new(
|
||||
network_id: *const c_char,
|
||||
issuer: *const c_char,
|
||||
client_id: *const c_char,
|
||||
auth_endpoint: *const c_char,
|
||||
web_listen_port: u16,
|
||||
) -> *mut ZeroIDC {
|
||||
if network_id.is_null() {
|
||||
println!("network_id is null");
|
||||
return std::ptr::null_mut();
|
||||
|
||||
}
|
||||
if issuer.is_null() {
|
||||
println!("issuer is null");
|
||||
return std::ptr::null_mut();
|
||||
|
@ -25,12 +31,14 @@ pub extern "C" fn zeroidc_new(
|
|||
return std::ptr::null_mut();
|
||||
}
|
||||
|
||||
let iss = unsafe { CStr::from_ptr(issuer) };
|
||||
let c_id = unsafe { CStr::from_ptr(client_id) };
|
||||
let network_id = unsafe {CStr::from_ptr(network_id) };
|
||||
let issuer = unsafe { CStr::from_ptr(issuer) };
|
||||
let client_id = unsafe { CStr::from_ptr(client_id) };
|
||||
let auth_endpoint = unsafe { CStr::from_ptr(auth_endpoint) };
|
||||
match ZeroIDC::new(
|
||||
iss.to_str().unwrap(),
|
||||
c_id.to_str().unwrap(),
|
||||
network_id.to_str().unwrap(),
|
||||
issuer.to_str().unwrap(),
|
||||
client_id.to_str().unwrap(),
|
||||
auth_endpoint.to_str().unwrap(),
|
||||
web_listen_port,
|
||||
) {
|
||||
|
@ -82,6 +90,24 @@ pub extern "C" fn zeroidc_is_running(ptr: *mut ZeroIDC) -> bool {
|
|||
idc.is_running()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn zeroidc_process_form_post(ptr: *mut ZeroIDC, body: *const c_char) -> bool {
|
||||
let idc = unsafe {
|
||||
assert!(!ptr.is_null());
|
||||
&mut *ptr
|
||||
};
|
||||
|
||||
if body.is_null() {
|
||||
println!("body is null");
|
||||
return false
|
||||
}
|
||||
|
||||
let body = unsafe { CStr::from_ptr(body) }
|
||||
.to_str().unwrap().to_string();
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn zeroidc_get_auth_info(
|
||||
ptr: *mut ZeroIDC,
|
||||
|
|
|
@ -21,6 +21,7 @@ pub struct ZeroIDC {
|
|||
|
||||
struct Inner {
|
||||
running: bool,
|
||||
network_id: String,
|
||||
auth_endpoint: String,
|
||||
oidc_thread: Option<JoinHandle<()>>,
|
||||
oidc_client: Option<openidconnect::core::CoreClient>,
|
||||
|
@ -43,6 +44,7 @@ pub struct AuthInfo {
|
|||
|
||||
impl ZeroIDC {
|
||||
fn new(
|
||||
network_id: &str,
|
||||
issuer: &str,
|
||||
client_id: &str,
|
||||
auth_ep: &str,
|
||||
|
@ -51,6 +53,7 @@ impl ZeroIDC {
|
|||
let idc = ZeroIDC {
|
||||
inner: Arc::new(Mutex::new(Inner {
|
||||
running: false,
|
||||
network_id: network_id.to_string(),
|
||||
auth_endpoint: auth_ep.to_string(),
|
||||
oidc_thread: None,
|
||||
oidc_client: None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue