shadowsocks

package module
v0.0.0-...-1ef5823 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 8 Imported by: 0

README

<( ̄︶ ̄)↗[GO!] A shadowsocks implementation in pure go

GoDoc

Install

go get github.com/Yee2/shadowsocks-go

Usage

shadowsocks-go provides a Go version implementation of the shadowsocks protocol, supporting AEAD encryption and Stream encryption. The main working principle is to encode a pipe for plaintext transmission, and data written to the pipe will be automatically encrypted, while data read from the pipe will be automatically decrypted.

package main

import (
	"bytes"
	"github.com/Yee2/shadowsocks-go"
	"log"
)

func main() {
	buf := new(bytes.Buffer)
	// Create a shadowsocks configuration
	tunnel, err := shadowsocks.NewTunnel("aes-256-gcm", "12345678")
	checkErr(err)

	// shadow the channel
	shaded, err := tunnel.Shadow(&shadowsocks.Closeable{ReadWriter: buf})
	checkErr(err)

	// Close channel will free some reusable resources like bytes buffer etc
	defer shaded.Close()

	// Write data is automatically encrypted and read data is automatically decrypted
	_, err = shaded.Write([]byte("hello shadowsocks!"))
	checkErr(err)
	var data [32]byte
	n, err := shaded.Read(data[:])
	checkErr(err)
	log.Printf("%s\n", data[:n])
}

func checkErr(err error) {
	if err != nil {
		log.Fatalln(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlreadyRegistered = errors.New("already registered")
View Source
var CipherNotSupported = errors.New("cipher not supported")

Functions

func Register

func Register(p core.TunnelProvider) error

func Supported

func Supported() []string

Supported Get the supported encryption methods

Types

type Closeable

type Closeable struct {
	io.ReadWriter
}

func (*Closeable) Close

func (c *Closeable) Close() error

type Tunnel

type Tunnel = core.Tunnel

func NewTunnel

func NewTunnel(method, password string) (Tunnel, error)

NewTunnel make a new shadowsocks channel

Directories

Path Synopsis
ciphers
cmd
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL