server

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2019 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultKeepAliveIdleInterval specifies how long connection can be idle
	// before sending keepalive message.
	DefaultKeepAliveIdleInterval = 15 * time.Minute
	// DefaultKeepAliveCount specifies maximal number of keepalive messages
	// sent before marking connection as dead.
	DefaultKeepAliveCount = 8
	// DefaultKeepAliveInterval specifies how often retry sending keepalive
	// messages when no response is received.
	DefaultKeepAliveInterval = 5 * time.Second
)
View Source
var ErrStopIteration = errors.New("stop iteration")

Functions

This section is empty.

Types

type AddrListener

type AddrListener struct {
	AddrS string
	net.Listener
	StrPrefix string
	// contains filtered or unexported fields
}

func (*AddrListener) Close

func (l *AddrListener) Close() (err error)

func (*AddrListener) Listen

func (l *AddrListener) Listen() (err error)

func (AddrListener) ProtoAddr added in v0.1.11

func (l AddrListener) ProtoAddr() string

func (AddrListener) String

func (l AddrListener) String() string

type ChanListener added in v0.1.11

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

func NewChanListener added in v0.1.11

func NewChanListener(name string) *ChanListener

func (*ChanListener) Accept added in v0.1.11

func (l *ChanListener) Accept() (net.Conn, error)

func (*ChanListener) Addr added in v0.1.11

func (l *ChanListener) Addr() (addr net.Addr)

func (*ChanListener) Close added in v0.1.11

func (l *ChanListener) Close() error

func (*ChanListener) Dial added in v0.1.11

func (l *ChanListener) Dial(ctx context.Context, remoteAddr string) (con net.Conn, err error)

func (*ChanListener) Listen added in v0.1.11

func (l *ChanListener) Listen() (err error)

func (*ChanListener) Name added in v0.1.12

func (l *ChanListener) Name() string

func (*ChanListener) OnClose added in v0.1.11

func (l *ChanListener) OnClose(f ...func())

func (*ChanListener) ProtoAddr added in v0.1.11

func (l *ChanListener) ProtoAddr() string

func (*ChanListener) String added in v0.1.11

func (l *ChanListener) String() string

type ClientListeners

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

func (*ClientListeners) Add

func (cl *ClientListeners) Add(sl ...*ServiceListener)

func (*ClientListeners) Close

func (cl *ClientListeners) Close()

func (*ClientListeners) Remove

func (cl *ClientListeners) Remove(addr string) (name string, ok bool)

type ContextKey

type ContextKey int
const (
	UnRegisterContextKey ContextKey = iota
)

type DB

type DB struct {
	DbName string
	*sql.DB
}

func NewDB

func NewDB(dbName string) *DB

func (*DB) Close

func (s *DB) Close() error

func (*DB) Init

func (s *DB) Init() *DB

type DefaultReversePortForwardingRegister

type DefaultReversePortForwardingRegister struct {
	Nodes     *Nodes
	HttpHosts *HttpHosts
	// contains filtered or unexported fields
}

func (*DefaultReversePortForwardingRegister) Get

func (*DefaultReversePortForwardingRegister) GetListener

func (r *DefaultReversePortForwardingRegister) GetListener(apName, serviceName string, addr ...string) (ln *ServiceListener, err error)

func (*DefaultReversePortForwardingRegister) Register

func (*DefaultReversePortForwardingRegister) UnRegister

func (r *DefaultReversePortForwardingRegister) UnRegister(ctx ssh.Context, addr string) (ln net.Listener, ok bool)

type Dialer added in v0.1.11

type Dialer func(ctx context.Context, remoteAddr string) (con net.Conn, err error)

type HostPaths added in v0.1.11

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

func (*HostPaths) Get added in v0.1.11

func (hp *HostPaths) Get(pth string) (lb *LB, ok bool)

func (*HostPaths) Remove added in v0.1.11

func (hp *HostPaths) Remove(pth ...string)

func (*HostPaths) Set added in v0.1.11

func (hp *HostPaths) Set(lb *LoadBalancer, n *Node)

type HttpHosts added in v0.1.11

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

func (*HttpHosts) Get added in v0.1.11

func (h *HttpHosts) Get(host string) (pths *HostPaths, ok bool)

func (*HttpHosts) GetOrRegister added in v0.1.12

func (h *HttpHosts) GetOrRegister(host string) (pths *HostPaths)

func (*HttpHosts) Register added in v0.1.11

func (h *HttpHosts) Register(host string) *HostPaths

func (*HttpHosts) Remove added in v0.1.11

func (h *HttpHosts) Remove(host string, pth ...string)

type HttpUsers added in v0.1.11

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

func (*HttpUsers) Empty added in v0.1.11

func (a *HttpUsers) Empty() bool

func (*HttpUsers) Match added in v0.1.11

func (a *HttpUsers) Match(user, password string) bool

func (*HttpUsers) Remove added in v0.1.11

