Giter VIP home page Giter VIP logo

gosocks's Introduction

GOSOCKS

Basic golang implementation of a socks5 proxy. This implementation is currently not feature complete and only supports the CONNECT command and no authentication.

This implemention also defines some handlers you can use to implement your own protocol behind this proxy server. This can be useful if you come a across a protocol that can be abused for proxy functionality and build a socks5 proxy around it.

The SOCKS protocol is defined in rfc1928

Documentation

https://pkg.go.dev/github.com/firefart/gosocks

Handler Interface

type ProxyHandler interface {
  Init(context.Context, Request) (context.Context, io.ReadWriteCloser, *Error)
  ReadFromClient(context.Context, io.ReadCloser, io.WriteCloser) error
  ReadFromRemote(context.Context, io.ReadCloser, io.WriteCloser) error
  Close(context.Context) error
  Refresh(context.Context)
}

Init

Init is called before the copy operations and it should return a connection to the target that is ready to receive data. It may also amend the context used throughout the lifecycle of the request.

ReadFromClient

ReadFromClient is the method that handles the data copy from the client (you) to the remote connection. You can see the DefaultHandler for a sample implementation. You can also pass in custom data using the context.

ReadFromRemote

ReadFromRemote is the method that handles the data copy from the remote connection to the client (you). You can see the DefaultHandler for a sample implementation. You can also pass in custom data using the context.

Close

Close is called after the request finishes or errors out. It is used to clean up any connections in your custom implementation.

Refresh

Refresh is called in a seperate goroutine and should loop forever to do refreshes of the connection if needed. The passed in context is cancelled after the request so be sure to check on the Done event.

Examples

Please see the examples directory.

gosocks's People

Contributors

coronon avatar dependabot[bot] avatar firefart avatar wikylyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.