worker

package
v0.0.0-...-767fa57 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLoopClosed = fmt.Errorf("loop closed")
)

Functions

func RecvProcSpec

func RecvProcSpec[T any](ctx *ProcRunCtx) (*T, error)

func SendProcSpec

func SendProcSpec(ctx *ProcRunCtx, spec any)

Types

type ExampleProcClient

type ExampleProcClient struct {
	ProcInfo
	// contains filtered or unexported fields
}

func NewExampleProcClient

func NewExampleProcClient(spec ExampleSpec) *ExampleProcClient

func (*ExampleProcClient) Run

func (p *ExampleProcClient) Run(ctx *ProcRunCtx)

type ExampleProcServer

type ExampleProcServer struct {
	ProcInfo
}

func NewExampleProcServer

func NewExampleProcServer() *ExampleProcServer

func (*ExampleProcServer) Run

func (p *ExampleProcServer) Run(ctx *ProcRunCtx)

type ExampleSpec

type ExampleSpec struct {
	Name string
}

type ExecInfo

type ExecInfo struct {
	Kind ExecInfoKind
	Data []byte
}

type ExecInfoKind

type ExecInfoKind byte
const (
	ExecInfoKind_WinSize ExecInfoKind = 1
)

type ExecProcClient

type ExecProcClient struct {
	ProcInfo
	ExecSpec
	// contains filtered or unexported fields
}

func NewExecProcClient

func NewExecProcClient(spec ExecSpec) *ExecProcClient

func (*ExecProcClient) Run

func (p *ExecProcClient) Run(ctx *ProcRunCtx)

type ExecProcServer

type ExecProcServer struct {
	ProcInfo
}

func NewExecProcServer

func NewExecProcServer() *ExecProcServer

func (*ExecProcServer) Run

func (p *ExecProcServer) Run(ctx *ProcRunCtx)

type ExecSpec

type ExecSpec struct {
	ARGV []string
	TTY  bool
}

type ForwardSpec

type ForwardSpec struct {
	ListenEndpoint  string
	ConnectEndpoint string
}

type GetProcClient

type GetProcClient struct {
	ProcInfo
	// contains filtered or unexported fields
}

func NewGetProcClient

func NewGetProcClient(spec GetPutSpec) *GetProcClient

func (*GetProcClient) Run

func (p *GetProcClient) Run(ctx *ProcRunCtx)

type GetProcServer

type GetProcServer struct {
	ProcInfo
}

func NewGetProcServer

func NewGetProcServer() *GetProcServer

func (*GetProcServer) Run

func (p *GetProcServer) Run(ctx *ProcRunCtx)

type GetPutSpec

type GetPutSpec struct {
	SourcePaths []string
	DestPath    string
	IsTarMode   bool
	IsGzipMode  bool
}

type LocalPFProcClient

type LocalPFProcClient struct {
	ProcInfo
	// contains filtered or unexported fields
}

func NewLocalPFProcClient

func NewLocalPFProcClient(spec ForwardSpec) *LocalPFProcClient

func (*LocalPFProcClient) Run

func (p *LocalPFProcClient) Run(ctx *ProcRunCtx)

type LocalPFProcServer

type LocalPFProcServer struct {
	ProcInfo
}

func NewLocalPFProcServer

func NewLocalPFProcServer() *LocalPFProcServer

func (*LocalPFProcServer) Run

func (p *LocalPFProcServer) Run(ctx *ProcRunCtx)

type Loop

type Loop interface {
	Run()                                                 // Run the loop
	Start(h Proc) (procID uint32, doneCh <-chan struct{}) // Start a Proc
	StartLater(p Proc) (
		procID uint32,
		handle func(bool) (doneCh <-chan struct{}),
	) // Start a Proc later
	Remove(id uint32) bool // Remove a Proc
	Done() <-chan struct{} // Get the done chan of loop ctx
	Stop()                 // Stop the loop
}

type LoopImpl

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

func NewLoop

func NewLoop(ctx context.Context, rwc io.ReadWriteCloser) *LoopImpl

func (*LoopImpl) Done

func (loop *LoopImpl) Done() <-chan struct{}

func (*LoopImpl) Remove

func (loop *LoopImpl) Remove(procID uint32) bool

func (*LoopImpl) Run

