Go to file
2020-08-06 20:21:26 +08:00
_example fix all test 2020-08-06 16:29:38 +08:00
.github/workflows fix ci 2020-08-05 14:47:08 +08:00
bufferpool add associate test 2020-08-06 14:31:36 +08:00
ccsocks5 laddr limit 2020-08-06 20:21:26 +08:00
statute use buffer pool interface 2020-08-06 10:12:46 +08:00
testing fix test 2020-08-06 20:15:25 +08:00
.gitignore use buffer pool interface 2020-08-06 10:12:46 +08:00
.travis.yml fix ci 2020-08-05 14:47:08 +08:00
auth_test.go add more test 2020-08-05 14:40:07 +08:00
auth.go add more test 2020-08-05 14:40:07 +08:00
credentials_test.go add more test 2020-08-05 14:40:07 +08:00
credentials.go add more test 2020-08-05 14:40:07 +08:00
go.mod add header test 2020-08-05 10:34:29 +08:00
go.sum add header test 2020-08-05 10:34:29 +08:00
handle_test.go add associate test 2020-08-06 14:31:36 +08:00
handle.go fix 2020-08-06 11:11:30 +08:00
LICENSE Initial commit 2014-01-22 15:49:51 -08:00
logger.go add user handle 2020-04-22 10:15:40 +08:00
option.go add associate test 2020-08-06 14:31:36 +08:00
README.md fix read me 2020-08-06 16:55:32 +08:00
resolver_test.go add more test 2020-08-05 14:40:07 +08:00
resolver.go add user handle 2020-04-22 10:15:40 +08:00
revive.sh revive inspect 2020-04-22 10:32:03 +08:00
revive.toml revive inspect 2020-04-22 10:32:03 +08:00
ruleset_test.go fix request/response statute 2020-08-05 18:10:50 +08:00
ruleset.go add more test 2020-08-05 14:40:07 +08:00
server_test.go fix all test 2020-08-06 16:29:38 +08:00
server.go fix all test 2020-08-06 16:29:38 +08:00

go-socks5

Build Status Go.Dev reference codecov Action Status Go Report Card License Tag

Provides the socks5 package that implements a SOCKS5. SOCKS (Secure Sockets) is used to route traffic between a client and server through an intermediate proxy layer. This can be used to bypass firewalls or NATs.

Feature

The package has the following features:

  • Support client(under ccsocks5 directory) and server(under root directory)
  • Support TCP/UDP and IPv4/IPv6
  • Unit tests
  • "No Auth" mode
  • User/Password authentication optional user addr limit
  • Support for the CONNECT command
  • Support for the ASSOCIATE command
  • Rules to do granular filtering of commands
  • Custom DNS resolution
  • Custom goroutine pool
  • buffer pool design and optional custom buffer pool
  • Custom logger

TODO

The package still needs the following:

  • Support for the BIND command

Installation

Use go get.

    go get github.com/thinkgos/go-socks5

Then import the socks5 server package into your own code.

    import modbus "github.com/thinkgos/go-socks5"

or

import the socks5 client package into your own code.

    import modbus "github.com/thinkgos/go-socks5/ccsocks5"

Example

Below is a simple example of usage

    // Server: 

    // Create a SOCKS5 server
    server := socks5.NewServer()
    
    // Create SOCKS5 proxy on localhost port 8000
    if err := server.ListenAndServe("tcp", ":8000"); err != nil {
      panic(err)
    }
   // Client: 
	client := ccsocks5.NewClient(
		"127.0.0.1:10800",
		ccsocks5.WithKeepAlivePeriod(time.Second*30),
	)
	conn, err := client.Dial("tcp", "127.0.0.1:12345") // server you want to visitor
	if err != nil {
		panic(err)
	}
	conn.Write([]byte("hahaha"))
	time.Sleep(time.Second)

Reference