engine

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvironLocal     = `local`
	EnvironContainer = `container`
)
View Source
const (
	NgingConfigPrefix = `nging_`
)

Variables

View Source
var (
	ErrNotSetCertContainerDir          = errors.New(`CertContainerDir value is not set`)
	ErrNotSetCertLocalDir              = errors.New(`CertLocalDir value is not set`)
	ErrNotSetEngineConfigLocalFile     = errors.New(`EngineConfigLocalFile value is not set`)
	ErrNotSetEngineConfigContainerFile = errors.New(`EngineConfigContainerFile value is not set`)
	ErrNotSetVhostConfigLocalDir       = errors.New(`VhostConfigLocalDir value is not set`)
	ErrNotSetVhostConfigContainerDir   = errors.New(`VhostConfigContainerDir value is not set`)
)
View Source
var CertUpdaters = echo.NewKVData()
View Source
var Engines = echo.NewKVData()
View Source
var Environs = echo.NewKVData().Add(EnvironLocal, `本机`).Add(EnvironContainer, `容器`)

Functions

func CertbotSanitizedDomain added in v1.4.11

func CertbotSanitizedDomain(domain string) (string, error)

CertbotSanitizedDomain Make sure no funny chars are in the cert names (like wildcards ;)).

func FixEngineConfigFile

func FixEngineConfigFile(cfg Configer, deleteMode ...bool) (bool, error)

func GetCtxStderr

func GetCtxStderr(c context.Context) io.Writer

func GetCtxStdout

func GetCtxStdout(c context.Context) io.Writer

func LegoSanitizedDomain added in v1.4.11

func LegoSanitizedDomain(domain string) (string, error)

LegoSanitizedDomain Make sure no funny chars are in the cert names (like wildcards ;)).

func MakeCertbotCommand added in v1.4.13

func MakeCertbotCommand(data RequestCertUpdate) (command string, args []string, env []string)

http://coscms.com/.well-known/acme-challenge/Ito***l4-Fh7O5FpaAA*************LI3vTPo 申请: certbot certonly --webroot -d example.com --email info@example.com -w /var/www/_letsencrypt -n --agree-tos --force-renewal 更新 certbot renew 更新所有 certbot renew --cert-name example.com --force-renewal documention: https://eff-certbot.readthedocs.io/en/latest/using.html#certbot-commands

certbot certonly \ --dns-cloudflare \ --dns-cloudflare-credentials ~/.secrets/certbot/cloudflare.ini \ -d example.com \ -d www.example.com

func MakeLegoCommand added in v1.4.13

func MakeLegoCommand(data RequestCertUpdate) (command string, args []string, env []string)

申请: lego --accept-tos --email you@example.com --http --http.webroot /path/to/webroot --domains example.com run https://go-acme.github.io/lego/usage/cli/obtain-a-certificate/ 更新: lego --email="you@example.com" --domains="example.com" --http renew https://go-acme.github.io/lego/usage/cli/renew-a-certificate/

CLOUDFLARE_EMAIL="you@example.com" \ CLOUDFLARE_API_KEY="yourprivatecloudflareapikey" \ lego --email "you@example.com" --dns cloudflare --domains "example.org" run

func NewSocketClient added in v1.4.19

func NewSocketClient(sockAddr string) *http.Client

/var/run/docker.sock

func ParseContainerInfo

func ParseContainerInfo(parts []string) (string, string)

func ParseSocketAddr added in v1.4.19

func ParseSocketAddr(sockAddr string) string

func PostDocker added in v1.4.19

func PostDocker(containerID string, data RequestDockerExec) error

func RemoveCertFile

func RemoveCertFile(cfg Configer, id uint) error

func RemoveVhostConfigFile

func RemoveVhostConfigFile(cfg Configer, id uint) error

如果 id 为 0 代表删除此配置下的所有其它文件

func RenewCert added in v1.4.10

func RenewCert(cfg Configer, ctx echo.Context, id uint, domains []string, email string, isObtain bool) error

func RenewCertByCertbot added in v1.4.11

func RenewCertByCertbot(ctx context.Context, data RequestCertUpdate) error

