diff --git a/README.md b/README.md index c082f37..21329bf 100755 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ socks-go A socks server implemented by golang, support socks4/4a, socks5. +Only support connect command now. usage ==== diff --git a/socks4.go b/socks4.go index 4abbca6..0eeda0d 100644 --- a/socks4.go +++ b/socks4.go @@ -8,6 +8,29 @@ import ( "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 { serverConn net.Conn clientConn net.Conn diff --git a/socks5.go b/socks5.go index cb1b858..d624a4d 100644 --- a/socks5.go +++ b/socks5.go @@ -9,6 +9,31 @@ import ( "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 { //addr string clientConn net.Conn