add protocol data format

master
Dingjun 8 years ago
parent a05b5b5ab9
commit f624794388

@ -3,6 +3,7 @@ socks-go
A socks server implemented by golang, support socks4/4a, socks5. A socks server implemented by golang, support socks4/4a, socks5.
Only support connect command now.
usage usage
==== ====

@ -8,6 +8,29 @@ import (
"net" "net"
) )
/*
socks4 protocol
request
byte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ... |
|0x04|cmd| port | ip | user\0 |
reply
byte | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7|
|0x00|status| | |
socks4a protocol
request
byte | 0 | 1 | 2 | 3 |4 | 5 | 6 | 7 | 8 | ... |... |
|0x04|cmd| port | 0.0.0.x | user\0 |domain\0|
reply
byte | 0 | 1 | 2 | 3 | 4 | 5 | 6| 7 |
|0x00|staus| port | ip |
*/
type socks4Conn struct { type socks4Conn struct {
serverConn net.Conn serverConn net.Conn
clientConn net.Conn clientConn net.Conn

@ -9,6 +9,31 @@ import (
"encoding/binary" "encoding/binary"
) )
/*
socks5 protocol
initial
byte | 0 | 1 | 2 | ...... | n |
|0x05|num auth| auth methods |
reply
byte | 0 | 1 |
|0x05| auth|
request
byte | 0 | 1 | 2 | 3 | 4 | .. | n-2 | n-1| n |
|0x05|cmd|0x00|addrtype| addr | port |
response
byte |0 | 1 | 2 | 3 | 4 | .. | n-2 | n-1 | n |
|0x05|status|0x00|addrtype| addr | port |
*/
type socks5Conn struct { type socks5Conn struct {
//addr string //addr string
clientConn net.Conn clientConn net.Conn

Loading…
Cancel
Save