func RenewCertByLego added in v1.4.11

func RenewCertByLego(ctx context.Context, data RequestCertUpdate) error

func Thirdparty

func Thirdparty() []echo.KV

func WithStderr

func WithStderr(c context.Context, w io.Writer) context.Context

func WithStdout

func WithStdout(c context.Context, w io.Writer) context.Context

func WithStdoutStderr

func WithStdoutStderr(c context.Context, w ...io.Writer) context.Context

Types

type APIClient

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

func NewAPIClient

func NewAPIClient(certPEMBlock, keyPEMBlock []byte) (*APIClient, error)

NewAPIClient("cert.pem", "key.pem")

func (*APIClient) Post

func (a *APIClient) Post(url string, data interface{}) error

Post url=/v1.43/containers/{id}/exec

func (*APIClient) SetClient added in v1.4.19

func (a *APIClient) SetClient(client *http.Client) *APIClient

type CertExecuteor added in v1.4.11

type CertExecuteor func(ctx context.Context, data RequestCertUpdate) error

type CertFileRemover

type CertFileRemover interface {
	RemoveCertFile(id uint) error
}

type CertPathFormat

type CertPathFormat struct {
	Cert  string
	Key   string
	Trust string
}

type CertPathFormatGetter

type CertPathFormatGetter interface {
	GetCertPathFormat(ctx echo.Context) CertPathFormat
}

type CertPathFormatWithUpdater added in v1.4.11

type CertPathFormatWithUpdater struct {
	CertPathFormat
	LocalUpdater     string // certbot / lego
	ContainerUpdater string // certbot / lego
	SaveDir          string
}

func (*CertPathFormatWithUpdater) AutoDetect added in v1.4.11

func (c *CertPathFormatWithUpdater) AutoDetect(ctx echo.Context)

func (*CertPathFormatWithUpdater) CertContainerUpdater added in v1.4.11

func (c *CertPathFormatWithUpdater) CertContainerUpdater() string

func (*CertPathFormatWithUpdater) CertLocalUpdater added in v1.4.11

func (c *CertPathFormatWithUpdater) CertLocalUpdater() string

func (*CertPathFormatWithUpdater) CopyFrom added in v1.4.11

func (*CertPathFormatWithUpdater) SetCertLocalUpdater added in v1.4.11

func (c *CertPathFormatWithUpdater) SetCertLocalUpdater(name string)

type CertRenewaler

type CertRenewaler interface {
	RenewCert(ctx echo.Context, id uint, domains []string, email string, isObtain bool) error
}

type CertUpdater added in v1.4.11

type CertUpdater struct {
	Update          CertExecuteor
	MakeCommand     func(RequestCertUpdate) (command string, args []string, env []string)
	PathFormat      CertPathFormat
	DomainSanitizer DomainSanitizer
}

type CertUpdaterGetter added in v1.4.11

type CertUpdaterGetter interface {
	CertUpdater() string
}

type CommonConfig

