Documentation
¶
Index ¶
- Constants
- Variables
- func DebugLog(format string, args ...interface{})
- func ErrorLog(format string, args ...interface{})
- func InfoLog(format string, args ...interface{})
- func SetLogLevel(l int)
- func WarnLog(format string, args ...interface{})
- type BalancedDialer
- func (b *BalancedDialer) AddDialer(dialers ...Dialer)
- func (b *BalancedDialer) AddFilter(matcher string, access int) (err error)
- func (b *BalancedDialer) AddPolicy(matcher string, limit []int64) (err error)
- func (b *BalancedDialer) Bootstrap(options xmap.M) (err error)
- func (b *BalancedDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (r Conn, err error)
- func (b *BalancedDialer) Matched(uri string) bool
- func (b *BalancedDialer) Name() string
- func (b *BalancedDialer) Options() xmap.M
- func (b *BalancedDialer) Shutdown() (err error)
- type BalancedFilter
- type BalancedPolicy
- type Channel
- type CodeError
- type Conn
- type CopyPipable
- type Dialer
- type DuplexPiped
- type EchoDialer
- func (e *EchoDialer) Bootstrap(options xmap.M) error
- func (e *EchoDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (r Conn, err error)
- func (e *EchoDialer) Matched(uri string) bool
- func (e *EchoDialer) Name() string
- func (e *EchoDialer) Options() xmap.M
- func (e *EchoDialer) Shutdown() (err error)
- type EchoReadWriteCloser
- type MapIntSorter
- type Pipable
- type PipedConn
- type Pool
- type SchemaDialer
- func (t *SchemaDialer) Bootstrap(options xmap.M) error
- func (t *SchemaDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)
- func (t *SchemaDialer) Matched(uri string) bool
- func (t *SchemaDialer) Name() string
- func (t *SchemaDialer) Options() xmap.M
- func (t *SchemaDialer) Shutdown() (err error)
- func (t *SchemaDialer) String() string
- type SocksProxyAddressPooler
- type SocksProxyDialer
- func (s *SocksProxyDialer) Bootstrap(options xmap.M) (err error)
- func (s *SocksProxyDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)
- func (s *SocksProxyDialer) Matched(uri string) bool
- func (s *SocksProxyDialer) Name() string
- func (s *SocksProxyDialer) Options() xmap.M
- func (s *SocksProxyDialer) Shutdown() (err error)
- func (s *SocksProxyDialer) String() string
- type Statable
- type StateBuffer
- type StateDialer
- func (s *StateDialer) Bootstrap(options xmap.M) error
- func (s *StateDialer) Dial(channel Channel, sid uint64, uri string, raw io.ReadWriteCloser) (conn Conn, err error)
- func (s *StateDialer) Matched(uri string) bool
- func (s *StateDialer) Name() string
- func (s *StateDialer) Options() xmap.M
- func (s *StateDialer) Shutdown() (err error)
- type StringAddressPooler
- type TCPDialer
- func (t *TCPDialer) Bootstrap(options xmap.M) error
- func (t *TCPDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)
- func (t *TCPDialer) Matched(uri string) bool
- func (t *TCPDialer) Name() string
- func (t *TCPDialer) Options() xmap.M
- func (t *TCPDialer) Shutdown() (err error)
- func (t *TCPDialer) String() string
- type WebDialer
- func (web *WebDialer) Accept() (conn net.Conn, err error)
- func (web *WebDialer) Addr() net.Addr
- func (web *WebDialer) Bootstrap(options xmap.M) error
- func (web *WebDialer) Close() error
- func (web *WebDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)
- func (web *WebDialer) FindChannelByRequest(req *http.Request) (channel Channel, err error)
- func (web *WebDialer) FindConnByID(sid string) (conn *WebDialerConn, err error)
- func (web *WebDialer) FindConnByRequest(req *http.Request) (conn *WebDialerConn, err error)
- func (web *WebDialer) Matched(uri string) bool
- func (web *WebDialer) Name() string
- func (web *WebDialer) Network() string
- func (web *WebDialer) Options() xmap.M
- func (web *WebDialer) Shutdown() error
- func (web *WebDialer) String() string
- type WebDialerAddr
- type WebDialerConn
- type WebdavFileHandler
- type WebdavHandler
Constants ¶
const ( //LogLevelDebug is debug log level LogLevelDebug = 40 //LogLevelInfo is info log level LogLevelInfo = 30 //LogLevelWarn is warn log level LogLevelWarn = 20 //LogLevelError is error log level LogLevelError = 10 )
Variables ¶
var LogLevel = LogLevelInfo
LogLevel is log leveo config
var Logger = log.New(os.Stdout, "", log.Ldate|log.Lmicroseconds|log.Lshortfile)
Logger is the bsck package default log
var NewDialer = DefaultDialerCreator
NewDialer is default all dialer creator
Functions ¶
Types ¶
type BalancedDialer ¶
type BalancedDialer struct {
ID string
PolicyList []*BalancedPolicy
Filters []*BalancedFilter
Delay int64
Timeout int64
Conf xmap.M
// contains filtered or unexported fields
}
func NewBalancedDialer ¶
func NewBalancedDialer() *BalancedDialer
func (*BalancedDialer) AddDialer ¶
func (b *BalancedDialer) AddDialer(dialers ...Dialer)
func (*BalancedDialer) AddFilter ¶
func (b *BalancedDialer) AddFilter(matcher string, access int) (err error)
func (*BalancedDialer) AddPolicy ¶
func (b *BalancedDialer) AddPolicy(matcher string, limit []int64) (err error)
func (*BalancedDialer) Bootstrap ¶
func (b *BalancedDialer) Bootstrap(options xmap.M) (err error)
initial dialer
func (*BalancedDialer) Dial ¶
func (b *BalancedDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (r Conn, err error)
func (*BalancedDialer) Name ¶
func (b *BalancedDialer) Name() string
func (*BalancedDialer) Shutdown ¶
func (b *BalancedDialer) Shutdown() (err error)
Shutdown will shutdown dial
type BalancedFilter ¶
type BalancedPolicy ¶
type Conn ¶
type Conn interface {
Pipable
io.ReadWriteCloser
}
type CopyPipable ¶
type CopyPipable struct {
io.ReadWriteCloser
// contains filtered or unexported fields
}
func NewCopyPipable ¶
func NewCopyPipable(raw io.ReadWriteCloser) *CopyPipable
func (*CopyPipable) Pipe ¶
func (c *CopyPipable) Pipe(r io.ReadWriteCloser) (err error)
func (*CopyPipable) String ¶
func (c *CopyPipable) String() string
type Dialer ¶
type Dialer interface {
Name() string
//initial dialer
Bootstrap(options xmap.M) error
//shutdown
Shutdown() error
//
Options() xmap.M
//match uri
Matched(uri string) bool
//dial raw connection
Dial(channel Channel, sid uint64, uri string, raw io.ReadWriteCloser) (r Conn, err error)
}
Dialer is the interface that wraps the dialer
func DefaultDialerCreator ¶
DefaultDialerCreator is default all dialer creator
type DuplexPiped ¶
type DuplexPiped struct {
UpReader *os.File
UpWriter *os.File
DownReader *os.File
DownWriter *os.File
// contains filtered or unexported fields
}
func (*DuplexPiped) Close ¶
func (d *DuplexPiped) Close() error
type EchoDialer ¶
type EchoDialer struct {
// contains filtered or unexported fields
}
EchoDialer is an implementation of the Dialer interface for echo tcp connection.
func NewEchoDialer ¶
func NewEchoDialer() (dialer *EchoDialer)
NewEchoDialer will return new EchoDialer
func (*EchoDialer) Bootstrap ¶
func (e *EchoDialer) Bootstrap(options xmap.M) error
Bootstrap the dialer
func (*EchoDialer) Dial ¶
func (e *EchoDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (r Conn, err error)
Dial one echo connection.
func (*EchoDialer) Matched ¶
func (e *EchoDialer) Matched(uri string) bool
Matched will return whetheer uri is invalid
func (*EchoDialer) Shutdown ¶
func (e *EchoDialer) Shutdown() (err error)
Shutdown will shutdown dial
type EchoReadWriteCloser ¶
EchoReadWriteCloser is an implementation of the io.ReadWriteCloser interface for pipe write to read.
func NewEchoReadWriteCloser ¶
func NewEchoReadWriteCloser() *EchoReadWriteCloser
NewEchoReadWriteCloser will return new EchoReadWriteCloser
func (*EchoReadWriteCloser) Pipe ¶
func (e *EchoReadWriteCloser) Pipe(raw io.ReadWriteCloser) (err error)
Pipe is Pipable implment
func (*EchoReadWriteCloser) String ¶
func (e *EchoReadWriteCloser) String() string
type MapIntSorter ¶
func NewMapIntSorter ¶
func NewMapIntSorter(data map[string][]int64, index int) *MapIntSorter
func (*MapIntSorter) Len ¶
func (m *MapIntSorter) Len() int
func (*MapIntSorter) Less ¶
func (m *MapIntSorter) Less(i, j int) bool
func (*MapIntSorter) Swap ¶
func (m *MapIntSorter) Swap(i, j int)
type Pipable ¶
type Pipable interface {
Pipe(r io.ReadWriteCloser) error
}
type PipedConn ¶
PipedConn is an implementation of the net.Conn interface for piped two connection.
func CreatePipedConn ¶
CreatePipedConn will return two piped connection.
type Pool ¶
type Pool struct {
Name string
Dialers []Dialer
Webs map[string]http.Handler
// contains filtered or unexported fields
}
Pool is the set of Dialer
type SchemaDialer ¶
type SchemaDialer struct {
// contains filtered or unexported fields
}
SchemaDialer is an implementation of the Dialer interface for dial tcp connections.
func NewSchemaDialer ¶
func NewSchemaDialer() *SchemaDialer
NewSchemaDialer will return new SchemaDialer
func (*SchemaDialer) Bootstrap ¶
func (t *SchemaDialer) Bootstrap(options xmap.M) error
Bootstrap the dialer.
func (*SchemaDialer) Dial ¶
func (t *SchemaDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)
Dial one connection by uri
func (*SchemaDialer) Matched ¶
func (t *SchemaDialer) Matched(uri string) bool
Matched will return whether the uri is invalid tcp uri.
func (*SchemaDialer) Shutdown ¶
func (t *SchemaDialer) Shutdown() (err error)
Shutdown will shutdown dial
func (*SchemaDialer) String ¶
func (t *SchemaDialer) String() string
type SocksProxyAddressPooler ¶
type SocksProxyAddressPooler interface {
//Get will return the proxy server address
Get(uri string) (address string, err error)
//Done will mark one address is free
Done(address, uri string, err error)
}
SocksProxyAddressPooler is an interface to handler proxy server address get/set
type SocksProxyDialer ¶
type SocksProxyDialer struct {
ID string
Pooler SocksProxyAddressPooler
// contains filtered or unexported fields
}
SocksProxyDialer is an implementation of the Dialer interface for dial by socks proxy.
func NewSocksProxyDialer ¶
func NewSocksProxyDialer() *SocksProxyDialer
NewSocksProxyDialer will return new SocksProxyDialer
func (*SocksProxyDialer) Bootstrap ¶
func (s *SocksProxyDialer) Bootstrap(options xmap.M) (err error)
Bootstrap the dialer.
func (*SocksProxyDialer) Dial ¶
func (s *SocksProxyDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)
Dial one connection by uri
func (*SocksProxyDialer) Matched ¶
func (s *SocksProxyDialer) Matched(uri string) bool
Matched will return whether the uri is invalid tcp uri.
func (*SocksProxyDialer) Name ¶
func (s *SocksProxyDialer) Name() string
Name will return dialer name
func (*SocksProxyDialer) Options ¶
func (s *SocksProxyDialer) Options() xmap.M
Options is options getter
func (*SocksProxyDialer) Shutdown ¶
func (s *SocksProxyDialer) Shutdown() (err error)
Shutdown will shutdown dial
func (*SocksProxyDialer) String ¶
func (s *SocksProxyDialer) String() string
type StateBuffer ¶
type StateBuffer struct {
// contains filtered or unexported fields
}
StateBuffer is an io.ReadWriteCloser by read from bytes.Buffer and write discard
func NewStateBuffer ¶
func NewStateBuffer(alias string, buf *bytes.Buffer) *StateBuffer
NewStateBuffer is the default creator by buffer.
func (*StateBuffer) String ¶
func (s *StateBuffer) String() string
type StateDialer ¶
StateDialer is an impl of dialer.Dialer for get router status
func NewStateDialer ¶
func NewStateDialer(alias string, s Statable) *StateDialer
NewStateDialer is the default creator by router.
func (*StateDialer) Bootstrap ¶
func (s *StateDialer) Bootstrap(options xmap.M) error
Bootstrap the dialer by configure
func (*StateDialer) Dial ¶
func (s *StateDialer) Dial(channel Channel, sid uint64, uri string, raw io.ReadWriteCloser) (conn Conn, err error)
Dial raw connection
func (*StateDialer) Matched ¶
func (s *StateDialer) Matched(uri string) bool
Matched return if uri is supported for this dialer.
func (*StateDialer) Options ¶
func (s *StateDialer) Options() xmap.M
Options return the current configure of dialer.
func (*StateDialer) Shutdown ¶
func (s *StateDialer) Shutdown() (err error)
Shutdown will shutdown dial
type StringAddressPooler ¶
type StringAddressPooler string
StringAddressPooler is an implementation of the SocksProxyAddressPooler interface for one string address.
func (StringAddressPooler) Done ¶
func (s StringAddressPooler) Done(address, uri string, err error)
Done will mark one address is fress
type TCPDialer ¶
type TCPDialer struct {
// contains filtered or unexported fields
}
TCPDialer is an implementation of the Dialer interface for dial tcp connections.
func (*TCPDialer) Dial ¶
func (t *TCPDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)
Dial one connection by uri
type WebDialer ¶
WebDialer is an implementation of the Dialer interface for dial to web server
func NewWebDialer ¶
NewWebDialer will return new WebDialer
func (*WebDialer) Dial ¶
func (web *WebDialer) Dial(channel Channel, sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)
Dial to web server
func (*WebDialer) FindChannelByRequest ¶
FindConnByRequest will find connection by id
func (*WebDialer) FindConnByID ¶
func (web *WebDialer) FindConnByID(sid string) (conn *WebDialerConn, err error)
FindConnByID will find connection by id
func (*WebDialer) FindConnByRequest ¶
func (web *WebDialer) FindConnByRequest(req *http.Request) (conn *WebDialerConn, err error)
FindConnByRequest will find connection by id
type WebDialerAddr ¶
WebDialerAddr is net.Addr implement
func NewWebDialerAddr ¶
func NewWebDialerAddr(net, info string) (addr *WebDialerAddr)
NewWebDialerAddr will return new web dialer address
func (*WebDialerAddr) Network ¶
func (w *WebDialerAddr) Network() string
Network return WebDialerConn
type WebDialerConn ¶
type WebDialerConn struct {
*PipedConn //the piped connection
Channel Channel
SID uint64 //session id
URI string //target uri
}
WebDialerConn is an implementation of the net.Conn interface for pipe WebDialerConn to raw connection.
func PipeWebDialerConn ¶
func PipeWebDialerConn(channel Channel, sid uint64, uri string) (conn *WebDialerConn, raw io.ReadWriteCloser, err error)
PipeWebDialerConn will return new WebDialerConn and piped raw connection.
func (*WebDialerConn) LocalAddr ¶
func (w *WebDialerConn) LocalAddr() net.Addr
LocalAddr return self
func (*WebDialerConn) Network ¶
func (w *WebDialerConn) Network() string
Network return WebDialerConn
func (*WebDialerConn) RemoteAddr ¶
func (w *WebDialerConn) RemoteAddr() net.Addr
RemoteAddr return self
type WebdavFileHandler ¶
type WebdavFileHandler struct {
// contains filtered or unexported fields
}
WebdavFileHandler is an implementation of the http.Handler interface for handling web GET/DAV
func NewWebdavFileHandler ¶
func NewWebdavFileHandler(dir string) *WebdavFileHandler
NewWebdavFileHandler will return new WebdavHandler
func (*WebdavFileHandler) ServeHTTP ¶
func (w *WebdavFileHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)
type WebdavHandler ¶
type WebdavHandler struct {
// contains filtered or unexported fields
}
WebdavHandler is webdav handler
func NewWebdavHandler ¶
func NewWebdavHandler(dirs xmap.M) (handler *WebdavHandler)
NewWebdavHandler will return new WebdavHandler
func (*WebdavHandler) ServeHTTP ¶
func (web *WebdavHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)