2020-08-06 08:55:32 +00:00
|
|
|
# go-socks5
|
2014-01-22 23:49:51 +00:00
|
|
|
|
2020-08-10 00:41:33 +00:00
|
|
|
[![GoDoc](https://godoc.org/github.com/thinkgos/go-socks5?status.svg)](https://godoc.org/github.com/thinkgos/go-socks5)
|
2020-08-06 03:11:30 +00:00
|
|
|
[![Go.Dev reference](https://img.shields.io/badge/go.dev-reference-blue?logo=go&logoColor=white)](https://pkg.go.dev/github.com/thinkgos/go-socks5?tab=doc)
|
2020-08-10 00:41:33 +00:00
|
|
|
[![Build Status](https://travis-ci.org/thinkgos/go-socks5.svg?branch=master)](https://travis-ci.org/thinkgos/go-socks5)
|
2020-04-19 09:11:00 +00:00
|
|
|
![Action Status](https://github.com/thinkgos/go-socks5/workflows/Go/badge.svg)
|
2020-08-10 00:41:33 +00:00
|
|
|
[![codecov](https://codecov.io/gh/thinkgos/go-socks5/branch/master/graph/badge.svg)](https://codecov.io/gh/thinkgos/go-socks5)
|
2020-04-19 09:11:00 +00:00
|
|
|
[![Go Report Card](https://goreportcard.com/badge/github.com/thinkgos/go-socks5)](https://goreportcard.com/report/github.com/thinkgos/go-socks5)
|
|
|
|
[![License](https://img.shields.io/github/license/thinkgos/go-socks5)](https://github.com/thinkgos/go-socks5/raw/master/LICENSE)
|
2020-08-06 03:11:30 +00:00
|
|
|
[![Tag](https://img.shields.io/github/v/tag/thinkgos/go-socks5)](https://github.com/thinkgos/go-socks5/tags)
|
2020-04-19 09:08:22 +00:00
|
|
|
|
2020-08-06 07:59:48 +00:00
|
|
|
Provides the `socks5` package that implements a [SOCKS5](http://en.wikipedia.org/wiki/SOCKS).
|
2014-01-23 22:22:07 +00:00
|
|
|
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.
|
|
|
|
|
2020-08-06 08:55:32 +00:00
|
|
|
### Feature
|
|
|
|
|
2014-01-23 22:22:07 +00:00
|
|
|
|
|
|
|
The package has the following features:
|
2020-08-06 07:59:48 +00:00
|
|
|
- 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
|
2014-01-23 22:22:07 +00:00
|
|
|
|
2020-08-06 08:55:32 +00:00
|
|
|
### TODO
|
2014-01-23 22:22:07 +00:00
|
|
|
|
|
|
|
The package still needs the following:
|
2020-08-06 07:59:48 +00:00
|
|
|
- Support for the BIND command
|
2014-06-27 05:39:00 +00:00
|
|
|
|
2020-08-06 08:55:32 +00:00
|
|
|
### Installation
|
|
|
|
|
|
|
|
Use go get.
|
|
|
|
```bash
|
|
|
|
go get github.com/thinkgos/go-socks5
|
|
|
|
```
|
|
|
|
|
|
|
|
Then import the socks5 server package into your own code.
|
|
|
|
|
|
|
|
```bash
|
2020-08-07 00:19:08 +00:00
|
|
|
import "github.com/thinkgos/go-socks5"
|
2020-08-06 08:55:32 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
import the socks5 client package into your own code.
|
|
|
|
|
|
|
|
```bash
|
2020-08-07 00:19:08 +00:00
|
|
|
import "github.com/thinkgos/go-socks5/ccsocks5"
|
2020-08-06 08:55:32 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Example
|
2014-06-27 05:39:00 +00:00
|
|
|
|
2020-08-07 00:19:08 +00:00
|
|
|
Below is a simple example of usage, more see [example](https://github.com/thinkgos/go-socks5/tree/master/_example)
|
2014-06-27 05:39:00 +00:00
|
|
|
|
2020-08-06 08:55:32 +00:00
|
|
|
|
2014-06-27 05:39:00 +00:00
|
|
|
```go
|
2020-08-06 08:55:32 +00:00
|
|
|
// Server:
|
2014-06-27 05:39:00 +00:00
|
|
|
|
2020-08-06 08:55:32 +00:00
|
|
|
// Create a SOCKS5 server
|
|
|
|
server := socks5.NewServer()
|
|
|
|
|
|
|
|
// Create SOCKS5 proxy on localhost port 8000
|
|
|
|
if err := server.ListenAndServe("tcp", ":8000"); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
```go
|
|
|
|
// Client:
|
2020-08-07 00:22:39 +00:00
|
|
|
client := ccsocks5.NewClient("127.0.0.1:10800")
|
2020-08-07 00:19:08 +00:00
|
|
|
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)
|
2014-06-27 05:39:00 +00:00
|
|
|
```
|
|
|
|
|
2020-08-06 08:55:32 +00:00
|
|
|
### Reference
|
2020-08-05 02:34:29 +00:00
|
|
|
- [rfc1928](https://www.ietf.org/rfc/rfc1928.txt)
|
2020-08-06 03:11:30 +00:00
|
|
|
- original armon [go-sock5](https://github.com/armon/go-socks5)
|