#vpn #security #networking #openconnect

openconnect-core

A library for interacting with OpenConnect VPN

5 releases

new 0.1.5 Apr 18, 2024
0.1.4 Apr 18, 2024
0.1.0 Mar 17, 2024

#1034 in Network programming

Download history 88/week @ 2024-03-11 44/week @ 2024-03-18 21/week @ 2024-04-01 127/week @ 2024-04-08 433/week @ 2024-04-15

583 downloads per month

LGPL-2.1

1MB
12K SLoC

Openconnect Core Library

This library provides a safe Rust API for interacting with underlying Openconnect C library. The unsafe bindings are provided by the openconnect-sys crate.

Prerequisites

Read the openconnect-sys crate documentation for installing prerequisites including native system libraries and headers.

Usage

  • 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

Dependencies

~13–64MB
~1M SLoC