Crates.io | openconnect-core |
lib.rs | openconnect-core |
version | 0.1.5 |
source | src |
created_at | 2024-03-17 14:49:26.043211 |
updated_at | 2024-04-18 13:22:53.86893 |
description | A library for interacting with OpenConnect VPN |
homepage | https://github.com/hlhr202/Openconnect-RS |
repository | https://github.com/hlhr202/Openconnect-RS/tree/main/crates/openconnect-core |
max_upload_size | |
id | 1176565 |
size | 166,103 |
This library provides a safe Rust API for interacting with underlying Openconnect C library. The unsafe bindings are provided by the openconnect-sys crate.
Read the openconnect-sys crate documentation for installing prerequisites including native system libraries and headers.
Add openconnect-core
to your Cargo.toml
:
[dependencies]
openconnect-core = "0.1"
Use the library in your code:
use openconnect_core::{
config::{ConfigBuilder, EntrypointBuilder, LogLevel},
events::EventHandlers,
protocols::get_anyconnect_protocol,
Connectable, VpnClient,
};
use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let protocol = get_anyconnect_protocol();
let config = ConfigBuilder::default().loglevel(LogLevel::Info).build()?;
let event_handlers = EventHandlers::default();
let client = VpnClient::new(config, event_handlers)?;
let entrypoint = EntrypointBuilder::new()
.server("vpn.example.com")
.username("your_username")
.password("your_password")
.protocol(protocol)
.enable_udp(true)
.accept_insecure_cert(true)
.build()?;
client.connect(entrypoint)?;
Ok(())
}
For more use cases, you can checkout our CLI application openconnect-cli.
For GUI/CLI applications, you can checkout our github repository Openconnect-RS