dialer

package module
v0.0.0-...-0e6b877 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2018 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CtrlC = []byte{255, 244, 255, 253, 6}
View Source
var TelnetCtrlC = []byte{255, 244, 255, 253, 6}

TelnetCtrlC is the ctrl-c command on telnet

Functions

func GetFileWinSize

func GetFileWinSize(t *os.File) (rows, cols int, err error)

func GetWindowRect

func GetWindowRect(ws *WinSize, fd uintptr) error

func SetFileWinSize

func SetFileWinSize(t *os.File, rows, cols int) (err error)

func SetWindowRect

func SetWindowRect(ws *WinSize, fd uintptr) error

Types

type BalancedDialer

type BalancedDialer struct {
	ID string

	PolicyList []*BalancedPolicy
	Filters    []*BalancedFilter
	Delay      int64
	Timeout    int64
	Conf       util.Map
	// 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 util.Map) (err error)

initial dialer

func (*BalancedDialer) Dial

func (b *BalancedDialer) Dial(sid uint64, uri string, pipe io.ReadWriteCloser) (r Conn, err error)

func (*BalancedDialer) Matched

func (b *BalancedDialer) Matched(uri string) bool

Matched uri

func (*BalancedDialer) Name

func (b *BalancedDialer) Name() string

func (*BalancedDialer) Options

func (b *BalancedDialer) Options() util.Map

Options

type BalancedFilter

type BalancedFilter struct {
	Matcher *regexp.Regexp
	Access  int
}

type BalancedPolicy

type BalancedPolicy struct {
	Matcher *regexp.Regexp
	Scope   string
	Limit   []int64
}

type Cmd

type Cmd struct {
	Raw  *exec.Cmd
	Dir  string
	Name string
	PS1  string

	Prefix io.Reader
	OnExit func(err error)
	Rows   int
	Cols   int
	// contains filtered or unexported fields
}

func NewCmd

func NewCmd(name, ps1, shell string, args ...string) (cmd *Cmd)

func (*Cmd) AddEnvf

func (c *Cmd) AddEnvf(format string, args ...interface{})

func (*Cmd) Close

func (c *Cmd) Close() error

Close the command.

func (*Cmd) Read

func (c *Cmd) Read(p []byte) (n int, err error)

func (*Cmd) Start

func (c *Cmd) Start() (err error)

func (*Cmd) Write

func (c *Cmd) Write(p []byte) (n int, err error)

type CmdDialer

type CmdDialer struct {
	Replace    []byte
	CloseTag   []byte
	PS1        string
	Dir        string
	LC         string
	Prefix     string
	Env        []string
	Reuse      int64
	ReuseDelay time.Duration
	// contains filtered or unexported fields
}

CmdDialer is an implementation of the Dialer interface for dial command

func NewCmdDialer

func NewCmdDialer() *CmdDialer

NewCmdDialer will return new CmdDialer

func (*CmdDialer) Bootstrap

func (c *CmdDialer) Bootstrap(options util.Map) error

Bootstrap the dilaer

func (*CmdDialer) Dial

func (c *CmdDialer) Dial(sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)

Dial will start command and pipe to stdin/stdout

func (*CmdDialer) Matched

func (c *CmdDialer) Matched(uri string) bool

Matched will return wheter uri is invalid uril.

func (*CmdDialer) Name

func (c *CmdDialer) Name() string

Name will return dialer name

func (*CmdDialer) Options

func (c *CmdDialer) Options() util.Map

func (*CmdDialer) Shutdown

func (c *CmdDialer) Shutdown() (err error)

Shutdown the dialer

func (*CmdDialer) String

func (c *CmdDialer) String() string

type CmdStdinWriter

type CmdStdinWriter struct {
	io.Writer
	Replace  []byte
	CloseTag []byte
}

CmdStdinWriter is writer to handler charset replace and close command.

func NewCmdStdinWriter

func NewCmdStdinWriter(w io.Writer, replace, closeTag []byte) (writer *CmdStdinWriter)

func (*CmdStdinWriter) Write

func (c *CmdStdinWriter) Write(p []byte) (n int, err error)

type CodeError

type CodeError struct {
	Inner    error
	ByteCode byte
}

func (*CodeError) Code

func (c *CodeError) Code() byte

func (*CodeError) Error

func (c *CodeError) Error() string

type CombinedRWC

type CombinedRWC struct {
	io.Reader
	io.Writer
	Closer func() error
	// contains filtered or unexported fields
}

CombinedRWC is an implementation of io.ReadWriteClose to combined reader/writer/closer

func (*CombinedRWC) Close

func (c *CombinedRWC) Close() (err error)

Close will call closer only once

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)