type CommonConfig struct {
	ID                        string
	Command                   string
	Endpoint                  string
	CmdWithConfig             bool
	WorkDir                   string
	EnvVars                   []string
	Environ                   string
	EngineConfigLocalFile     string
	EngineConfigContainerFile string
	VhostConfigLocalDir       string
	VhostConfigContainerDir   string
	CertLocalDir              string
	CertContainerDir          string
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(engineName, templateFile string) *CommonConfig

func (*CommonConfig) APIPost added in v1.4.13

func (c *CommonConfig) APIPost(ctx context.Context, data RequestDockerExec) error

func (*CommonConfig) CopyFrom

func (c *CommonConfig) CopyFrom(m *dbschema.NgingVhostServer)

func (*CommonConfig) EngineConfigFile

func (c *CommonConfig) EngineConfigFile() string

func (*CommonConfig) Exec

func (c *CommonConfig) Exec(ctx context.Context, args ...string) ([]byte, error)

func (*CommonConfig) FixVhostDirPath

func (c *CommonConfig) FixVhostDirPath(vhostDir string) string

func (*CommonConfig) GetCertContainerDir

func (c *CommonConfig) GetCertContainerDir() string

func (*CommonConfig) GetCertLocalDir

func (c *CommonConfig) GetCertLocalDir() string

func (*CommonConfig) GetEngine

func (c *CommonConfig) GetEngine() string

func (*CommonConfig) GetEngineConfigContainerFile

func (c *CommonConfig) GetEngineConfigContainerFile() string

func (*CommonConfig) GetEngineConfigLocalFile

func (c *CommonConfig) GetEngineConfigLocalFile() string

func (*CommonConfig) GetEnviron

func (c *CommonConfig) GetEnviron() string

func (*CommonConfig) GetIdent

func (c *CommonConfig) GetIdent() string

func (*CommonConfig) GetTemplateFile

func (c *CommonConfig) GetTemplateFile() string

func (*CommonConfig) GetVhostConfigContainerDir

func (c *CommonConfig) GetVhostConfigContainerDir() string

func (*CommonConfig) GetVhostConfigLocalDir

func (c *CommonConfig) GetVhostConfigLocalDir() string

func (*CommonConfig) RemoveDir

func (c *CommonConfig) RemoveDir(typeName string, rootDir string, prefix string, extensions ...string) error

func (*CommonConfig) VhostConfigDir

func (c *CommonConfig) VhostConfigDir() string

type Configer

type Configer interface {
	GetVhostConfigLocalDirAbs() (string, error)
	GetTemplateFile() string
	GetIdent() string
	GetEngine() string
	GetEnviron() string
	GetCertLocalDir() string
	GetCertContainerDir() string
	GetVhostConfigLocalDir() string
	GetVhostConfigContainerDir() string
	GetEngineConfigLocalFile() string
	GetEngineConfigContainerFile() string
}

type ContainerExec added in v1.4.19

type ContainerExec func(ctx context.Context, containerID string, cmd []string, env []string, outWriter io.Writer, errWriter io.Writer) error

type ContextKey

type ContextKey string
const CtxKeyStderr ContextKey = `stderr`
const CtxKeyStdout ContextKey = `stdout`

type DomainSanitizer added in v1.4.11

type DomainSanitizer func(string) (string, error)

type EngineConfigFileFixer

type EngineConfigFileFixer interface {
	FixEngineConfigFile(deleteMode ...bool) (bool, error)
}

type Enginer

type Enginer interface {
	Name() string
	ListConfig(ctx echo.Context) ([]Configer, error)
	BuildConfig(ctx echo.Context, m *dbschema.NgingVhostServer) Configer
	ReloadServer(ctx echo.Context, cfg Configer) error
	DefaultConfigDir() string
}

type IDResponse added in v1.4.17

type IDResponse struct {
	// The id of the newly created object.
	// Required: true
	ID string `json:"Id"`
}

type ParsedCommand

type ParsedCommand struct {
	Command         string
	Args            []string
	ContainerEngine string
	ContainerName   string
}

type RequestCertUpdate added in v1.4.13

type RequestCertUpdate struct {
	CmdPathPrefix  string
	Domains        []string
	Email          string
	CertSaveDir    string // 保存证书的目录
	CertVerifyDir  string // 保存证书验证素材的目录
	Obtain         bool
	DNSProvider    string
	DNSCredentials string
	DNSWaitSeconds int
	Env            []string
}

type RequestDockerExec

type RequestDockerExec struct {
	AttachStdin  bool     `json:",omitempty"`
	AttachStdout bool     `json:",omitempty"`
	AttachStderr bool     `json:",omitempty"`
	DetachKeys   string   `json:",omitempty"` //"ctrl-p,ctrl-q",
	Tty          bool     `json:",omitempty"`
	Cmd          []string `json:",omitempty"` // ["date"],
	Env          []string `json:",omitempty"` // ["FOO=bar","BAZ=quux"]
}

documention: https://docs.docker.com/engine/api/v1.43/#tag/Exec/operation/ContainerExec API: /containers/{id}/exec

type RequestDockerExecStart added in v1.4.17

type RequestDockerExecStart struct {
	Detach bool
	Tty    bool
}

type VhostConfigRemover

type VhostConfigRemover interface {
	RemoveVhostConfig(id uint) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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