a bit more debug info

ffi-segfault-fix
Jake McGinty 2021-11-29 03:21:35 +09:00
parent 534403b170
commit 595367ab87
2 changed files with 3 additions and 1 deletions

View File

@ -128,6 +128,7 @@ fn set_endpoint(public_key: &str, endpoint: Option<&Endpoint>) -> Option<PeerCon
endpoint
.and_then(|endpoint| endpoint.resolve().ok())
.map(|addr| {
log::trace!("set_endpoint({}, {})", public_key, addr);
PeerConfigBuilder::new(&Key::from_base64(public_key).unwrap()).set_endpoint(addr)
})
}

View File

@ -392,10 +392,11 @@ pub fn get_by_name(name: &InterfaceName) -> Result<Device, io::Error> {
};
let result = if ret == 0 && !device.is_null() {
println!("kernel get_by_name: wg FFI ret code was normal.");
Ok(Device::from(unsafe { &*device }))
} else {
let last_error = io::Error::last_os_error();
println!("FFI ret code was {}, &device is {:p}, last OS error: {:?}", ret, device, last_error.raw_os_error());
println!("kernel get_by_name: FFI ret code was {}, &device is {:p}, last OS error: {:?}", ret, device, last_error.raw_os_error());
Err(last_error)
};