type Dialer

type Dialer interface {
	Name() string
	//initial dialer
	Bootstrap(options util.Map) error
	//
	Options() util.Map
	//match uri
	Matched(uri string) bool
	//dial raw connection
	Dial(sid uint64, uri string, raw io.ReadWriteCloser) (r Conn, err error)
}

Dialer is the interface that wraps the dialer

func DefaultDialerCreator

func DefaultDialerCreator(t string) (dialer Dialer)

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 util.Map) error

Bootstrap the dialer

func (*EchoDialer) Dial

func (e *EchoDialer) Dial(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) Name

func (e *EchoDialer) Name() string

Name will return dialer name

func (*EchoDialer) Options

func (e *EchoDialer) Options() util.Map

type EchoReadWriteCloser

type EchoReadWriteCloser struct {
	// contains filtered or unexported fields
}

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) Close

func (e *EchoReadWriteCloser) Close() (err error)

Close echo read writer closer.

func (*EchoReadWriteCloser) Pipe

func (e *EchoReadWriteCloser) Pipe(raw io.ReadWriteCloser) (err error)

func (*EchoReadWriteCloser) Read

func (e *EchoReadWriteCloser) Read(p []byte) (n int, err error)

func (*EchoReadWriteCloser) Write

func (e *EchoReadWriteCloser) Write(p []byte) (n int, err error)

type MapIntSorter

type MapIntSorter struct {
	List  []string
	Data  map[string][]int64
	Index int
}

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

type PipedConn struct {
	// contains filtered or unexported fields
}

PipedConn is an implementation of the net.Conn interface for piped two connection.

func CreatePipedConn

func CreatePipedConn() (a, b *PipedConn, err error)

CreatePipedConn will return two piped connection.

func (*PipedConn) Close

func (p *PipedConn) Close() error

Close the piped connection

func (*PipedConn) LocalAddr

func (p *PipedConn) LocalAddr() net.Addr

LocalAddr return self

func (*PipedConn) Network

func (p *PipedConn) Network() string

Network return "piped"

func (*PipedConn) Read

func (p *PipedConn) Read(b []byte) (n int, err error)

func (*PipedConn) RemoteAddr

func (p *PipedConn) RemoteAddr() net.Addr

RemoteAddr return self

func (*PipedConn) SetDeadline

func (p *PipedConn) SetDeadline(t time.Time) error

SetDeadline is empty

func (*PipedConn) SetReadDeadline

func (p *PipedConn) SetReadDeadline(t time.Time) error

SetReadDeadline is empty

func (*PipedConn) SetWriteDeadline

func (p *PipedConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline is empty

func (*PipedConn) String

func (p *PipedConn) String() string

func (*PipedConn) Write

func (p *PipedConn) Write(b []byte) (n int, err error)

type Pool

type Pool struct {
	Dialers []Dialer
}

Pool is the set of Dialer

func NewPool

func NewPool() (pool *Pool)

NewPool will return new Pool

func (*Pool) AddDialer

func (p *Pool) AddDialer(dialers ...Dialer) (err error)

AddDialer will append dialer which is bootstraped to pool

func (*Pool) Bootstrap

func (p *Pool) Bootstrap(options util.Map) error

func (*Pool) Dial

func (p *Pool) Dial(sid uint64, uri string, pipe io.ReadWriteCloser) (r Conn, err error)

Dial the uri by dialer poo

type ReusableRWC

type ReusableRWC struct {
	Raw io.ReadWriteCloser

	Name     string
	Reused   bool
	Last     int64
	OnPaused func(r *ReusableRWC)
	// contains filtered or unexported fields
}

ReusableRWC

func NewReusableRWC

func NewReusableRWC(raw io.ReadWriteCloser) (reusable *ReusableRWC)

func (*ReusableRWC) Close

func (r *ReusableRWC) Close() (err error)

func (*ReusableRWC) Destory

func (r *ReusableRWC) Destory() (err error)

func (*ReusableRWC) Pipe

func (r *ReusableRWC) Pipe(raw io.ReadWriteCloser) (err error)

func (*ReusableRWC) Read

func (r *ReusableRWC) Read(b []byte) (n int, err error)

func (*ReusableRWC) Resume

func (r *ReusableRWC) Resume() (err error)

func (*ReusableRWC) Write

func (r *ReusableRWC) Write(p []byte) (n int, err error)

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 util.Map) (err error)

