Crate ss_light

Source
Expand description

§Examples

tcp relay with aes-256-gcm:

use tokio::net::TcpListener;
use std::io;
use ss_light::*;

#[tokio::main]
async fn main() -> io::Result<()> {
    let pwd = "123456";
    let key = util::evp_bytes_to_key(pwd.as_bytes(), CipherKind::AES_256_GCM.key_len());

    let listener = TcpListener::bind("127.0.0.1:8080").await?;
    let (socket, _) = listener.accept().await?;

    // notice: one connection one task
    let mut ss = Stream::new_from_stream(socket, CipherKind::AES_256_GCM, &key);

    let target_addr = Address::read_from(&mut ss).await.unwrap();
    let target = target_addr.connect().await.unwrap();

    util::copy_bidirectional(ss, target).await;
    Ok(())
}

udp relay with aes-256-gcm:

use tokio::net::UdpSocket;
use std::{io,time};
use ss_light::*;

#[tokio::main]
async fn main() -> io::Result<()> {
    let pwd = "123456";
    let key = util::evp_bytes_to_key(pwd.as_bytes(), CipherKind::AES_256_GCM.key_len());

    let socket = UdpSocket::bind("127.0.0.1:8080").await?;

    let udp_server = ss_light::UdpServer::new(
        socket,
        CipherKind::AES_256_GCM,
        &key,
        1000,
        time::Duration::from_secs(30),
    );

    udp_server.run().await;
    Ok(())
}

Re-exports§

pub use consts::Error;
pub use crypto::Stream;

Modules§

consts
Handshake related constants
crypto
plugin
plugin support. SIP003 https://shadowsocks.org/en/wiki/Plugin.html
util

Structs§

UdpServer

Enums§

Address
CipherKind

Constants§

VERSION