func (loop *LoopImpl) Run()

func (*LoopImpl) Start

func (loop *LoopImpl) Start(p Proc) (procID uint32, doneCh <-chan struct{})

func (*LoopImpl) StartLater

func (loop *LoopImpl) StartLater(proc Proc) (procID uint32, handle func(bool) <-chan struct{})

func (*LoopImpl) Stop

func (loop *LoopImpl) Stop()

type MainProcClient

type MainProcClient struct {
	ProcInfo
	MainSpec
	// contains filtered or unexported fields
}

func NewMainProcClient

func NewMainProcClient(spec MainSpec) *MainProcClient

func (*MainProcClient) Run

func (p *MainProcClient) Run(ctx *ProcRunCtx)

func (*MainProcClient) StartProc

func (p *MainProcClient) StartProc(kind ProcKind, spec any)

type MainProcMsg

type MainProcMsg struct {
	Kind  MainProcMsgKind
	SeqNo uint32
	Data  []byte
}

type MainProcMsgKind

type MainProcMsgKind string
const (
	MainProcMsgKind_Start  MainProcMsgKind = "Start"
	MainProcMsgKind_Remove MainProcMsgKind = "Remove"
	MainProcMsgKind_Exit   MainProcMsgKind = "Exit"
)

type MainProcMsg_Remove

type MainProcMsg_Remove struct {
	ProcID uint32
	Error  string // response
}

type MainProcMsg_Start

type MainProcMsg_Start struct {
	ProcID   uint32
	ProcKind ProcKind
	Error    string // response
}

type MainProcServer

type MainProcServer struct {
	ProcInfo
}

func NewMainProcServer

func NewMainProcServer() *MainProcServer

func (*MainProcServer) Run

func (p *MainProcServer) Run(ctx *ProcRunCtx)

type MainSpec

type MainSpec struct {
	ExitWhenNoProc bool
}

type MedSocksConn

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

func (*MedSocksConn) Close

func (conn *MedSocksConn) Close() error

func (*MedSocksConn) LocalAddr

func (conn *MedSocksConn) LocalAddr() net.Addr

func (*MedSocksConn) Read

func (conn *MedSocksConn) Read(b []byte) (n int, err error)

func (*MedSocksConn) RemoteAddr

func (conn *MedSocksConn) RemoteAddr() net.Addr

func (*MedSocksConn) SetDeadline

func (conn *MedSocksConn) SetDeadline(t time.Time) error

func (*MedSocksConn) SetReadDeadline

func (conn *MedSocksConn) SetReadDeadline(t time.Time) error

func (*MedSocksConn) SetWriteDeadline

func (conn *MedSocksConn) SetWriteDeadline(t time.Time) error

func (*MedSocksConn) Write

func (conn *MedSocksConn) Write(b []byte) (n int, err error)

type MedSocksListener

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

MedSocksListener provides net.Listener interface for socks5.Serve

func NewMedSocksListener

func NewMedSocksListener(
	ctx context.Context, dataIn pfDataInFn, dataOut pfDataOutFn) *MedSocksListener

func (*MedSocksListener) Accept

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

func (*MedSocksListener) Addr

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

func (*MedSocksListener) Close

func (l *MedSocksListener) Close() error

func (*MedSocksListener) Wait

func (l *MedSocksListener) Wait()

type Proc

type Proc interface {
	Run(ctx *ProcRunCtx)
	Kind() ProcKind
	Side() ProcSide
}

func CreateProcClient

func CreateProcClient(kind ProcKind, spec any) (Proc, error)

func CreateProcServer

func CreateProcServer(kind ProcKind) (Proc, error)

type ProcInfo

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

func NewProcInfo

func NewProcInfo(kind ProcKind, side ProcSide) ProcInfo

func (ProcInfo) Kind

func (p ProcInfo) Kind() ProcKind

func (ProcInfo) Side

func (p ProcInfo) Side() ProcSide

type ProcKind

type ProcKind string
const (
	ProcKind_None     ProcKind = "none"
	ProcKind_Example  ProcKind = "example"
	ProcKind_Main     ProcKind = "main"
	ProcKind_Exec     ProcKind = "exec"
	ProcKind_Get      ProcKind = "get"
	ProcKind_Put      ProcKind = "put"
	ProcKind_FTP      ProcKind = "ftp" // TODO
	ProcKind_LocalPF  ProcKind = "forward-local"
	ProcKind_RemotePF ProcKind = "forward-remote"
	ProcKind_Socks    ProcKind = "socks"
	ProcKind_Proxy    ProcKind = "proxy" // TODO
	ProcKind_Self     ProcKind = "self"
	ProcKind_WebUI    ProcKind = "webui" // TODO
	ProcKind_CLI      ProcKind = "cli"   // TODO
	ProcKind_TMUX     ProcKind = "tmux"  // TODO
)

type ProcRunCtx

type ProcRunCtx struct {
	context.Context                    // proc ctx
	Cancel          context.CancelFunc // cancel proc ctx
	Loop            Loop               // the loop running proc
	ProcID          uint32
	PktOutCh        chan<- *pb.Packet // packet output channel
	PktOutDone      <-chan struct{}
	PktInCh         <-chan *pb.Packet // packet input channel
}

func (*ProcRunCtx) InputPacket

func (ctx *ProcRunCtx) InputPacket() *pb.Packet

func (*ProcRunCtx) InputPacketWithDone

func (ctx *ProcRunCtx) InputPacketWithDone(doneCh <-chan struct{}) *pb.Packet

func (*ProcRunCtx) OutputPacket

func (ctx *ProcRunCtx) OutputPacket(pkt *pb.Packet) bool

type ProcSide

type ProcSide byte
const (
	ProcSide_None   ProcSide = 0b00
	ProcSide_Client ProcSide = 0b01
	ProcSide_Server ProcSide = 0b10
	ProcSide_Both   ProcSide = 0b11
)

type PutProcClient

type PutProcClient struct {
	ProcInfo
	// contains filtered or unexported fields
}

func NewPutProcClient

func NewPutProcClient(spec GetPutSpec) *PutProcClient

func (*PutProcClient) Run

func (p *PutProcClient) Run(ctx *ProcRunCtx)

type PutProcServer

type PutProcServer struct {
	ProcInfo
}

func NewPutProcServer

func NewPutProcServer() *PutProcServer

func (*PutProcServer) Run

func (p *PutProcServer) Run(ctx *ProcRunCtx)

type RemotePFProcClient

type RemotePFProcClient struct {
	ProcInfo
	// contains filtered or unexported fields
}

func NewRemotePFProcClient

func NewRemotePFProcClient(spec ForwardSpec) *RemotePFProcClient

func (*RemotePFProcClient) Run

func (p *RemotePFProcClient) Run(ctx *ProcRunCtx)

type RemotePFProcServer

type RemotePFProcServer struct {
	ProcInfo
}

func NewRemotePFProcServer

func NewRemotePFProcServer() *RemotePFProcServer

func (*RemotePFProcServer) Run

func (p *RemotePFProcServer) Run(ctx *ProcRunCtx)

type SelfProcClient

type SelfProcClient struct {
	ProcInfo
	// contains filtered or unexported fields
}

func NewSelfProcClient

func NewSelfProcClient(spec SelfSpec) *SelfProcClient

func (*SelfProcClient) Run

func (p *SelfProcClient) Run(ctx *ProcRunCtx)

type SelfProcServer

type SelfProcServer struct {
	ProcInfo
}

func NewSelfProcServer

func NewSelfProcServer() *SelfProcServer

func (*SelfProcServer) Run

func (p *SelfProcServer) Run(ctx *ProcRunCtx)

type SelfSpec

type SelfSpec struct {
	Exit   bool
	Remove bool
}

type SocksProcClient

type SocksProcClient struct {
	ProcInfo
	// contains filtered or unexported fields
}

func NewSocksProcClient

func NewSocksProcClient(spec SocksSpec) *SocksProcClient

func (*SocksProcClient) Run

func (p *SocksProcClient) Run(ctx *ProcRunCtx)

type SocksProcServer

type SocksProcServer struct {
	ProcInfo
}

func NewSocksProcServer

func NewSocksProcServer() *SocksProcServer

func (*SocksProcServer) Run

func (p *SocksProcServer) Run(ctx *ProcRunCtx)

type SocksSpec

type SocksSpec struct {
	ListenEndpoint string
}

Jump to

Keyboard shortcuts

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