Bootstrap the dialer.

func (*SocksProxyDialer) Dial

func (s *SocksProxyDialer) Dial(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() util.Map

func (*SocksProxyDialer) String

func (s *SocksProxyDialer) String() string

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

func (StringAddressPooler) Get

func (s StringAddressPooler) Get(uri string) (address string, err error)

Get will return the proxy server address

type TCPDialer

type TCPDialer struct {
	// contains filtered or unexported fields
}

TCPDialer is an implementation of the Dialer interface for dial tcp connections.

func NewTCPDialer

func NewTCPDialer() *TCPDialer

NewTCPDialer will return new TCPDialer

func (*TCPDialer) Bootstrap

func (t *TCPDialer) Bootstrap(options util.Map) error

Bootstrap the dialer.

func (*TCPDialer) Dial

func (t *TCPDialer) Dial(sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)

Dial one connection by uri

func (*TCPDialer) Matched

func (t *TCPDialer) Matched(uri string) bool

Matched will return whether the uri is invalid tcp uri.

func (*TCPDialer) Name

func (t *TCPDialer) Name() string

Name will return dialer name

func (*TCPDialer) Options

func (t *TCPDialer) Options() util.Map

func (*TCPDialer) String

func (t *TCPDialer) String() string

type WebDialer

type WebDialer struct {
	// contains filtered or unexported fields
}

WebDialer is an implementation of the Dialer interface for dial to web server

func NewWebDialer

func NewWebDialer() (dialer *WebDialer)

NewWebDialer will return new WebDialer

func (*WebDialer) Accept

func (web *WebDialer) Accept() (conn net.Conn, err error)

Accept one connection to process web server.

func (*WebDialer) Addr

func (web *WebDialer) Addr() net.Addr

Addr return the web dialer address, it always return dialer

func (*WebDialer) Bootstrap

func (web *WebDialer) Bootstrap(options util.Map) error

Bootstrap the web dialer

func (*WebDialer) Close

func (web *WebDialer) Close() error

Close is not used

func (*WebDialer) Dial

func (web *WebDialer) Dial(sid uint64, uri string, pipe io.ReadWriteCloser) (raw Conn, err error)

Dial to web server

func (*WebDialer) Matched

func (web *WebDialer) Matched(uri string) bool

Matched will return whether the uri is a invalid uri

func (*WebDialer) Name

func (web *WebDialer) Name() string

Name will return dialer name

func (*WebDialer) Network

func (web *WebDialer) Network() string

Network return "tcp"

func (*WebDialer) Options

func (web *WebDialer) Options() util.Map

func (*WebDialer) ServeHTTP

func (web *WebDialer) ServeHTTP(resp http.ResponseWriter, req *http.Request)

func (*WebDialer) Shutdown

func (web *WebDialer) Shutdown() error

Shutdown the web dialer

func (*WebDialer) String

func (web *WebDialer) String() string

type WebDialerConn

type WebDialerConn struct {
	*PipedConn        //the piped connection
	SID        uint64 //session id
	URI        string //target uri
	DIR        string //work directory
}

WebDialerConn is an implementation of the net.Conn interface for pipe WebDialerConn to raw connection.

func PipeWebDialerConn

func PipeWebDialerConn(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

func (*WebDialerConn) String

func (w *WebDialerConn) String() string

type WebdavHandler

type WebdavHandler struct {
	// contains filtered or unexported fields
}

WebdavHandler is an implementation of the http.Handler interface for handling web GET/DAV

func NewWebdavHandler

func NewWebdavHandler(dir string) *WebdavHandler

NewWebdavHandler will return new WebdavHandler

func (*WebdavHandler) ServeHTTP

func (w *WebdavHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type WinSize

type WinSize struct {
	Row    uint16
	Col    uint16
	PixelX uint16
	PixelY uint16
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL