config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_EXECUTOR = "shell"
View Source
const PTY_EXECUTOR = "pty"

Variables

View Source
var (
	ConfigData *ConfigStruct
	ConfigPath string
)
View Source
var DefaultExecutorConfig = InternalExecutors[0]
View Source
var InternalExecutors = []*ConfigExecutorStruct{
	{
		Name:     DEFAULT_EXECUTOR,
		Type:     "shell",
		Config:   "--ts-oneshot",
		Internal: true,
		Global:   true,
		Comment:  "The default executor. Exec cmdline using system shell. It's always open and can not be closed.",
	},
	{
		Name:     PTY_EXECUTOR,
		Type:     "shell",
		Internal: true,
		Comment:  "The system shell pty (pseudo terminal) executor.",
	},
}
View Source
var PtyExecutorConfig = InternalExecutors[1]

Functions

func AddCmd

func AddCmd(cmd *ConfigCmdStruct) error

func AddExecutor

func AddExecutor(executor *ConfigExecutorStruct) error

func AddExecutorButton

func AddExecutorButton(name string, button string) error

func ClearExecutorButtons

func ClearExecutorButtons(name string) error

func DelCmd

func DelCmd(name string) error

func DelExecutor

func DelExecutor(name string) error

func DelExecutorButton

func DelExecutorButton(name string, payload string) error

func GetExecutorButtons

func GetExecutorButtons(name string) (buttons []string)

func InitConfig

func InitConfig() error

func SetExecutorSecret

func SetExecutorSecret(name string, secret string) error

Set or update the secret of executor

Types

type ConfigCmdStruct

type ConfigCmdStruct struct {
	Name string
	Cmd  string
}

func GetCmd

func GetCmd(name string) *ConfigCmdStruct

type ConfigExecutorStruct

type ConfigExecutorStruct struct {
	Name     string
	Type     string
	Config   string
	Secret   string
	Buttons  []string // cmdline shortcuts
	Comment  string
	Internal bool
	Global   bool // one instance can be shared accross all users
}

func GetExecutor

func GetExecutor(name string) *ConfigExecutorStruct

func (*ConfigExecutorStruct) Desc

func (ecs *ConfigExecutorStruct) Desc() (desc string)

get a descriptive string of it's type and config combined

type ConfigServiceStruct

type ConfigServiceStruct struct {
	Name     string
	Hostname string
	Backend  string
	Headers  [][2]string
	Comment  string
}

Securely publish intranet (e.g.: 127.0.0.1) service to tg user

func (*ConfigServiceStruct) GetName

func (sc *ConfigServiceStruct) GetName() string

type ConfigStruct

type ConfigStruct struct {
	ShellExecutor        string // by default, use "cmd /C" on windows, "/bin/bash -c" on other platforms.
	ShellExecutorButtons []string
	TelegramToken        string // tg bot token
	Cmds                 []*ConfigCmdStruct
	Executors            []*ConfigExecutorStruct
	Services             []*ConfigServiceStruct
	Whitelist            []int64
	// should be same as server's OpenSSH HostKeyAlgorithms. Default values can be found using `man ssh_config`.
	// Note it's not same as `ssh -Q HostKeyAlgorithms`,
	// which outputs all available algorithms, not actual used algorithms.
	SshHostKeyAlgorithms []string
	ServicesPort         int
	ServicesAddr         string // 0.0.0.0
	ServicesPublicPort   int
	ServicesHttps        bool
	Secret               string
}

func (*ConfigStruct) ResetSecret

func (cs *ConfigStruct) ResetSecret() error

Jump to

Keyboard shortcuts

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