Documentation ¶
Index ¶
- Constants
- Variables
- func CheckServerCfgDefault(cfg *ServerCfg)
- func CreateClientCfg(path string) error
- func CreateServerCfg(path string) error
- func NewSocks4Client(cfg ClientCfg) *socks4Client
- func NewSocks5Client(cfg ClientCfg) *socks5client
- func Pipe(left Stream, right Stream, timeout time.Duration) error
- type AddrByte
- type ClientCfg
- type Conn
- type ConnCfg
- type MethodSelectReply
- type MethodSelectReq
- type Reply
- type ReplySocks4
- type ReqSocks4
- type Request
- type SenderMap
- type Server
- type ServerCfg
- type Socks4Conn
- type Socks5Conn
- type SocksUDPConn
- type Stream
- type UDPDatagram
- type UserPassAuthReply
- type UserPassAuthReq
Constants ¶
View Source
const ( VerSocks4 = 0x04 VerSocks5 = 0x05 )
View Source
const ( RepSocks4Granted = 0x5a RepSocks4Rejected = 0x5b RepSocks4NoIdentd = 0x5c RepSocks4InvalidUser = 0x5d )
View Source
const ( MethodNone = 0x00 MethodUserPass = 0x02 MethodNoAcceptable = 0xff VerAuthUserPass = 0x01 AuthStatusSuccess = 0x00 AuthStatusFailure = 0x01 CmdConnect = 0x01 CmdBind = 0x02 CmdUDP = 0x03 ATypIPV4 = 0x01 ATypDomainname = 0x03 ATypIPV6 = 0x04 RepSuccess = 0x00 RepServerFailure = 0x01 RepRuleFailure = 0x02 RepNetworkUnreachable = 0x03 RepHostUnreachable = 0x04 RepConnectionRefused = 0x05 RepTTLExpired = 0x06 RepCmdNotSupported = 0x07 RepAddrTypeNotSupported = 0x08 )
View Source
const DefaultListenPort = 1080
View Source
const DefaultLogLevel = "error"
View Source
const DefaultTcpTimeout = 60
View Source
const DefaultUdpTimeout = 60
View Source
const MaxAddrLen = 1 + 1 + 255 + 2
View Source
const MaxSegmentSize = 65535
View Source
const PortLen = 2
View Source
const SocketBufSize = 20480
buf cannot larger than 64k,because of the socket buffer size header is 16bit
Variables ¶
View Source
var ( ErrMethodNoAcceptable = errors.New("no acceptable method") ErrAuthFailed = errors.New("User authentication failed") NoSupportedAuth = errors.New("no supported auth") ErrAuthUserPassVer = errors.New("auth user pass version") ErrCmdNotSupport = errors.New("cmd not support") ErrAddrType = fmt.Errorf("Unrecognized address type") ErrSocksVersion = fmt.Errorf("not socks version 5") ErrMethod = fmt.Errorf("Unsupport method") ErrBadRequest = fmt.Errorf("bad request") ErrUDPFrag = fmt.Errorf("Frag !=0 not supported") )
View Source
var DefaultServerConfig = ServerCfg{ ListenPort: DefaultListenPort, UserName: "", Password: "", UDPTimout: DefaultTcpTimeout, TCPTimeout: DefaultUdpTimeout, UDPAdvertisedIP: "", LogLevel: DefaultLogLevel, }
Functions ¶
func CheckServerCfgDefault ¶
func CheckServerCfgDefault(cfg *ServerCfg)
func CreateClientCfg ¶
func CreateServerCfg ¶
func NewSocks4Client ¶
func NewSocks4Client(cfg ClientCfg) *socks4Client
func NewSocks5Client ¶
func NewSocks5Client(cfg ClientCfg) *socks5client
Types ¶
type MethodSelectReply ¶
func NewMethodSelectReply ¶
func NewMethodSelectReply(method byte) *MethodSelectReply
func NewMethodSelectReplyFrom ¶
func NewMethodSelectReplyFrom(r io.Reader) (*MethodSelectReply, error)
func (*MethodSelectReply) ToBytes ¶
func (p *MethodSelectReply) ToBytes() []byte
type MethodSelectReq ¶
func NewMethodSelectReq ¶
func NewMethodSelectReq(methods []byte) *MethodSelectReq
func NewMethodSelectReqFrom ¶
func NewMethodSelectReqFrom(r io.Reader) (*MethodSelectReq, error)
func (*MethodSelectReq) ToBytes ¶
func (p *MethodSelectReq) ToBytes() []byte
type ReplySocks4 ¶
func NewReplySocks4 ¶
func NewReplySocks4(cd byte, portIp []byte) *ReplySocks4
func NewReplySocks4From ¶
func NewReplySocks4From(r io.Reader) (*ReplySocks4, error)
func (*ReplySocks4) ToBytes ¶
func (p *ReplySocks4) ToBytes() []byte
type ReqSocks4 ¶
type ReqSocks4 struct { Ver byte CD byte //1 connect 2 bind DstPort []byte //2 bytes DstIP []byte UserId []byte HostName []byte }
Ver|CD|DstPort|DstIP|USERID|0|HostName|0
func (*ReqSocks4) PortIPBytes ¶
type Request ¶
type Request struct { Ver byte Cmd byte Rsv byte //0x00 Atyp byte DstAddr []byte DstPort []byte //2 bytes }
func NewRequest ¶
type ServerCfg ¶
type ServerCfg struct { ListenPort int //tcp,udp监听端口,仅当TCPListen或UDPListen无值时有效,监听地址为 0.0.0.0:ListenPort TCPListen string //tcp监听地址 UDPListen string //udp监听地址 UDPAdvertisedIP string //udp的广告IP地址,告诉客户端将UDP数据发往这个ip,默认值为udp监听的本地ip地址 UserName string Password string UDPTimout int TCPTimeout int LogLevel string }
func ReadClientCfg ¶
func ReadOrCreateServerCfg ¶
func ReadServerCfg ¶
type Socks4Conn ¶
type Socks4Conn struct {
// contains filtered or unexported fields
}
func (*Socks4Conn) Handle ¶
func (p *Socks4Conn) Handle() error
type Socks5Conn ¶
type Socks5Conn struct {
// contains filtered or unexported fields
}
func (*Socks5Conn) Handle ¶
func (p *Socks5Conn) Handle() error
func (*Socks5Conn) SetCustomDialTarget ¶ added in v1.0.3
type SocksUDPConn ¶
func (*SocksUDPConn) SetReadDeadline ¶ added in v1.0.4
func (p *SocksUDPConn) SetReadDeadline(t time.Time) error
type UDPDatagram ¶
type UDPDatagram struct { Rsv []byte //0x00,0x00 Frag byte AType byte DstAddr []byte DstPort []byte Data []byte }
func NewUDPDatagram ¶
func NewUDPDatagram(addrByte AddrByte, data []byte) *UDPDatagram
func NewUDPDatagramFromBytes ¶
func NewUDPDatagramFromBytes(b []byte) (*UDPDatagram, error)
func (*UDPDatagram) Address ¶
func (p *UDPDatagram) Address() string
func (*UDPDatagram) ToBytes ¶
func (p *UDPDatagram) ToBytes() []byte
type UserPassAuthReply ¶
func NewUserPassAuthReply ¶
func NewUserPassAuthReply(status byte) *UserPassAuthReply
func NewUserPassAuthReplyFrom ¶
func NewUserPassAuthReplyFrom(r io.Reader) (*UserPassAuthReply, error)
func (*UserPassAuthReply) ToBytes ¶
func (p *UserPassAuthReply) ToBytes() []byte
type UserPassAuthReq ¶
func NewUserPassAuthReq ¶
func NewUserPassAuthReq(username []byte, password []byte) *UserPassAuthReq
func NewUserPassAuthReqFrom ¶
func NewUserPassAuthReqFrom(r io.Reader) (*UserPassAuthReq, error)
func (*UserPassAuthReq) ToBytes ¶
func (p *UserPassAuthReq) ToBytes() []byte
Source Files ¶
Click to show internal directories.
Click to hide internal directories.