Documentation ¶
Index ¶
- Constants
- Variables
- func CertbotSanitizedDomain(domain string) (string, error)
- func FixEngineConfigFile(cfg Configer, deleteMode ...bool) (bool, error)
- func GetCtxStderr(c context.Context) io.Writer
- func GetCtxStdout(c context.Context) io.Writer
- func LegoSanitizedDomain(domain string) (string, error)
- func MakeCertbotCommand(data RequestCertUpdate) (command string, args []string, env []string)
- func MakeLegoCommand(data RequestCertUpdate) (command string, args []string, env []string)
- func NewSocketClient(sockAddr string) *http.Client
- func ParseContainerInfo(parts []string) (string, string)
- func ParseSocketAddr(sockAddr string) string
- func PostDocker(containerID string, data RequestDockerExec) error
- func RemoveCertFile(cfg Configer, id uint) error
- func RemoveVhostConfigFile(cfg Configer, id uint) error
- func RenewCert(cfg Configer, ctx echo.Context, id uint, domains []string, email string, ...) error
- func RenewCertByCertbot(ctx context.Context, data RequestCertUpdate) error
- func RenewCertByLego(ctx context.Context, data RequestCertUpdate) error
- func Thirdparty() []echo.KV
- func WithStderr(c context.Context, w io.Writer) context.Context
- func WithStdout(c context.Context, w io.Writer) context.Context
- func WithStdoutStderr(c context.Context, w ...io.Writer) context.Context
- type APIClient
- type CertExecuteor
- type CertFileRemover
- type CertPathFormat
- type CertPathFormatGetter
- type CertPathFormatWithUpdater
- func (c *CertPathFormatWithUpdater) AutoDetect(ctx echo.Context)
- func (c *CertPathFormatWithUpdater) CertContainerUpdater() string
- func (c *CertPathFormatWithUpdater) CertLocalUpdater() string
- func (c *CertPathFormatWithUpdater) CopyFrom(m *dbschema.NgingVhostServer)
- func (c *CertPathFormatWithUpdater) SetCertLocalUpdater(name string)
- type CertRenewaler
- type CertUpdater
- type CertUpdaterGetter
- type CommonConfig
- func (c *CommonConfig) APIPost(ctx context.Context, data RequestDockerExec) error
- func (c *CommonConfig) CopyFrom(m *dbschema.NgingVhostServer)
- func (c *CommonConfig) EngineConfigFile() string
- func (c *CommonConfig) Exec(ctx context.Context, args ...string) ([]byte, error)
- func (c *CommonConfig) FixVhostDirPath(vhostDir string) string
- func (c *CommonConfig) GetCertContainerDir() string
- func (c *CommonConfig) GetCertLocalDir() string
- func (c *CommonConfig) GetEngine() string
- func (c *CommonConfig) GetEngineConfigContainerFile() string
- func (c *CommonConfig) GetEngineConfigLocalFile() string
- func (c *CommonConfig) GetEnviron() string
- func (c *CommonConfig) GetIdent() string
- func (c *CommonConfig) GetTemplateFile() string
- func (c *CommonConfig) GetVhostConfigContainerDir() string
- func (c *CommonConfig) GetVhostConfigLocalDir() string
- func (c *CommonConfig) RemoveDir(typeName string, rootDir string, prefix string, extensions ...string) error
- func (c *CommonConfig) VhostConfigDir() string
- type Configer
- type ContainerExec
- type ContextKey
- type DomainSanitizer
- type EngineConfigFileFixer
- type Enginer
- type IDResponse
- type ParsedCommand
- type RequestCertUpdate
- type RequestDockerExec
- type RequestDockerExecStart
- type VhostConfigRemover
Constants ¶
const ( EnvironLocal = `local` EnvironContainer = `container` )
const (
NgingConfigPrefix = `nging_`
)
Variables ¶
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`) )
var CertUpdaters = echo.NewKVData()
var Engines = echo.NewKVData()
var Environs = echo.NewKVData().Add(EnvironLocal, `本机`).Add(EnvironContainer, `容器`)
Functions ¶
func CertbotSanitizedDomain ¶ added in v1.4.11
CertbotSanitizedDomain Make sure no funny chars are in the cert names (like wildcards ;)).
func LegoSanitizedDomain ¶ added in v1.4.11
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
/var/run/docker.sock
func ParseContainerInfo ¶
func ParseSocketAddr ¶ added in v1.4.19
func PostDocker ¶ added in v1.4.19
func PostDocker(containerID string, data RequestDockerExec) error
func RemoveCertFile ¶
func RemoveVhostConfigFile ¶
如果 id 为 0 代表删除此配置下的所有其它文件
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 ¶
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
func NewAPIClient ¶
NewAPIClient("cert.pem", "key.pem")
type CertExecuteor ¶ added in v1.4.11
type CertExecuteor func(ctx context.Context, data RequestCertUpdate) error
type CertFileRemover ¶
type CertPathFormat ¶
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 (c *CertPathFormatWithUpdater) CopyFrom(m *dbschema.NgingVhostServer)
func (*CertPathFormatWithUpdater) SetCertLocalUpdater ¶ added in v1.4.11
func (c *CertPathFormatWithUpdater) SetCertLocalUpdater(name string)
type CertRenewaler ¶
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) 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) 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 ContextKey ¶
type ContextKey string
const CtxKeyStderr ContextKey = `stderr`
const CtxKeyStdout ContextKey = `stdout`
type DomainSanitizer ¶ added in v1.4.11
type EngineConfigFileFixer ¶
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 RequestCertUpdate ¶ added in v1.4.13
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