4 releases

0.1.3 Oct 25, 2023
0.1.2 Apr 6, 2023
0.1.1 Mar 12, 2023
0.1.0 Mar 12, 2023

#15 in #tls-connection

Download history 57/week @ 2024-02-23 29/week @ 2024-03-01 7/week @ 2024-03-08 3/week @ 2024-03-15

96 downloads per month
Used in qs-lite

MIT license

35KB
582 lines

QSocket Rust

Build Status Coverage Status (codecov.io) Documentation

Rust library for qsocket...

Usage

Usage is really simple, qsocket_rs::new function simply creates a new quantum socket with given secret, it includes all the functions of standard std::net::TcpStream sockets and also implements io::Read/Write. After creating a socket you need to dial the QSRN network by calling qsocket_rs::Dial* functions. Simple example below...

use qsocket;

/// Creates a new quantum socket instance.
///
/// `secret` value can be considered as the password for the QSocket connection,
/// It will be used for generating a 128bit unique identifier (UID) for the connection.
let mut qsock = qsocket::QSocket::new("my-secret", true);

/// Opens a TLS connection to the QSRN.
///
/// If the `verify_cert` parameter is true,
/// after establishing a TLS connection with the QSRN gate server,
/// the TLS certificate fingerprint will be validated with the hardcoded certificate fingerprint value `QSRN_CERT_FINGERPRINT`.
///
/// If the connection fails due to network related errors,
/// function will return the corresponding error, in the case of
/// QSRN related errors the function will return one the ERR_KNOCK_* errors.
if let Err(e) = qsock.dial() {           
    panic!("{}", e);
}

After dialing the QSRN, socket is ready for read/write operations.

Dependencies

~10–21MB
~378K SLoC