Documentation
¶
Index ¶
- Constants
- Variables
- func DebugDNS(r *dns.Msg, name string)
- func ParseDnsFrame(f Frame, req *dns.Msg) (addrs []net.IP, err error)
- func ReadString(r io.Reader) (s string, err error)
- func RecvWithTimeout(ch chan uint32, t time.Duration) (errno uint32)
- func WriteString(w io.Writer, s string) (err error)
- type Addr
- type ChanFrameSender
- type Conn
- func (c *Conn) CheckAndSetStatus(old uint8, new uint8) (err error)
- func (c *Conn) Close() (err error)
- func (c *Conn) CloseFrame() error
- func (c *Conn) Final()
- func (c *Conn) GetAddress() (s string)
- func (c *Conn) GetReadBufSize() (n int32)
- func (c *Conn) GetStatusString() (st string)
- func (c *Conn) GetStreamId() uint16
- func (c *Conn) GetWriteBufSize() (n int32)
- func (c *Conn) InConnect(errno uint32) (err error)
- func (c *Conn) InData(ft *FrameData) (err error)
- func (c *Conn) InFin(ft *FrameFin) (err error)
- func (c *Conn) InWnd(ft *FrameWnd) (err error)
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(data []byte) (n int, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SendFrame(f Frame) (err error)
- func (c *Conn) SendSynAndWait() (err error)
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) String() (s string)
- func (c *Conn) Write(data []byte) (n int, err error)
- type ConnSlice
- type Frame
- type FrameAuth
- type FrameBase
- type FrameData
- type FrameDns
- type FrameFin
- type FramePing
- type FrameResult
- type FrameRst
- type FrameSender
- type FrameSpam
- type FrameSyn
- type FrameWnd
- type MsocksServer
- type Queue
- type Session
- func (s *Session) Close() (err error)
- func (s *Session) CloseFrame() error
- func (s *Session) Dial(network, address string) (c *Conn, err error)
- func (s *Session) GetPorts() (ports []*Conn)
- func (s *Session) GetSize() int
- func (s *Session) GetSortedPorts() (ports ConnSlice)
- func (s *Session) LocalAddr() net.Addr
- func (s *Session) LocalPort() int
- func (s *Session) LookupIP(host string) (addrs []net.IP, err error)
- func (s *Session) PutIntoId(id uint16, fs FrameSender) (err error)
- func (s *Session) PutIntoNextId(fs FrameSender) (id uint16, err error)
- func (s *Session) RemoteAddr() net.Addr
- func (s *Session) RemovePort(streamid uint16) (err error)
- func (s *Session) Run()
- func (s *Session) SendFrame(f Frame) (err error)
- func (s *Session) String() string
- type SessionFactory
- type SessionPool
- func (sp *SessionPool) Add(s *Session)
- func (sp *SessionPool) AddSessionFactory(dialer sutils.Dialer, serveraddr, username, password string)
- func (sp *SessionPool) CutAll()
- func (sp *SessionPool) Dial(network, address string) (net.Conn, error)
- func (sp *SessionPool) Get() (sess *Session, err error)
- func (sp *SessionPool) GetSessions() (sessions []*Session)
- func (sp *SessionPool) GetSize() int
- func (sp *SessionPool) LookupIP(host string) (addrs []net.IP, err error)
- func (sp *SessionPool) Remove(s *Session) (err error)
- type SpeedCounter
Constants ¶
View Source
const ( DIAL_RETRY = 2 DIAL_TIMEOUT = 30 AUTH_TIMEOUT = 10 DNS_TIMEOUT = 30 WRITE_TIMEOUT = 60 WINDOWSIZE = 4 * 1024 * 1024 SHRINK_TIME = 3 DEBUGDNS = false )
View Source
const ( ERR_NONE = iota ERR_AUTH ERR_IDEXIST ERR_CONNFAILED ERR_TIMEOUT ERR_CLOSED )
View Source
const ( ST_UNKNOWN = iota ST_SYN_RECV ST_SYN_SENT ST_EST ST_CLOSE_WAIT ST_FIN_WAIT )
View Source
const ( MSG_UNKNOWN = iota MSG_RESULT MSG_AUTH MSG_DATA MSG_SYN MSG_WND MSG_FIN MSG_RST MSG_PING MSG_DNS MSG_SPAM )
Variables ¶
View Source
var ( ErrNoSession = errors.New("session in pool but can't pick one.") ErrSessionNotFound = errors.New("session not found.") ErrAuthFailed = errors.New("auth failed.") ErrAuthTimeout = errors.New("auth timeout %s.") ErrStreamNotExist = errors.New("stream not exist.") ErrQueueClosed = errors.New("queue closed.") ErrUnexpectedPkg = errors.New("unexpected package.") ErrNotSyn = errors.New("frame result in conn which status is not syn.") ErrFinState = errors.New("status not est or fin wait when get fin.") ErrIdExist = errors.New("frame sync stream id exist.") ErrState = errors.New("status error.") ErrUnknownState = errors.New("unknown status.") ErrChanClosed = errors.New("chan closed.") ErrDnsTimeOut = errors.New("dns timeout.") ErrDnsMsgIllegal = errors.New("dns message illegal.") ErrNoDnsServer = errors.New("no proper dns server.") )
Functions ¶
Types ¶
type ChanFrameSender ¶
type ChanFrameSender chan Frame
func CreateChanFrameSender ¶
func CreateChanFrameSender(n int) ChanFrameSender
func (*ChanFrameSender) CloseFrame ¶
func (cfs *ChanFrameSender) CloseFrame() (err error)
func (*ChanFrameSender) RecvWithTimeout ¶
func (cfs *ChanFrameSender) RecvWithTimeout(t time.Duration) (f Frame, err error)
func (*ChanFrameSender) SendFrame ¶
func (cfs *ChanFrameSender) SendFrame(f Frame) (err error)
type Conn ¶
func (*Conn) CloseFrame ¶
func (*Conn) GetAddress ¶
func (*Conn) GetReadBufSize ¶
func (*Conn) GetStatusString ¶
func (*Conn) GetStreamId ¶
func (*Conn) GetWriteBufSize ¶
func (*Conn) RemoteAddr ¶
func (*Conn) SendSynAndWait ¶
type Frame ¶
type Frame interface {
GetStreamid() uint16
GetSize() uint16
Packed() (buf *bytes.Buffer, err error)
Unpack(r io.Reader) error
Debug() string
}
func MakeDnsFrame ¶
type FrameAuth ¶
func NewFrameAuth ¶
type FrameBase ¶
func (*FrameBase) GetStreamid ¶
type FrameDns ¶
func NewFrameDns ¶
type FramePing ¶
type FramePing struct {
FrameBase
}
func NewFramePing ¶
func NewFramePing() (f *FramePing)
type FrameResult ¶
func NewFrameResult ¶
func NewFrameResult(streamid uint16, errno uint32) (f *FrameResult)
type FrameSender ¶
type FrameSyn ¶
func NewFrameSyn ¶
type FrameWnd ¶
func NewFrameWnd ¶
type MsocksServer ¶
type MsocksServer struct {
*SessionPool
// contains filtered or unexported fields
}
func (*MsocksServer) Handler ¶
func (ms *MsocksServer) Handler(conn net.Conn)
func (*MsocksServer) OnAuth ¶
func (ms *MsocksServer) OnAuth(stream io.ReadWriteCloser) (err error)
type Session ¶
type Session struct {
Readcnt *SpeedCounter
Writecnt *SpeedCounter
// contains filtered or unexported fields
}
func NewSession ¶
func (*Session) CloseFrame ¶
func (*Session) GetSortedPorts ¶
func (*Session) PutIntoNextId ¶
func (s *Session) PutIntoNextId(fs FrameSender) (id uint16, err error)
func (*Session) RemoteAddr ¶
func (*Session) RemovePort ¶
type SessionFactory ¶
func (*SessionFactory) CreateSession ¶
func (sf *SessionFactory) CreateSession() (s *Session, err error)
type SessionPool ¶
func CreateSessionPool ¶
func CreateSessionPool(MinSess, MaxConn int) (sp *SessionPool)
func (*SessionPool) Add ¶
func (sp *SessionPool) Add(s *Session)
func (*SessionPool) AddSessionFactory ¶
func (sp *SessionPool) AddSessionFactory(dialer sutils.Dialer, serveraddr, username, password string)
func (*SessionPool) CutAll ¶
func (sp *SessionPool) CutAll()
func (*SessionPool) Get ¶
func (sp *SessionPool) Get() (sess *Session, err error)
func (*SessionPool) GetSessions ¶
func (sp *SessionPool) GetSessions() (sessions []*Session)
func (*SessionPool) GetSize ¶
func (sp *SessionPool) GetSize() int
func (*SessionPool) LookupIP ¶
func (sp *SessionPool) LookupIP(host string) (addrs []net.IP, err error)
func (*SessionPool) Remove ¶
func (sp *SessionPool) Remove(s *Session) (err error)
type SpeedCounter ¶
func NewSpeedCounter ¶
func NewSpeedCounter() (sc *SpeedCounter)
func (*SpeedCounter) Add ¶
func (sc *SpeedCounter) Add(s uint32) uint32
func (*SpeedCounter) Close ¶
func (sc *SpeedCounter) Close() error
func (*SpeedCounter) Update ¶
func (sc *SpeedCounter) Update()
Click to show internal directories.
Click to hide internal directories.