dehub

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnmarshalMetaFailed ssh.RejectionReason = iota + ssh.ResourceShortage + 1000
	FailedStartPTY
)
View Source
const DefaultSignTimeout = 10 * time.Second
View Source
const ExecResizeRequest = "resize"

Variables

This section is empty.

Functions

func CheckPublicKeys added in v0.2.0

func CheckPublicKeys(trustedPubKeys ...[]byte) (func(ssh.PublicKey) bool, error)

func FormatPubKey added in v0.2.1

func FormatPubKey(key ssh.PublicKey) string

func WebsocketDial

func WebsocketDial(ctx context.Context, addr string) (net.Conn, error)

func WebsocketUpgrade

func WebsocketUpgrade(conn io.ReadWriter) error

Types

type ClientType

type ClientType int
const (
	ClientTypeServant ClientType = iota
	ClientTypeMaster
)

type Command

type Command string
const (
	CommandExec          Command = "exec"
	CommandForwardSocks5 Command = "forward-socks5"
	CommandShareDir      Command = "share-dir"
)

func (Command) String

func (c Command) String() string

type DB

type DB interface {
	StoreLocation(id string, netAddr string) error
	LoadLocation(idPrefix string) (netAddr string, id string, err error)
	DeleteLocation(id string) error
}

DB store the location of which hub node the servant is connected to.

type ExecMeta

type ExecMeta struct {
	Size *pty.Winsize
	Cmd  string
	Args []string
}

type Hub

type Hub struct {
	Logger *slog.Logger

	DB DB

	GetIP func() (string, error)
	// contains filtered or unexported fields
}

func NewHub

func NewHub() *Hub

func (*Hub) Handle

func (h *Hub) Handle(conn io.ReadWriteCloser)

func (*Hub) MustStartRelay added in v0.2.3

func (h *Hub) MustStartRelay() func()

MustStartRelay is similar to Hub.StartRelay.

func (*Hub) StartRelay added in v0.2.3

func (h *Hub) StartRelay(addr string) (func(), error)

type HubHeader

type HubHeader struct {
	Type ClientType
	ID   ServantID
}

type Logger

type Logger interface {
	Info(string, ...slog.Attr)
	Warn(string, ...slog.Attr)
	Error(string, ...slog.Attr)
}

type Master

type Master struct {
	Logger *slog.Logger
	// contains filtered or unexported fields
}

func NewMaster

func NewMaster(id ServantID, prvKey ssh.Signer, check func(ssh.PublicKey) bool) *Master

func (*Master) Connect

func (m *Master) Connect(conn io.ReadWriteCloser) error

func (*Master) Exec

func (m *Master) Exec(in io.Reader, out io.Writer, cmd string, args ...string) error

func (*Master) ForwardSocks5

func (m *Master) ForwardSocks5(listenTo net.Listener) error

func (*Master) ServeNFS

func (m *Master) ServeNFS(remoteDir string, fsSrv net.Listener, cacheLimit int) error

type MountDirMeta

type MountDirMeta struct {
	Path       string
	CacheLimit int
}

type Servant

type Servant struct {
	Logger *slog.Logger
	// contains filtered or unexported fields
}

func NewServant

func NewServant(id ServantID, prvKey ssh.Signer, check func(ssh.PublicKey) bool) *Servant

func (*Servant) Serve added in v0.1.0

func (s *Servant) Serve(conn io.ReadWriteCloser) func()

type ServantID

type ServantID string

func (ServantID) String

func (n ServantID) String() string

type TunnelHeader

type TunnelHeader struct {
	Timestamp    []byte
	PubKeyHash   [md5.Size]byte
	Sign         *ssh.Signature
	Command      Command
	ExecMeta     *ExecMeta
	ShareDirMeta *MountDirMeta
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