• Stars
    star
    641
  • Rank 69,787 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SOCKS Protocol Version 5 Library in Go. Full TCP/UDP and IPv4/IPv6 support

socks5

中文

Go Report Card GoDoc

🗣 News 🩸 Youtube

SOCKS Protocol Version 5 Library.

Full TCP/UDP and IPv4/IPv6 support. Goals: KISS, less is more, small API, code is like the original protocol.

❤️ A project by txthinking.com

Install

$ go get github.com/txthinking/socks5

Struct is like concept in protocol

  • Negotiation:
    • type NegotiationRequest struct
      • func NewNegotiationRequest(methods []byte), in client
      • func (r *NegotiationRequest) WriteTo(w io.Writer), client writes to server
      • func NewNegotiationRequestFrom(r io.Reader), server reads from client
    • type NegotiationReply struct
      • func NewNegotiationReply(method byte), in server
      • func (r *NegotiationReply) WriteTo(w io.Writer), server writes to client
      • func NewNegotiationReplyFrom(r io.Reader), client reads from server
  • User and password negotiation:
    • type UserPassNegotiationRequest struct
      • func NewUserPassNegotiationRequest(username []byte, password []byte), in client
      • func (r *UserPassNegotiationRequest) WriteTo(w io.Writer), client writes to server
      • func NewUserPassNegotiationRequestFrom(r io.Reader), server reads from client
    • type UserPassNegotiationReply struct
      • func NewUserPassNegotiationReply(status byte), in server
      • func (r *UserPassNegotiationReply) WriteTo(w io.Writer), server writes to client
      • func NewUserPassNegotiationReplyFrom(r io.Reader), client reads from server
  • Request:
    • type Request struct
      • func NewRequest(cmd byte, atyp byte, dstaddr []byte, dstport []byte), in client
      • func (r *Request) WriteTo(w io.Writer), client writes to server
      • func NewRequestFrom(r io.Reader), server reads from client
      • After server gets the client's *Request, processes...
  • Reply:
    • type Reply struct
      • func NewReply(rep byte, atyp byte, bndaddr []byte, bndport []byte), in server
      • func (r *Reply) WriteTo(w io.Writer), server writes to client
      • func NewReplyFrom(r io.Reader), client reads from server
  • Datagram:
    • type Datagram struct
      • func NewDatagram(atyp byte, dstaddr []byte, dstport []byte, data []byte)
      • func NewDatagramFromBytes(bb []byte)
      • func (d *Datagram) Bytes()

Advanced API

This can satisfy the classic scenario, and it is still recommended that you choose the above small API to customize for special scenarios.

Server: support both TCP and UDP

  • type Server struct
  • type Handler interface
    • TCPHandle(*Server, *net.TCPConn, *Request) error
    • UDPHandle(*Server, *net.UDPAddr, *Datagram) error

Example:

server, _ := NewClassicServer(addr, ip, username, password, tcpTimeout, udpTimeout)
server.ListenAndServe(Handler)

Client: support both TCP and UDP and return net.Conn

  • type Client struct

Example:

client, _ := socks5.NewClient(server, username, password, tcpTimeout, udpTimeout)
conn, _ := client.Dial(network, addr)

Projects using this library

License

Licensed under The MIT License

More Repositories

1

brook

A cross-platform programmable network tool
Go
14,398
star
2

google-hosts

Google hosts generator
Shell
3,328
star
3

zoro

zoro can help you expose local server to external network. Support both TCP/UDP, of course support HTTP. Zero-Configuration.
Go
1,536
star
4

nami

A clean and tidy decentralized package manager.
Go
301
star
5

tun2brook

Proxy all traffic just one line command. tun2socks, tun2brook. IPv4 and IPv6, TCP and UDP.
Go
266
star
6

blackwhite

https://github.com/txthinking/brook/tree/master/programmable
JavaScript
246
star
7

joker

Joker can turn process into daemon. Zero-Configuration
C
186
star
8

brook-manager

Brook Manager is a Brook management system for medium to large merchants.
HTML
123
star
9

nico

A HTTP3 web server for reverse proxy and single page application, automatically apply for ssl certificate, Zero-Configuration.
Go
112
star
10

bypass

https://github.com/txthinking/brook/tree/master/programmable
JavaScript
94
star
11

Mailer

A lightweight PHP SMTP mail sender
PHP
93
star
12

frank

Frank is a REST API automated testing tool like Postman but in command line. Auto generate markdown API document.
Go
91
star
13

z

z - process manager
Zig
53
star
14

socks5-configurator

Configure your Chrome with socks5 proxy
JavaScript
50
star
15

mad

Generate root CA and derivative certificate for any domains and any IPs.
Go
37
star
16

soso

HTML
26
star
17

crypto

crypto: Encryption, Hash, Encoding Library
Go
26
star
18

mailx

A lightweight SMTP mail library
Go
25
star
19

cloudupload

Upload files to multiple Cloud Storage in parallel. Automatically apply for ssl certificate with your domain.
Go
25
star
20

jb

jb: write script in an easier way than bash
Zig
20
star
21

bash

One-Click Scripts.
JavaScript
19
star
22

wiresharkhelper

https://www.txthinking.com
19
star
23

x

A util library on golang.
Go
17
star
24

runnergroup

RunnerGroup is like sync.WaitGroup, the diffrence is if one task stops, all will be stopped.
Go
16
star
25

sshexec

A command-line tool to execute remote command through ssh
Go
16
star
26

filelink

Upload and download file in command line
JavaScript
15
star
27

hancock

Manage multiple remote servers and execute commands remotely
Go
14
star
28

denobundle

Bundle assets into the binary with deno compile
JavaScript
14
star
29

denolib

A Deno library to keep everything small.
JavaScript
11
star
30

testsocks5

Test TCP and UDP of socks5 server
Shell
10
star
31

httpserver

This is a very simple http static server, sometimes we need it for testing
Shell
9
star
32

shiliew

An encrypted, undetectable, simple business proxy/VPN.
9
star
33

mail-checker

A chrome extension for checking unseen mail count. http://goo.gl/U4XkPR
JavaScript
8
star
34

markdown

markdown converter and documentation generator
JavaScript
7
star
35

coding-principle

建议编码风格
5
star
36

pingpong

TCP & UDP echo but with address
JavaScript
5
star
37

cloudflare

cloudflare cli
Shell
5
star
38

php-multipart-form-data-leak

POC for php multipart form data leak, make cpu full
Go
4
star
39

no-referer-image

A chrome extention for removing referer header when requesting image
JavaScript
3
star
40

codeinstall

HTML
2
star
41

txthinking

https://www.txthinking.com
2
star
42

testbrook

JavaScript
1
star
43

sitemap

Build sitemap.xml
JavaScript
1
star