Documentation ¶
Index ¶
- Constants
- Variables
- func Close(closer io.Closer)
- func CloseResponse(response *http.Response)
- func ContainsScope(arr []Scope, value Scope) bool
- func ContainsString(arr []string, value string) bool
- func Convert(val interface{}, target interface{}) (interface{}, error)
- func CopyFile(src, dest string) error
- func DetermineKernelSupport()
- func EnsureAccess(source string, prefix string) bool
- func ExtractDeb(stream io.ReaderAt, directory string) error
- func ExtractTar(stream io.Reader, directory string) error
- func ExtractTarGz(gzipStream io.Reader, directory string) error
- func ExtractZip(name, directory string) error
- func GenerateRandomString(n int) (string, error)
- func GenerateValidationMessage(err error) error
- func GetBooleanOrDefault(data map[string]interface{}, key string, def bool) bool
- func GetHostname(requestHost string) string
- func GetMapOrNull(data map[string]interface{}, key string) map[string]interface{}
- func GetObjectArrayOrNull(data map[string]interface{}, key string) []interface{}
- func GetStringArrayOrNull(data map[string]interface{}, key string) []string
- func GetStringOrDefault(data map[string]interface{}, key string, def string) string
- func Http() *http.Client
- func HttpDownloadDeb(link, folder string) error
- func HttpGet(url string) (*http.Response, error)
- func HttpGetTarGz(url, directory string) error
- func HttpGetZip(url, directory string) error
- func JoinPath(paths ...string) string
- func Recover()
- func RemoveInvalidSymlinks(files []os.FileInfo, sourceFolder, prefix string) []os.FileInfo
- func ReplaceTokens(msg string, mapping map[string]interface{}) string
- func ReplaceTokensInArr(msg []string, mapping map[string]interface{}) []string
- func ReplaceTokensInMap(msg map[string]string, mapping map[string]interface{}) map[string]string
- func SplitArguments(source string) (cmd string, arguments []string)
- func ToString(v interface{}) string
- func UnmarshalTo(source, target interface{}) error
- func UseOpenat2() bool
- func UserInGroup(groups ...string) bool
- func Write(c *Socket, msg messages.Message) error
- type BaseEnvironment
- func (e *BaseEnvironment) AddListener(ws *Socket)
- func (e *BaseEnvironment) CreateWrapper() io.Writer
- func (e *BaseEnvironment) Delete() (err error)
- func (e *BaseEnvironment) DisplayToConsole(daemon bool, msg string, data ...interface{})
- func (e *BaseEnvironment) Execute(steps ExecutionData) error
- func (e *BaseEnvironment) ExecuteAsync(steps ExecutionData) (err error)
- func (e *BaseEnvironment) GetBase() *BaseEnvironment
- func (e *BaseEnvironment) GetConsole() (console []string, epoch int64)
- func (e *BaseEnvironment) GetConsoleFrom(time int64) (console []string, epoch int64)
- func (e *BaseEnvironment) GetRootDirectory() string
- func (e *BaseEnvironment) Log(l *log.Logger, format string, obj ...interface{})
- func (e *BaseEnvironment) Update() error
- func (e *BaseEnvironment) WaitForMainProcess() (err error)
- type Cache
- type Claim
- type CreateOperation
- type DaemonRunning
- type Environment
- type EnvironmentFactory
- type Error
- type Execution
- type ExecutionData
- type ExecutionFunction
- type FileServer
- type MemoryCache
- type Message
- type MetadataType
- type Operation
- type OperationFactory
- type PanelClaims
- type Requirements
- type SFTPAuthorization
- type Scope
- type Scopes
- type Server
- type ServerData
- type ServerDataAdmin
- type ServerIdResponse
- type ServerLogs
- type ServerRunning
- type ServerStats
- type ServerTasks
- type Socket
- type Task
- type Token
- type Tracker
- type Type
- type Variable
- type VariableOption
Constants ¶
View Source
const ( //none scope to allow defining that something doesn't need any specific permission ScopeNone = Scope("none") //generic ScopeOAuth2Auth = Scope("oauth2.auth") //server ScopeServersAdmin = Scope("servers.admin") ScopeServersView = Scope("servers.view") ScopeServersEdit = Scope("servers.edit") ScopeServersEditAdmin = Scope("servers.edit.admin") ScopeServersEditUsers = Scope("servers.edit.users") ScopeServersCreate = Scope("servers.create") ScopeServersDelete = Scope("servers.delete") ScopeServersInstall = Scope("servers.install") ScopeServersUpdate = Scope("servers.update") ScopeServersConsole = Scope("servers.console") ScopeServersConsoleSend = Scope("servers.console.send") ScopeServersStop = Scope("servers.stop") ScopeServersStart = Scope("servers.start") ScopeServersStat = Scope("servers.stats") ScopeServersSFTP = Scope("servers.sftp") ScopeServersFilesGet = Scope("servers.files.get") ScopeServersFilesPut = Scope("servers.files.put") //node ScopeNodesView = Scope("nodes.view") ScopeNodesEdit = Scope("nodes.edit") ScopeNodesDeploy = Scope("nodes.deploy") //template ScopeTemplatesView = Scope("templates.view") ScopeTemplatesEdit = Scope("templates.edit") //user ScopeUsersView = Scope("users.view") ScopeUsersEdit = Scope("users.edit") ScopeSettings = Scope("panel.settings") )
View Source
const MaxRecursivePath = 256
Variables ¶
View Source
var ( Hash = "unknown" Version = "nightly" Display string )
View Source
var Engine *gin.Engine
View Source
var ErrCannotValidateToken = CreateError("could not validate access token", "ErrCannotValidateToken")
View Source
var ErrClientNotFound = CreateError("client not found", "ErrClientNotFound")
View Source
var ErrContainerRunning = CreateError("container already running", "ErrContainerRunning")
View Source
var ErrDatabaseNotAvailable = CreateError("database not available", "ErrDatabaseNotAvailable")
View Source
var ErrDockerNotSupported = CreateError("docker not supported", "ErrDockerNotSupported")
View Source
var ErrEmailNotConfigured = CreateError("email not configured", "ErrEmailNotConfigured")
View Source
var ErrFactoryError = func(operatorName string, err error) *Error { return CreateError("factory `${operatorName}` encountered an error: `${err}`", "ErrFactoryError").Metadata(map[string]interface{}{"operatorName": operatorName, "err": err.Error()}) }
View Source
var ErrFieldEqual = func(fieldName1, fieldName2 string) *Error { return CreateError("${field1} cannot be equal to ${field2}", "ErrFieldEqual").Metadata(map[string]interface{}{"field1": fieldName1, "field2": fieldName2}) }
View Source
var ErrFieldHasURICharacters = func(fieldName string) *Error { return CreateError("${field} must not contain characters which cannot be used in URIs", "ErrFieldHasURICharacters").Metadata(map[string]interface{}{"field": fieldName}) }
View Source
var ErrFieldIsInvalidHost = func(fieldName string) *Error { return CreateError("${field} must be a valid IP or FQDN", "ErrFieldIsInvalidHost").Metadata(map[string]interface{}{"field": fieldName}) }
View Source
var ErrFieldIsInvalidIP = func(fieldName string) *Error { return CreateError("${field} must be a valid IP", "ErrFieldIsInvalidIP").Metadata(map[string]interface{}{"field": fieldName}) }
View Source
var ErrFieldLength = func(fieldName string, min int, max int) *Error { return CreateError("${field} must be between ${min} and ${max} characters", "ErrFieldLength").Metadata(map[string]interface{}{"field": fieldName, "min": min, "max": max}) }
View Source
var ErrFieldMustBePrintable = func(fieldName string) *Error { return CreateError("${field} must be printable ascii characters", "ErrFieldMustBePrintable").Metadata(map[string]interface{}{"field": fieldName}) }
View Source
var ErrFieldNotBetween = func(fieldName string, min, max int64) *Error { return CreateError("${field} must be between ${min} and ${max}", "ErrFieldNotBetween").Metadata(map[string]interface{}{"field": fieldName, "min": min, "max": max}) }
View Source
var ErrFieldNotEmail = func(fieldName string) *Error { return CreateError("${field} is not a valid email", "ErrFieldNotEmail").Metadata(map[string]interface{}{"field": fieldName}) }
View Source
var ErrFieldNotEqual = func(fieldName1, fieldName2 string) *Error { return CreateError("${field1} is not equal to ${field2}", "ErrFieldNotEqual").Metadata(map[string]interface{}{"field1": fieldName1, "field2": fieldName2}) }
View Source
var ErrFieldRequired = func(fieldName string) *Error { return CreateError("${field} is required", "ErrFieldRequired").Metadata(map[string]interface{}{"field": fieldName}) }
View Source
var ErrFieldTooLarge = func(fieldName string, value int64) *Error { return CreateError("${field} cannot be larger than ${max}", "ErrFieldTooLarge").Metadata(map[string]interface{}{"field": fieldName, "max": value}) }
View Source
var ErrFieldTooSmall = func(fieldName string, value int64) *Error { return CreateError("${field} cannot be smaller than ${min}", "ErrFieldTooSmall").Metadata(map[string]interface{}{"field": fieldName, "min": value}) }
View Source
var ErrFileExists = CreateError("file exists where there should be none", "ErrFileExists")
View Source
var ErrFileNotFound = CreateError("file not found", "ErrFileNotFound")
View Source
var ErrIllegalFileAccess = CreateError("invalid file access", "ErrIllegalFileAccess")
View Source
var ErrImageDownloading = CreateError("image downloading", "ErrImageDownloading")
View Source
var ErrInvalidCredentials = CreateError("invalid credentials", "ErrInvalidCredentials")
View Source
var ErrInvalidSession = CreateError("invalid session", "ErrInvalidSession")
View Source
var ErrInvalidTokenState = CreateError("invalid token state", "ErrInvalidTokenState")
View Source
var ErrInvalidUnixTime = CreateError("time provided is not a valid UNIX time", "ErrInvalidUnixTime")
View Source
var ErrKeyNotECDSA = CreateError("key is not ECDSA key", "ErrKeyNotECDSA")
View Source
var ErrKeyNotPEM = CreateError("key is not in PEM format", "ErrKeyNotPEM")
View Source
var ErrLoginNotPermitted = CreateError("login not permitted", "ErrLoginNotPermitted")
View Source
var ErrMissingAccessToken = CreateError("access token not provided", "ErrMissingAccessToken")
View Source
var ErrMissingBinary = func(expected string) *Error { return CreateError("missing binary: ${expected}", "ErrMissingBinary").Metadata(map[string]interface{}{"expected": expected}) }
View Source
var ErrMissingFactory = CreateError("missing factory", "ErrMissingFactory")
View Source
var ErrMissingScope = CreateError("missing scope", "ErrMissingScope")
View Source
var ErrNoPermission = CreateError("no permission to perform action", "ErrNoPermission")
View Source
var ErrNoTemplate = func(template string) *Error { return CreateError("no template with name ${name}", "ErrNoTemplate").Metadata(map[string]interface{}{"template": template}) }
View Source
var ErrNodeHasServers = CreateError("node has servers associated", "ErrNodeHasServers")
View Source
var ErrNodeInvalid = CreateError("node is invalid", "ErrNodeInvalid")
View Source
var ErrNotBearerToken = CreateError("access token must be a Bearer token", "ErrNotBearerToken")
View Source
var ErrNotImplemented = CreateError("not implemented", "ErrNotImplemented")
View Source
var ErrProcessRunning = CreateError("process already running", "ErrProcessRunning")
View Source
var ErrServerAlreadyExists = CreateError("server already exists", "ErrServerAlreadyExists")
View Source
var ErrServerDisabled = CreateError("server is disabled", "ErrServerDisabled")
View Source
var ErrServerNotFound = CreateError("server not found", "ErrServerNotFound")
View Source
var ErrServerOffline = CreateError("server offline", "ErrServerOffline")
View Source
var ErrServiceInvalidProvider = func(service, provider string) *Error { return CreateError("{service} does not support ${provider}", "ErrServiceInvalidProvider").Metadata(map[string]interface{}{"service": service, "provider": provider}) }
View Source
var ErrServiceNotAvailable = CreateError("service not available", "ErrServiceNotAvailable")
View Source
var ErrSessionExpired = CreateError("session expired", "ErrSessionExpired")
View Source
var ErrSettingNotConfigured = func(name string) *Error { return CreateError("${setting} is not configured", "ErrSettingNotConfigured").Metadata(map[string]interface{}{"setting": name}) }
View Source
var ErrTaskNotFound = CreateError("task not found", "ErrTaskNotFound")
View Source
var ErrTokenInvalid = CreateError("token is invalid", "ErrTokenInvalid")
View Source
var ErrUnknownError = CreateError("unknown error", "ErrUnknownError")
View Source
var ErrUnsupportedArch = func(actual, expected string) *Error { return CreateError("Architecture ${actual} not supported. Supported Architectures: ${expected}", "ErrUnsupportedArch").Metadata(map[string]interface{}{"actual": actual, "expected": expected}) }
View Source
var ErrUnsupportedOS = func(actual, expected string) *Error { return CreateError("OS (${actual}) not supported. Supported OS: ${expected}", "ErrUnsupportedOS").Metadata(map[string]interface{}{"actual": actual, "expected": expected}) }
View Source
var ErrUserNotFound = CreateError("user not found", "ErrUserNotFound")
Functions ¶
func CloseResponse ¶
func ContainsScope ¶
func ContainsString ¶
func Convert ¶
func Convert(val interface{}, target interface{}) (interface{}, error)
Converts the val parameter to the same type as the target
func DetermineKernelSupport ¶ added in v2.7.0
func DetermineKernelSupport()
func EnsureAccess ¶
func ExtractZip ¶ added in v2.6.0
func GenerateRandomString ¶ added in v2.4.0
func GetBooleanOrDefault ¶
func GetHostname ¶ added in v2.5.0
func GetMapOrNull ¶
func GetObjectArrayOrNull ¶
func GetStringArrayOrNull ¶
func GetStringOrDefault ¶
func HttpDownloadDeb ¶ added in v2.6.0
func HttpGetTarGz ¶ added in v2.6.0
func HttpGetZip ¶ added in v2.6.0
func RemoveInvalidSymlinks ¶
func ReplaceTokens ¶
func ReplaceTokensInArr ¶
func ReplaceTokensInMap ¶
func SplitArguments ¶
func UnmarshalTo ¶
func UnmarshalTo(source, target interface{}) error
func UseOpenat2 ¶ added in v2.7.0
func UseOpenat2() bool
func UserInGroup ¶
Types ¶
type BaseEnvironment ¶
type BaseEnvironment struct { Environment Type string RootDirectory string `json:"root"` ConsoleBuffer Cache `json:"-"` WSManager *Tracker `json:"-"` Wait *sync.WaitGroup `json:"-"` ExecutionFunction ExecutionFunction `json:"-"` WaitFunction func() (err error) `json:"-"` ServerId string `json:"-"` }
func (*BaseEnvironment) AddListener ¶
func (e *BaseEnvironment) AddListener(ws *Socket)
func (*BaseEnvironment) CreateWrapper ¶
func (e *BaseEnvironment) CreateWrapper() io.Writer
func (*BaseEnvironment) Delete ¶
func (e *BaseEnvironment) Delete() (err error)
func (*BaseEnvironment) DisplayToConsole ¶
func (e *BaseEnvironment) DisplayToConsole(daemon bool, msg string, data ...interface{})
func (*BaseEnvironment) Execute ¶
func (e *BaseEnvironment) Execute(steps ExecutionData) error
func (*BaseEnvironment) ExecuteAsync ¶
func (e *BaseEnvironment) ExecuteAsync(steps ExecutionData) (err error)
func (*BaseEnvironment) GetBase ¶
func (e *BaseEnvironment) GetBase() *BaseEnvironment
func (*BaseEnvironment) GetConsole ¶
func (e *BaseEnvironment) GetConsole() (console []string, epoch int64)
func (*BaseEnvironment) GetConsoleFrom ¶
func (e *BaseEnvironment) GetConsoleFrom(time int64) (console []string, epoch int64)
func (*BaseEnvironment) GetRootDirectory ¶
func (e *BaseEnvironment) GetRootDirectory() string
func (*BaseEnvironment) Log ¶ added in v2.6.0
func (e *BaseEnvironment) Log(l *log.Logger, format string, obj ...interface{})
func (*BaseEnvironment) Update ¶
func (e *BaseEnvironment) Update() error
func (*BaseEnvironment) WaitForMainProcess ¶
func (e *BaseEnvironment) WaitForMainProcess() (err error)
type Claim ¶
type Claim struct { jwt.RegisteredClaims PanelClaims PanelClaims `json:"pufferpanel,omitempty"` }
type CreateOperation ¶
type DaemonRunning ¶ added in v2.6.0
type DaemonRunning struct {
Message string `json:"message"`
}
type Environment ¶
type Environment interface { //Executes a command within the environment. Execute(steps ExecutionData) error //Executes a command within the environment and immediately return ExecuteAsync(steps ExecutionData) error //Sends a string to the StdIn of the main program process ExecuteInMainProcess(cmd string) error //Kills the main process, but leaves the environment running. Kill() error //Creates the environment setting needed to run programs. Create() error //Deletes the environment. Delete() error Update() error IsRunning() (isRunning bool, err error) WaitForMainProcess() error WaitForMainProcessFor(timeout time.Duration) error GetRootDirectory() string GetConsole() (console []string, epoch int64) GetConsoleFrom(time int64) (console []string, epoch int64) AddListener(ws *Socket) GetStats() (*ServerStats, error) DisplayToConsole(prefix bool, msg string, data ...interface{}) SendCode(code int) error GetBase() *BaseEnvironment }
type EnvironmentFactory ¶
type EnvironmentFactory interface { Create(id string) Environment Key() string }
type Error ¶
type Error struct { Message string `json:"msg,omitempty"` Code string `json:"code,omitempty"` Meta map[string]interface{} `json:"metadata,omitempty"` }
func CreateErrMissingScope ¶
func CreateError ¶
func (*Error) GetMessage ¶
type Execution ¶
type Execution struct { Command string `json:"command,omitempty"` StopCommand string `json:"stop,omitempty"` Disabled bool `json:"disabled,omitempty"` AutoStart bool `json:"autostart,omitempty"` AutoRestartFromCrash bool `json:"autorecover,omitempty"` AutoRestartFromGraceful bool `json:"autorestart,omitempty"` PreExecution []interface{} `json:"pre,omitempty"` PostExecution []interface{} `json:"post,omitempty"` StopCode int `json:"stopCode,omitempty"` EnvironmentVariables map[string]string `json:"environmentVars,omitempty"` LegacyRun string `json:"program,omitempty"` LegacyArguments []string `json:"arguments,omitempty"` WorkingDirectory string `json:"workingDirectory,omitempty"` }
type ExecutionData ¶
type ExecutionFunction ¶
type ExecutionFunction func(steps ExecutionData) (err error)
type FileServer ¶ added in v2.7.0
type FileServer interface { fs.FS fs.ReadDirFS fs.StatFS Prefix() string Stat(name string) (fs.FileInfo, error) Mkdir(path string, mode os.FileMode) error MkdirAll(path string, mode os.FileMode) error OpenFile(path string, flags int, mode os.FileMode) (*os.File, error) Remove(path string) error Rename(source, target string) error RemoveAll(path string) error Close() error }
func NewFileServer ¶ added in v2.7.0
func NewFileServer(prefix string) (FileServer, error)
type MemoryCache ¶
func CreateCache ¶
func CreateCache() *MemoryCache
func (*MemoryCache) Read ¶
func (c *MemoryCache) Read() (msg []string, lastTime int64)
type MetadataType ¶
type MetadataType struct { Type string `json:"type,omitempty"` Metadata map[string]interface{} `json:"-,omitempty"` }
designed to be overridden
func (*MetadataType) MarshalJSON ¶
func (t *MetadataType) MarshalJSON() ([]byte, error)
func (*MetadataType) ParseMetadata ¶
func (t *MetadataType) ParseMetadata(target interface{}) (err error)
Parses the metadata into the target interface
func (*MetadataType) UnmarshalJSON ¶
func (t *MetadataType) UnmarshalJSON(bs []byte) (err error)
parses a type with this declaration, storing what it needs into metadata and type
type Operation ¶
type Operation interface {
Run(env Environment) error
}
type OperationFactory ¶
type OperationFactory interface { Create(CreateOperation) (Operation, error) Key() string }
type PanelClaims ¶
type Requirements ¶ added in v2.5.0
type Requirements struct { Binaries []string `json:"binaries,omitempty"` OS string `json:"os,omitempty"` Arch string `json:"arch,omitempty"` }
func (Requirements) Test ¶ added in v2.5.0
func (r Requirements) Test(server Server) error
type SFTPAuthorization ¶
type SFTPAuthorization interface {
Validate(username, password string) (perms *ssh.Permissions, err error)
}
type Server ¶
type Server struct { Type Variables map[string]Variable `json:"data,omitempty"` Display string `json:"display,omitempty"` Environment interface{} `json:"environment,omitempty"` SupportedEnvironments []interface{} `json:"supportedEnvironments,omitempty"` Installation []interface{} `json:"install,omitempty"` Uninstallation []interface{} `json:"uninstall,omitempty"` Identifier string `json:"id,omitempty"` Execution Execution `json:"run,omitempty"` Tasks map[string]Task `json:"tasks,omitempty"` Requirements Requirements `json:"requirements,omitempty"` }
type ServerData ¶
type ServerDataAdmin ¶
type ServerDataAdmin struct {
*Server
}
type ServerIdResponse ¶
type ServerIdResponse struct {
Id string `json:"id"`
}
type ServerLogs ¶
type ServerRunning ¶
type ServerRunning struct {
Running bool `json:"running"`
}
type ServerStats ¶
type ServerTasks ¶ added in v2.3.2
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
func (*Socket) WriteMessage ¶
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
func CreateTracker ¶
func CreateTracker() *Tracker
type Variable ¶
type Variable struct { Type Description string `json:"desc,omitempty"` Display string `json:"display,omitempty"` Internal bool `json:"internal,omitempty"` Required bool `json:"required,omitempty"` Value interface{} `json:"value,omitempty"` UserEditable bool `json:"userEdit,omitempty"` Options []VariableOption `json:"options,omitempty"` }
type VariableOption ¶
type VariableOption struct { Value interface{} `json:"value"` Display string `json:"display"` }
Source Files ¶
- arguments.go
- authorization.go
- cache.go
- claims.go
- client.go
- close.go
- compression.go
- conversion.go
- engine.go
- environment.go
- environmentfactory.go
- errors.go
- files.go
- filesystem.go
- filesystem_linux.go
- groups_linux.go
- host.go
- httpmodels.go
- interface.go
- kernel.go
- kernel_linux.go
- mappings.go
- message.go
- operation.go
- scopes.go
- server.go
- socket.go
- tracker.go
- typewithmetadata.go
- utils.go
- version.go
Click to show internal directories.
Click to hide internal directories.