func (a *HttpUsers) Remove(user ...string) *HttpUsers

func (*HttpUsers) Scan added in v0.1.11

func (a *HttpUsers) Scan(src interface{}) (err error)

func (*HttpUsers) Set added in v0.1.11

func (a *HttpUsers) Set(user, password string) *HttpUsers

func (*HttpUsers) Value added in v0.1.11

func (a *HttpUsers) Value() (v driver.Value, err error)

type LB added in v0.1.11

type LB struct {
	*LoadBalancer
	Node *Node
}

type Listener

type Listener interface {
	net.Listener
	fmt.Stringer

	Listen() (err error)
	ProtoAddr() string
}

type LoadBalancer

type LoadBalancer struct {
	Ap, Service string
	PublicAddr  *string
	HttpHost    *string
	HttpPath    string
	MaxCount    int
	UnixSocket  bool

	*Nodes
}

type LoadBalancerFilter

type LoadBalancerFilter struct {
	Ap       string
	Services []string
}

type LoadBalancers

type LoadBalancers struct {
	*DB
}

func NewLoadBalancers

func NewLoadBalancers(DB *DB) *LoadBalancers

func (*LoadBalancers) Add

func (s *LoadBalancers) Add(ap, service string, maxCount int, publicAddr string) (err error)

func (*LoadBalancers) Get

func (s *LoadBalancers) Get(ap, service string) (balancer *LoadBalancer, err error)

func (*LoadBalancers) GetUsers added in v0.1.11

func (s *LoadBalancers) GetUsers(ap, service string) (users HttpUsers, enabled bool, err error)

func (*LoadBalancers) HttpUserAdd added in v0.1.11

func (s *LoadBalancers) HttpUserAdd(ap, name, username, pasword string) (err error)

func (*LoadBalancers) HttpUserRemove added in v0.1.11

func (s *LoadBalancers) HttpUserRemove(ap, name string, username ...string) (err error)

func (*LoadBalancers) List

func (s *LoadBalancers) List(cb func(i int, lb *LoadBalancer) error, filter *LoadBalancerFilter) (err error)

func (*LoadBalancers) Remove

func (s *LoadBalancers) Remove(ap string, name ...string) (removed int64, err error)

func (*LoadBalancers) Set added in v0.1.11

func (s *LoadBalancers) Set(ap, name, field string, value interface{}) (err error)

func (*LoadBalancers) SetHttpAuthEnabled added in v0.1.11

func (s *LoadBalancers) SetHttpAuthEnabled(ap, name string, value bool) (err error)

func (*LoadBalancers) SetHttpHost added in v0.1.11

func (s *LoadBalancers) SetHttpHost(ap, name string, value *string) (err error)

func (*LoadBalancers) SetHttpPath added in v0.1.11

func (s *LoadBalancers) SetHttpPath(ap, name string, value string) (err error)

func (*LoadBalancers) SetMaxCount added in v0.1.11

func (s *LoadBalancers) SetMaxCount(ap, name string, value int) (err error)

func (*LoadBalancers) SetPublicAddr added in v0.1.11

func (s *LoadBalancers) SetPublicAddr(ap, name, value string) (err error)

func (*LoadBalancers) SetUnixSocket added in v0.1.11

func (s *LoadBalancers) SetUnixSocket(ap, name string, value bool) (err error)

type Node

type Node struct {
	*ChanListener

	Dir         string
	Ap, Service string
	Listeners   []Listener
	EndPoints   map[string]*NodeServiceListener
	// contains filtered or unexported fields
}

func (Node) Close

func (n Node) Close() (err error)

func (Node) CloseEndPont

func (n Node) CloseEndPont(addr string)

func (Node) Forever

func (n Node) Forever()

func (Node) Listen

func (n Node) Listen() (err error)

func (Node) NextDial added in v0.1.12

func (n Node) NextDial(ctx context.Context, remoteAddr string) (conn net.Conn, err error)

func (Node) NextDialSl added in v0.1.12

func (n Node) NextDialSl(ctx context.Context, remoteAddr string) (sl *NodeServiceListener, conn net.Conn, err error)

func (Node) String

func (n Node) String() string

type NodeServiceListener

type NodeServiceListener struct {
	*ServiceListener
	// contains filtered or unexported fields
}

func (*NodeServiceListener) Dial

func (sl *NodeServiceListener) Dial(ctx context.Context, remoteAddr string) (conn net.Conn, err error)

type Nodes

type Nodes struct {
	Dir string

	Ln       net.Listener
	SockPerm os.FileMode
	// contains filtered or unexported fields
}

func (*Nodes) Add

func (ns *Nodes) Add(LB *LoadBalancer, ln *ServiceListener) (node *Node, err error)

func (*Nodes) Count

func (ns *Nodes) Count(ap, service string) int

func (*Nodes) Remove

func (ns *Nodes) Remove(LB *LoadBalancer, ln *NodeServiceListener)

