Giter Club home page Giter Club logo

shadowsocks-go's Introduction

<( ̄︶ ̄)↗[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)
	}
}

Links

shadowsocks-go's People

Contributors

dependabot[bot] avatar yee2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.