herbplugin

package module
v0.0.0-...-18e76e9 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 5 Imported by: 6

README

herbplugin

Documentation

Index

Constants

View Source
const ContextNameFinished = ContextName("finished")
View Source
const PermissionDangerousAPI = "DANGER!!!ALLOW-MALICIOUS-DAMAGE"

Variables

View Source
var Finish = func(ctx context.Context, plugin Plugin) {
	result := ctx.Value(ContextNameFinished).(*bool)
	*result = true
}

Functions

func ContainsPermissions

func ContainsPermissions(src []string, target []string) bool

func Exec

func Exec(plugin Plugin, p ...Process) bool

func GetFinished

func GetFinished(ctx context.Context) bool

func IsUnauthorizeDomainError

func IsUnauthorizeDomainError(err error) bool

func IsUnauthorizePathError

func IsUnauthorizePathError(err error) bool

func IsUnauthorizePermissionError

func IsUnauthorizePermissionError(err error) bool

func Lanuch

func Lanuch(p Plugin, opt Options)

func LogError

func LogError(err error)

func MatchDomain

func MatchDomain(pattern string, domain string) bool

func MustAuthorizePermission

func MustAuthorizePermission(permissions []string, permission string) bool

func MustCleanPath

func MustCleanPath(base string, newpath string) string

func NewUnauthorizeDomainError

func NewUnauthorizeDomainError(domain string) error

func NewUnauthorizePathError

func NewUnauthorizePathError(path string) error

func NewUnauthorizePermissionError

func NewUnauthorizePermissionError(prmission string) error

func NopPrinter

func NopPrinter(info string)

Types

type BasicPlugin

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

func New

func New() *BasicPlugin

func (*BasicPlugin) HandlePluginError

func (p *BasicPlugin) HandlePluginError(err error)

func (*BasicPlugin) MustBootPlugin

func (p *BasicPlugin) MustBootPlugin()

func (*BasicPlugin) MustClosePlugin

func (p *BasicPlugin) MustClosePlugin()

func (*BasicPlugin) MustInitPlugin

func (p *BasicPlugin) MustInitPlugin()

func (*BasicPlugin) MustLoadPlugin

func (p *BasicPlugin) MustLoadPlugin()

func (*BasicPlugin) PluginOptions

func (p *BasicPlugin) PluginOptions() Options

func (*BasicPlugin) PluginPrint

func (p *BasicPlugin) PluginPrint(info string)

func (*BasicPlugin) PluginType

func (p *BasicPlugin) PluginType() string

func (*BasicPlugin) SetPluginErrorHandler

func (p *BasicPlugin) SetPluginErrorHandler(h func(err error))

func (*BasicPlugin) SetPluginOptions

func (p *BasicPlugin) SetPluginOptions(opt Options)

func (*BasicPlugin) SetPluginPrinter

func (p *BasicPlugin) SetPluginPrinter(h func(info string))

type ContextName

type ContextName string

type Location

type Location struct {
	Path string
}

func NewLoaction

func NewLoaction() *Location

func (*Location) MustCleanInsidePath

func (l *Location) MustCleanInsidePath(p string) string

func (*Location) MustCleanPath

func (l *Location) MustCleanPath(p string) string

type Module

type Module struct {
	ID           string
	InitProcess  Process
	BootProcess  Process
	CloseProcess Process
}

func CreateModule

func CreateModule(id string, initfn Process, bootfn Process, closefn Process) *Module

type NopOptions

type NopOptions struct{}

func (NopOptions) GetLocation

func (o NopOptions) GetLocation() *Location

func (NopOptions) GetParam

func (o NopOptions) GetParam(name string) string

func (NopOptions) MustAuthorizeDomain

func (o NopOptions) MustAuthorizeDomain(domain string) bool

func (NopOptions) MustAuthorizePath

func (o NopOptions) MustAuthorizePath(path string) bool

func (NopOptions) MustAuthorizePermission

func (o NopOptions) MustAuthorizePermission(permission string) bool

type Options

type Options interface {
	GetLocation() *Location
	GetParam(name string) string
	MustAuthorizeDomain(domain string) bool
	MustAuthorizePath(path string) bool
	MustAuthorizePermission(permission string) bool
}

type PlainOptions

type PlainOptions struct {
	Location    *Location
	Params      map[string]string
	Trusted     *Trusted
	Permissions []string
}

func NewOptions

func NewOptions() *PlainOptions

func (*PlainOptions) GetLocation

func (o *PlainOptions) GetLocation() *Location

func (*PlainOptions) GetParam

func (o *PlainOptions) GetParam(name string) string

func (*PlainOptions) MustAuthorizeDomain

func (o *PlainOptions) MustAuthorizeDomain(domain string) bool

func (*PlainOptions) MustAuthorizePath

func (o *PlainOptions) MustAuthorizePath(path string) bool

func (*PlainOptions) MustAuthorizePermission

func (o *PlainOptions) MustAuthorizePermission(permission string) bool

type Plugin

type Plugin interface {
	MustInitPlugin()
	MustLoadPlugin()
	MustBootPlugin()
	MustClosePlugin()
	PluginType() string
	SetPluginErrorHandler(func(err error))
	HandlePluginError(err error)
	SetPluginPrinter(func(info string))
	PluginPrint(info string)
	PluginOptions() Options
	SetPluginOptions(opt Options)
}

type Process

type Process func(ctx context.Context, plugin Plugin, next func(ctx context.Context, plugin Plugin))

func ComposeProcess

func ComposeProcess(series ...Process) Process

type Trusted

type Trusted struct {
	Paths   []string
	Domains []string
}

func NewTrusted

func NewTrusted() *Trusted

func (*Trusted) Contains

func (t *Trusted) Contains(target *Trusted) bool

func (*Trusted) MustAuthorizeDomain

func (t *Trusted) MustAuthorizeDomain(domain string) bool

func (*Trusted) MustAuthorizePath

func (t *Trusted) MustAuthorizePath(path string) bool

type UnauthorizeDomainError

type UnauthorizeDomainError struct {
	Domain string
}

func (*UnauthorizeDomainError) Error

func (e *UnauthorizeDomainError) Error() string

type UnauthorizePathError

type UnauthorizePathError struct {
	Path string
}

func (*UnauthorizePathError) Error

func (e *UnauthorizePathError) Error() string

type UnauthorizePermissionError

type UnauthorizePermissionError struct {
	Permission string
}

func (*UnauthorizePermissionError) Error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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