type PubKeySigner

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

func (PubKeySigner) PublicKey

func (s PubKeySigner) PublicKey() ssh.PublicKey

func (PubKeySigner) Sign

func (s PubKeySigner) Sign(rand io.Reader, data []byte) (*ssh.Signature, error)

type Server

type Server struct {
	KeyFile        string
	Addr           string
	HttpConfig     *httpu.Config
	SocketsDir     string
	NodeSockerPerm os.FileMode
	Updater        updater.Updater

	Cron               *cron.Cron
	RenewTokenSchedule cron.Schedule

	Users         *Users
	LoadBalancers *LoadBalancers

	HttpHosts *HttpHosts
	// contains filtered or unexported fields
}

func (*Server) CreateToken added in v0.1.11

func (srv *Server) CreateToken() (err error)

func (*Server) IsRunning added in v0.1.11

func (srv *Server) IsRunning() bool

func (*Server) RoundTrip added in v0.1.11

func (srv *Server) RoundTrip(lb *LB, r *http.Request) (resp *http.Response, err error)

RoundTrip is http.RoundTriper implementation.

func (*Server) Run added in v0.1.11

func (srv *Server) Run() (err error)

func (*Server) ServeHTTP added in v0.1.11

func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Setup added in v0.1.11

func (srv *Server) Setup(appender task.Appender) (err error)

func (*Server) Start added in v0.1.11

func (srv *Server) Start(done func()) (stop task.Stoper, err error)

func (*Server) Stop added in v0.1.11

func (srv *Server) Stop()

type ServiceListener

type ServiceListener struct {
	Name string
	Listener
	Client ssh.Session
	// contains filtered or unexported fields
}

func (*ServiceListener) Close

func (sl *ServiceListener) Close() error

type UnixListener

type UnixListener struct {
	net.Listener
	Str        string
	RootDir    string
	SocketPath string
	SockPerm   os.FileMode
	// contains filtered or unexported fields
}

func (*UnixListener) Addr added in v0.1.11

func (l *UnixListener) Addr() net.Addr

func (*UnixListener) Close

func (l *UnixListener) Close() (err error)

func (*UnixListener) Listen

func (l *UnixListener) Listen() (err error)

func (*UnixListener) OnClose added in v0.1.11

func (l *UnixListener) OnClose(f ...func())

func (*UnixListener) ProtoAddr added in v0.1.11

func (l *UnixListener) ProtoAddr() string

func (*UnixListener) RemoveSocketFile

func (l *UnixListener) RemoveSocketFile() (err error)

func (UnixListener) String

func (l UnixListener) String() string

type User

type User struct {
	Name      string
	IsAp      bool
	UpdateKey bool
}

func (User) String

func (u User) String() (s string)

type Users

type Users struct {
	DB *DB
}

func NewUsers

func NewUsers(db *DB) *Users

func (*Users) Add

func (s *Users) Add(name string, isAp, updateKey bool) (err error)

func (*Users) CheckUser

func (s *Users) CheckUser(user, key string) (err error, ok, isAp bool)

func (*Users) IsAp

func (s *Users) IsAp(user string) (ok bool, err error)

func (*Users) List

func (s *Users) List(isAp bool, cb func(i int, u *User) error, nameMatch ...string) (err error)

func (*Users) Remove

func (s *Users) Remove(name ...string) (removed int64, err error)

func (*Users) SetUpdateKeyFlag

func (s *Users) SetUpdateKeyFlag(value bool, name ...string) (removed int64, err error)

type VirtualAddr added in v0.1.11

type VirtualAddr struct {
	Name string
}

func (VirtualAddr) Network added in v0.1.11

func (addr VirtualAddr) Network() string

func (VirtualAddr) String added in v0.1.11

func (addr VirtualAddr) String() string

type VirtualCon added in v0.1.11

type VirtualCon struct {
	Writer io.Writer
	Reader io.Reader
	LAddr  net.Addr
	RAddr  net.Addr
	// contains filtered or unexported fields
}

func (VirtualCon) Close added in v0.1.11

func (con VirtualCon) Close() error

func (VirtualCon) LocalAddr added in v0.1.11

func (con VirtualCon) LocalAddr() net.Addr

func (VirtualCon) Read added in v0.1.11

func (con VirtualCon) Read(p []byte) (n int, err error)

func (VirtualCon) RemoteAddr added in v0.1.11

func (con VirtualCon) RemoteAddr() net.Addr

func (VirtualCon) SetDeadline added in v0.1.11

func (con VirtualCon) SetDeadline(t time.Time) error

func (VirtualCon) SetReadDeadline added in v0.1.11

func (con VirtualCon) SetReadDeadline(t time.Time) error

func (VirtualCon) SetWriteDeadline added in v0.1.11

func (con VirtualCon) SetWriteDeadline(t time.Time) error

func (VirtualCon) Write added in v0.1.11

func (con VirtualCon) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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