mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-08 06:26:38 +08:00
feat: add .user.ini for php website (#8782)
This commit is contained in:
parent
8e808903fc
commit
6bd9bb7c06
9 changed files with 294 additions and 273 deletions
|
@ -188,6 +188,7 @@ func SyncRuntimesStatus(runtimes []model.Runtime) error {
|
||||||
case "restarting":
|
case "restarting":
|
||||||
runtimes[index].Status = constant.StatusRestarting
|
runtimes[index].Status = constant.StatusRestarting
|
||||||
}
|
}
|
||||||
|
_ = runtimeRepo.Save(&runtimes[index])
|
||||||
delete(runtimeContainer, contain.Names[0])
|
delete(runtimeContainer, contain.Names[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,6 +422,15 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
||||||
if err = createWafConfig(website, domains); err != nil {
|
if err = createWafConfig(website, domains); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if create.Type == constant.Runtime {
|
||||||
|
runtime, err = runtimeRepo.GetFirst(context.Background(), repo.WithByID(create.RuntimeID))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if runtime.Type == constant.RuntimePHP && runtime.Resource == constant.ResourceAppstore {
|
||||||
|
createPHPConfig(website)
|
||||||
|
}
|
||||||
|
}
|
||||||
tx, ctx := helper.GetTxAndContext()
|
tx, ctx := helper.GetTxAndContext()
|
||||||
defer tx.Rollback()
|
defer tx.Rollback()
|
||||||
if err = websiteRepo.Create(ctx, website); err != nil {
|
if err = websiteRepo.Create(ctx, website); err != nil {
|
||||||
|
|
|
@ -349,6 +349,13 @@ func createAllWebsitesWAFConfig(websites []model.Website) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createPHPConfig(website *model.Website) {
|
||||||
|
fileOp := files.NewFileOp()
|
||||||
|
userIniPath := path.Join(GetSitePath(*website, SiteIndexDir), ".user.ini")
|
||||||
|
_ = fileOp.CreateFile(userIniPath)
|
||||||
|
_ = fileOp.SaveFile(userIniPath, fmt.Sprintf("open_basedir=/www/sites/%s/index", website.Alias), 0644)
|
||||||
|
}
|
||||||
|
|
||||||
func createWafConfig(website *model.Website, domains []model.WebsiteDomain) error {
|
func createWafConfig(website *model.Website, domains []model.WebsiteDomain) error {
|
||||||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -46,6 +46,23 @@ const (
|
||||||
KeyRSA4096 = certcrypto.RSA4096
|
KeyRSA4096 = certcrypto.RSA4096
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type AcmeUser struct {
|
||||||
|
Email string
|
||||||
|
Registration *registration.Resource
|
||||||
|
Key crypto.PrivateKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *AcmeUser) GetEmail() string {
|
||||||
|
return u.Email
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *AcmeUser) GetRegistration() *registration.Resource {
|
||||||
|
return u.Registration
|
||||||
|
}
|
||||||
|
func (u *AcmeUser) GetPrivateKey() crypto.PrivateKey {
|
||||||
|
return u.Key
|
||||||
|
}
|
||||||
|
|
||||||
func GetPrivateKey(priKey crypto.PrivateKey, keyType KeyType) ([]byte, error) {
|
func GetPrivateKey(priKey crypto.PrivateKey, keyType KeyType) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
marshal []byte
|
marshal []byte
|
||||||
|
|
|
@ -2,25 +2,7 @@ package ssl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto"
|
"crypto"
|
||||||
"encoding/json"
|
|
||||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/go-acme/lego/v4/providers/dns/alidns"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/clouddns"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/cloudflare"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/cloudns"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/dnspod"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/freemyip"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/godaddy"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/huaweicloud"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/namecheap"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/namedotcom"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/namesilo"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/rainyun"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/spaceship"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/tencentcloud"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/vercel"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/volcengine"
|
|
||||||
"github.com/go-acme/lego/v4/providers/dns/westcn"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -33,39 +15,15 @@ import (
|
||||||
"github.com/go-acme/lego/v4/challenge/dns01"
|
"github.com/go-acme/lego/v4/challenge/dns01"
|
||||||
"github.com/go-acme/lego/v4/lego"
|
"github.com/go-acme/lego/v4/lego"
|
||||||
"github.com/go-acme/lego/v4/providers/http/webroot"
|
"github.com/go-acme/lego/v4/providers/http/webroot"
|
||||||
"github.com/go-acme/lego/v4/registration"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AcmeUser struct {
|
|
||||||
Email string
|
|
||||||
Registration *registration.Resource
|
|
||||||
Key crypto.PrivateKey
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *AcmeUser) GetEmail() string {
|
|
||||||
return u.Email
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *AcmeUser) GetRegistration() *registration.Resource {
|
|
||||||
return u.Registration
|
|
||||||
}
|
|
||||||
func (u *AcmeUser) GetPrivateKey() crypto.PrivateKey {
|
|
||||||
return u.Key
|
|
||||||
}
|
|
||||||
|
|
||||||
type AcmeClientOption func(*AcmeClientOptions)
|
type AcmeClientOption func(*AcmeClientOptions)
|
||||||
|
|
||||||
type AcmeClientOptions struct {
|
type AcmeClientOptions struct {
|
||||||
SystemProxy *dto.SystemProxy
|
SystemProxy *dto.SystemProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithSystemProxy(proxy *dto.SystemProxy) AcmeClientOption {
|
|
||||||
return func(opts *AcmeClientOptions) {
|
|
||||||
opts.SystemProxy = proxy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type AcmeClient struct {
|
type AcmeClient struct {
|
||||||
Config *lego.Config
|
Config *lego.Config
|
||||||
Client *lego.Client
|
Client *lego.Client
|
||||||
|
@ -85,205 +43,6 @@ func NewAcmeClient(acmeAccount *model.WebsiteAcmeAccount, systemProxy *dto.Syste
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type DnsType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
DnsPod DnsType = "DnsPod"
|
|
||||||
AliYun DnsType = "AliYun"
|
|
||||||
CloudFlare DnsType = "CloudFlare"
|
|
||||||
CloudDns DnsType = "CloudDns"
|
|
||||||
NameSilo DnsType = "NameSilo"
|
|
||||||
NameCheap DnsType = "NameCheap"
|
|
||||||
NameCom DnsType = "NameCom"
|
|
||||||
Godaddy DnsType = "Godaddy"
|
|
||||||
TencentCloud DnsType = "TencentCloud"
|
|
||||||
RainYun DnsType = "RainYun"
|
|
||||||
Volcengine DnsType = "Volcengine"
|
|
||||||
HuaweiCloud DnsType = "HuaweiCloud"
|
|
||||||
FreeMyIP DnsType = "FreeMyIP"
|
|
||||||
Vercel DnsType = "Vercel"
|
|
||||||
Spaceship DnsType = "Spaceship"
|
|
||||||
WestCN DnsType = "WestCN"
|
|
||||||
ClouDNS DnsType = "ClouDNS"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DNSParam struct {
|
|
||||||
ID string `json:"id"`
|
|
||||||
Token string `json:"token"`
|
|
||||||
AccessKey string `json:"accessKey"`
|
|
||||||
SecretKey string `json:"secretKey"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
APIkey string `json:"apiKey"`
|
|
||||||
APIUser string `json:"apiUser"`
|
|
||||||
APISecret string `json:"apiSecret"`
|
|
||||||
SecretID string `json:"secretID"`
|
|
||||||
ClientID string `json:"clientID"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
Region string `json:"region"`
|
|
||||||
Username string `json:"username"`
|
|
||||||
AuthID string `json:"authID"`
|
|
||||||
SubAuthID string `json:"subAuthID"`
|
|
||||||
AuthPassword string `json:"authPassword"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
propagationTimeout = 30 * time.Minute
|
|
||||||
pollingInterval = 10 * time.Second
|
|
||||||
ttl = 3600
|
|
||||||
dnsTimeOut = 30 * time.Minute
|
|
||||||
manualDnsTimeout = 10 * time.Minute
|
|
||||||
)
|
|
||||||
|
|
||||||
func getDNSProviderConfig(dnsType DnsType, params string) (challenge.Provider, error) {
|
|
||||||
var (
|
|
||||||
param DNSParam
|
|
||||||
p challenge.Provider
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
if err := json.Unmarshal([]byte(params), ¶m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
switch dnsType {
|
|
||||||
case DnsPod:
|
|
||||||
dnsPodConfig := dnspod.NewDefaultConfig()
|
|
||||||
dnsPodConfig.LoginToken = param.ID + "," + param.Token
|
|
||||||
dnsPodConfig.PropagationTimeout = propagationTimeout
|
|
||||||
dnsPodConfig.PollingInterval = pollingInterval
|
|
||||||
dnsPodConfig.TTL = ttl
|
|
||||||
p, err = dnspod.NewDNSProviderConfig(dnsPodConfig)
|
|
||||||
case AliYun:
|
|
||||||
alidnsConfig := alidns.NewDefaultConfig()
|
|
||||||
alidnsConfig.SecretKey = param.SecretKey
|
|
||||||
alidnsConfig.APIKey = param.AccessKey
|
|
||||||
alidnsConfig.PropagationTimeout = propagationTimeout
|
|
||||||
alidnsConfig.PollingInterval = pollingInterval
|
|
||||||
alidnsConfig.TTL = ttl
|
|
||||||
p, err = alidns.NewDNSProviderConfig(alidnsConfig)
|
|
||||||
case CloudFlare:
|
|
||||||
cloudflareConfig := cloudflare.NewDefaultConfig()
|
|
||||||
cloudflareConfig.AuthEmail = param.Email
|
|
||||||
cloudflareConfig.AuthToken = param.APIkey
|
|
||||||
cloudflareConfig.PropagationTimeout = propagationTimeout
|
|
||||||
cloudflareConfig.PollingInterval = pollingInterval
|
|
||||||
cloudflareConfig.TTL = ttl
|
|
||||||
p, err = cloudflare.NewDNSProviderConfig(cloudflareConfig)
|
|
||||||
case CloudDns:
|
|
||||||
clouddnsConfig := clouddns.NewDefaultConfig()
|
|
||||||
clouddnsConfig.ClientID = param.ClientID
|
|
||||||
clouddnsConfig.Email = param.Email
|
|
||||||
clouddnsConfig.Password = param.Password
|
|
||||||
clouddnsConfig.PropagationTimeout = propagationTimeout
|
|
||||||
clouddnsConfig.PollingInterval = pollingInterval
|
|
||||||
clouddnsConfig.TTL = ttl
|
|
||||||
p, err = clouddns.NewDNSProviderConfig(clouddnsConfig)
|
|
||||||
case NameCheap:
|
|
||||||
namecheapConfig := namecheap.NewDefaultConfig()
|
|
||||||
namecheapConfig.APIKey = param.APIkey
|
|
||||||
namecheapConfig.APIUser = param.APIUser
|
|
||||||
namecheapConfig.PropagationTimeout = propagationTimeout
|
|
||||||
namecheapConfig.PollingInterval = pollingInterval
|
|
||||||
namecheapConfig.TTL = ttl
|
|
||||||
p, err = namecheap.NewDNSProviderConfig(namecheapConfig)
|
|
||||||
case NameSilo:
|
|
||||||
nameSiloConfig := namesilo.NewDefaultConfig()
|
|
||||||
nameSiloConfig.APIKey = param.APIkey
|
|
||||||
nameSiloConfig.PropagationTimeout = propagationTimeout
|
|
||||||
nameSiloConfig.PollingInterval = pollingInterval
|
|
||||||
nameSiloConfig.TTL = ttl
|
|
||||||
p, err = namesilo.NewDNSProviderConfig(nameSiloConfig)
|
|
||||||
case Godaddy:
|
|
||||||
godaddyConfig := godaddy.NewDefaultConfig()
|
|
||||||
godaddyConfig.APIKey = param.APIkey
|
|
||||||
godaddyConfig.APISecret = param.APISecret
|
|
||||||
godaddyConfig.PropagationTimeout = propagationTimeout
|
|
||||||
godaddyConfig.PollingInterval = pollingInterval
|
|
||||||
godaddyConfig.TTL = ttl
|
|
||||||
p, err = godaddy.NewDNSProviderConfig(godaddyConfig)
|
|
||||||
case NameCom:
|
|
||||||
nameComConfig := namedotcom.NewDefaultConfig()
|
|
||||||
nameComConfig.APIToken = param.Token
|
|
||||||
nameComConfig.Username = param.APIUser
|
|
||||||
nameComConfig.PropagationTimeout = propagationTimeout
|
|
||||||
nameComConfig.PollingInterval = pollingInterval
|
|
||||||
nameComConfig.TTL = ttl
|
|
||||||
p, err = namedotcom.NewDNSProviderConfig(nameComConfig)
|
|
||||||
case TencentCloud:
|
|
||||||
tencentCloudConfig := tencentcloud.NewDefaultConfig()
|
|
||||||
tencentCloudConfig.SecretID = param.SecretID
|
|
||||||
tencentCloudConfig.SecretKey = param.SecretKey
|
|
||||||
tencentCloudConfig.PropagationTimeout = propagationTimeout
|
|
||||||
tencentCloudConfig.PollingInterval = pollingInterval
|
|
||||||
tencentCloudConfig.TTL = ttl
|
|
||||||
p, err = tencentcloud.NewDNSProviderConfig(tencentCloudConfig)
|
|
||||||
case RainYun:
|
|
||||||
rainyunConfig := rainyun.NewDefaultConfig()
|
|
||||||
rainyunConfig.APIKey = param.APIkey
|
|
||||||
rainyunConfig.PropagationTimeout = propagationTimeout
|
|
||||||
rainyunConfig.PollingInterval = pollingInterval
|
|
||||||
rainyunConfig.TTL = ttl
|
|
||||||
p, err = rainyun.NewDNSProviderConfig(rainyunConfig)
|
|
||||||
case Volcengine:
|
|
||||||
volcConfig := volcengine.NewDefaultConfig()
|
|
||||||
volcConfig.SecretKey = param.SecretKey
|
|
||||||
volcConfig.AccessKey = param.AccessKey
|
|
||||||
volcConfig.PropagationTimeout = propagationTimeout
|
|
||||||
volcConfig.PollingInterval = pollingInterval
|
|
||||||
volcConfig.TTL = ttl
|
|
||||||
p, err = volcengine.NewDNSProviderConfig(volcConfig)
|
|
||||||
case HuaweiCloud:
|
|
||||||
huaweiCloudConfig := huaweicloud.NewDefaultConfig()
|
|
||||||
huaweiCloudConfig.AccessKeyID = param.AccessKey
|
|
||||||
huaweiCloudConfig.SecretAccessKey = param.SecretKey
|
|
||||||
huaweiCloudConfig.Region = param.Region
|
|
||||||
huaweiCloudConfig.PropagationTimeout = propagationTimeout
|
|
||||||
huaweiCloudConfig.PollingInterval = pollingInterval
|
|
||||||
huaweiCloudConfig.TTL = int32(ttl)
|
|
||||||
p, err = huaweicloud.NewDNSProviderConfig(huaweiCloudConfig)
|
|
||||||
case FreeMyIP:
|
|
||||||
freeMyIpConfig := freemyip.NewDefaultConfig()
|
|
||||||
freeMyIpConfig.Token = param.Token
|
|
||||||
freeMyIpConfig.PropagationTimeout = propagationTimeout
|
|
||||||
freeMyIpConfig.PollingInterval = pollingInterval
|
|
||||||
p, err = freemyip.NewDNSProviderConfig(freeMyIpConfig)
|
|
||||||
case Vercel:
|
|
||||||
vercelConfig := vercel.NewDefaultConfig()
|
|
||||||
vercelConfig.AuthToken = param.Token
|
|
||||||
vercelConfig.PropagationTimeout = propagationTimeout
|
|
||||||
vercelConfig.PollingInterval = pollingInterval
|
|
||||||
p, err = vercel.NewDNSProviderConfig(vercelConfig)
|
|
||||||
case Spaceship:
|
|
||||||
spaceshipConfig := spaceship.NewDefaultConfig()
|
|
||||||
spaceshipConfig.APIKey = param.APIkey
|
|
||||||
spaceshipConfig.APISecret = param.APISecret
|
|
||||||
spaceshipConfig.PropagationTimeout = propagationTimeout
|
|
||||||
spaceshipConfig.PollingInterval = pollingInterval
|
|
||||||
spaceshipConfig.TTL = ttl
|
|
||||||
p, err = spaceship.NewDNSProviderConfig(spaceshipConfig)
|
|
||||||
case WestCN:
|
|
||||||
westcnConfig := westcn.NewDefaultConfig()
|
|
||||||
westcnConfig.Username = param.Username
|
|
||||||
westcnConfig.Password = param.Password
|
|
||||||
westcnConfig.PropagationTimeout = propagationTimeout
|
|
||||||
westcnConfig.PollingInterval = pollingInterval
|
|
||||||
westcnConfig.TTL = ttl
|
|
||||||
p, err = westcn.NewDNSProviderConfig(westcnConfig)
|
|
||||||
|
|
||||||
case ClouDNS:
|
|
||||||
cloudnsConfig := cloudns.NewDefaultConfig()
|
|
||||||
cloudnsConfig.AuthID = param.AuthID
|
|
||||||
cloudnsConfig.SubAuthID = param.SubAuthID
|
|
||||||
cloudnsConfig.AuthPassword = param.AuthPassword
|
|
||||||
cloudnsConfig.PropagationTimeout = propagationTimeout
|
|
||||||
cloudnsConfig.PollingInterval = pollingInterval
|
|
||||||
cloudnsConfig.TTL = ttl
|
|
||||||
p, err = cloudns.NewDNSProviderConfig(cloudnsConfig)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return p, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *AcmeClient) UseDns(dnsType DnsType, params string, websiteSSL model.WebsiteSSL) error {
|
func (c *AcmeClient) UseDns(dnsType DnsType, params string, websiteSSL model.WebsiteSSL) error {
|
||||||
p, err := getDNSProviderConfig(dnsType, params)
|
p, err := getDNSProviderConfig(dnsType, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -313,7 +72,7 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string, websiteSSL model.Web
|
||||||
|
|
||||||
func (c *AcmeClient) UseManualDns(websiteSSL model.WebsiteSSL) error {
|
func (c *AcmeClient) UseManualDns(websiteSSL model.WebsiteSSL) error {
|
||||||
p, err := NewCustomDNSProviderManual(&ManualConfig{
|
p, err := NewCustomDNSProviderManual(&ManualConfig{
|
||||||
PropagationTimeout: propagationTimeout,
|
PropagationTimeout: 20 * time.Minute,
|
||||||
PollingInterval: pollingInterval,
|
PollingInterval: pollingInterval,
|
||||||
TTL: ttl,
|
TTL: ttl,
|
||||||
})
|
})
|
||||||
|
@ -381,36 +140,6 @@ type Resolve struct {
|
||||||
Err string
|
Err string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ManualConfig struct {
|
|
||||||
TTL int
|
|
||||||
PropagationTimeout time.Duration
|
|
||||||
PollingInterval time.Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
type CustomManualDnsProvider struct {
|
|
||||||
config *ManualConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCustomDNSProviderManual(config *ManualConfig) (*CustomManualDnsProvider, error) {
|
|
||||||
return &CustomManualDnsProvider{config}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *CustomManualDnsProvider) Present(domain, token, keyAuth string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *CustomManualDnsProvider) CleanUp(domain, token, keyAuth string) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *CustomManualDnsProvider) Sequential() time.Duration {
|
|
||||||
return manualDnsTimeout
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *CustomManualDnsProvider) Timeout() (timeout, interval time.Duration) {
|
|
||||||
return p.config.PropagationTimeout, p.config.PollingInterval
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *AcmeClient) GetDNSResolve(domains []string) (map[string]Resolve, error) {
|
func (c *AcmeClient) GetDNSResolve(domains []string) (map[string]Resolve, error) {
|
||||||
core, err := api.New(c.Config.HTTPClient, c.Config.UserAgent, c.Config.CADirURL, c.User.Registration.URI, c.User.Key)
|
core, err := api.New(c.Config.HTTPClient, c.Config.UserAgent, c.Config.CADirURL, c.User.Registration.URI, c.User.Key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -462,6 +191,7 @@ func (c *AcmeClient) GetDNSResolve(domains []string) (map[string]Resolve, error)
|
||||||
if strings.HasPrefix(domain, "*.") && strings.Contains(fqdn, "*.") {
|
if strings.HasPrefix(domain, "*.") && strings.Contains(fqdn, "*.") {
|
||||||
fqdn = strings.Replace(fqdn, "*.", "", 1)
|
fqdn = strings.Replace(fqdn, "*.", "", 1)
|
||||||
}
|
}
|
||||||
|
_, _ = dns01.FindZoneByFqdn(challengeInfo.EffectiveFQDN)
|
||||||
resolves[domain] = Resolve{
|
resolves[domain] = Resolve{
|
||||||
Key: fqdn,
|
Key: fqdn,
|
||||||
Value: challengeInfo.Value,
|
Value: challengeInfo.Value,
|
||||||
|
|
33
agent/utils/ssl/custom_manual_provider.go
Normal file
33
agent/utils/ssl/custom_manual_provider.go
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
package ssl
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type ManualConfig struct {
|
||||||
|
TTL int
|
||||||
|
PropagationTimeout time.Duration
|
||||||
|
PollingInterval time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomManualDnsProvider struct {
|
||||||
|
config *ManualConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCustomDNSProviderManual(config *ManualConfig) (*CustomManualDnsProvider, error) {
|
||||||
|
return &CustomManualDnsProvider{config}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *CustomManualDnsProvider) Present(domain, token, keyAuth string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *CustomManualDnsProvider) CleanUp(domain, token, keyAuth string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *CustomManualDnsProvider) Sequential() time.Duration {
|
||||||
|
return manualDnsTimeout
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *CustomManualDnsProvider) Timeout() (timeout, interval time.Duration) {
|
||||||
|
return p.config.PropagationTimeout, p.config.PollingInterval
|
||||||
|
}
|
223
agent/utils/ssl/dns_provider.go
Normal file
223
agent/utils/ssl/dns_provider.go
Normal file
|
@ -0,0 +1,223 @@
|
||||||
|
package ssl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/go-acme/lego/v4/challenge"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/alidns"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/clouddns"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/cloudflare"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/cloudns"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/dnspod"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/freemyip"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/godaddy"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/huaweicloud"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/namecheap"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/namedotcom"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/namesilo"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/rainyun"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/spaceship"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/tencentcloud"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/vercel"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/volcengine"
|
||||||
|
"github.com/go-acme/lego/v4/providers/dns/westcn"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DnsType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
DnsPod DnsType = "DnsPod"
|
||||||
|
AliYun DnsType = "AliYun"
|
||||||
|
CloudFlare DnsType = "CloudFlare"
|
||||||
|
CloudDns DnsType = "CloudDns"
|
||||||
|
NameSilo DnsType = "NameSilo"
|
||||||
|
NameCheap DnsType = "NameCheap"
|
||||||
|
NameCom DnsType = "NameCom"
|
||||||
|
Godaddy DnsType = "Godaddy"
|
||||||
|
TencentCloud DnsType = "TencentCloud"
|
||||||
|
RainYun DnsType = "RainYun"
|
||||||
|
Volcengine DnsType = "Volcengine"
|
||||||
|
HuaweiCloud DnsType = "HuaweiCloud"
|
||||||
|
FreeMyIP DnsType = "FreeMyIP"
|
||||||
|
Vercel DnsType = "Vercel"
|
||||||
|
Spaceship DnsType = "Spaceship"
|
||||||
|
WestCN DnsType = "WestCN"
|
||||||
|
ClouDNS DnsType = "ClouDNS"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DNSParam struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Token string `json:"token"`
|
||||||
|
AccessKey string `json:"accessKey"`
|
||||||
|
SecretKey string `json:"secretKey"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
APIkey string `json:"apiKey"`
|
||||||
|
APIUser string `json:"apiUser"`
|
||||||
|
APISecret string `json:"apiSecret"`
|
||||||
|
SecretID string `json:"secretID"`
|
||||||
|
ClientID string `json:"clientID"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
Region string `json:"region"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
AuthID string `json:"authID"`
|
||||||
|
SubAuthID string `json:"subAuthID"`
|
||||||
|
AuthPassword string `json:"authPassword"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
propagationTimeout = 30 * time.Minute
|
||||||
|
pollingInterval = 10 * time.Second
|
||||||
|
ttl = 3600
|
||||||
|
dnsTimeOut = 30 * time.Minute
|
||||||
|
manualDnsTimeout = 10 * time.Minute
|
||||||
|
)
|
||||||
|
|
||||||
|
func getDNSProviderConfig(dnsType DnsType, params string) (challenge.Provider, error) {
|
||||||
|
var (
|
||||||
|
param DNSParam
|
||||||
|
p challenge.Provider
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if err := json.Unmarshal([]byte(params), ¶m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch dnsType {
|
||||||
|
case DnsPod:
|
||||||
|
dnsPodConfig := dnspod.NewDefaultConfig()
|
||||||
|
dnsPodConfig.LoginToken = param.ID + "," + param.Token
|
||||||
|
dnsPodConfig.PropagationTimeout = propagationTimeout
|
||||||
|
dnsPodConfig.PollingInterval = pollingInterval
|
||||||
|
dnsPodConfig.TTL = ttl
|
||||||
|
p, err = dnspod.NewDNSProviderConfig(dnsPodConfig)
|
||||||
|
case AliYun:
|
||||||
|
alidnsConfig := alidns.NewDefaultConfig()
|
||||||
|
alidnsConfig.SecretKey = param.SecretKey
|
||||||
|
alidnsConfig.APIKey = param.AccessKey
|
||||||
|
alidnsConfig.PropagationTimeout = propagationTimeout
|
||||||
|
alidnsConfig.PollingInterval = pollingInterval
|
||||||
|
alidnsConfig.TTL = ttl
|
||||||
|
p, err = alidns.NewDNSProviderConfig(alidnsConfig)
|
||||||
|
case CloudFlare:
|
||||||
|
cloudflareConfig := cloudflare.NewDefaultConfig()
|
||||||
|
cloudflareConfig.AuthEmail = param.Email
|
||||||
|
cloudflareConfig.AuthToken = param.APIkey
|
||||||
|
cloudflareConfig.PropagationTimeout = propagationTimeout
|
||||||
|
cloudflareConfig.PollingInterval = pollingInterval
|
||||||
|
cloudflareConfig.TTL = ttl
|
||||||
|
p, err = cloudflare.NewDNSProviderConfig(cloudflareConfig)
|
||||||
|
case CloudDns:
|
||||||
|
clouddnsConfig := clouddns.NewDefaultConfig()
|
||||||
|
clouddnsConfig.ClientID = param.ClientID
|
||||||
|
clouddnsConfig.Email = param.Email
|
||||||
|
clouddnsConfig.Password = param.Password
|
||||||
|
clouddnsConfig.PropagationTimeout = propagationTimeout
|
||||||
|
clouddnsConfig.PollingInterval = pollingInterval
|
||||||
|
clouddnsConfig.TTL = ttl
|
||||||
|
p, err = clouddns.NewDNSProviderConfig(clouddnsConfig)
|
||||||
|
case NameCheap:
|
||||||
|
namecheapConfig := namecheap.NewDefaultConfig()
|
||||||
|
namecheapConfig.APIKey = param.APIkey
|
||||||
|
namecheapConfig.APIUser = param.APIUser
|
||||||
|
namecheapConfig.PropagationTimeout = propagationTimeout
|
||||||
|
namecheapConfig.PollingInterval = pollingInterval
|
||||||
|
namecheapConfig.TTL = ttl
|
||||||
|
p, err = namecheap.NewDNSProviderConfig(namecheapConfig)
|
||||||
|
case NameSilo:
|
||||||
|
nameSiloConfig := namesilo.NewDefaultConfig()
|
||||||
|
nameSiloConfig.APIKey = param.APIkey
|
||||||
|
nameSiloConfig.PropagationTimeout = propagationTimeout
|
||||||
|
nameSiloConfig.PollingInterval = pollingInterval
|
||||||
|
nameSiloConfig.TTL = ttl
|
||||||
|
p, err = namesilo.NewDNSProviderConfig(nameSiloConfig)
|
||||||
|
case Godaddy:
|
||||||
|
godaddyConfig := godaddy.NewDefaultConfig()
|
||||||
|
godaddyConfig.APIKey = param.APIkey
|
||||||
|
godaddyConfig.APISecret = param.APISecret
|
||||||
|
godaddyConfig.PropagationTimeout = propagationTimeout
|
||||||
|
godaddyConfig.PollingInterval = pollingInterval
|
||||||
|
godaddyConfig.TTL = ttl
|
||||||
|
p, err = godaddy.NewDNSProviderConfig(godaddyConfig)
|
||||||
|
case NameCom:
|
||||||
|
nameComConfig := namedotcom.NewDefaultConfig()
|
||||||
|
nameComConfig.APIToken = param.Token
|
||||||
|
nameComConfig.Username = param.APIUser
|
||||||
|
nameComConfig.PropagationTimeout = propagationTimeout
|
||||||
|
nameComConfig.PollingInterval = pollingInterval
|
||||||
|
nameComConfig.TTL = ttl
|
||||||
|
p, err = namedotcom.NewDNSProviderConfig(nameComConfig)
|
||||||
|
case TencentCloud:
|
||||||
|
tencentCloudConfig := tencentcloud.NewDefaultConfig()
|
||||||
|
tencentCloudConfig.SecretID = param.SecretID
|
||||||
|
tencentCloudConfig.SecretKey = param.SecretKey
|
||||||
|
tencentCloudConfig.PropagationTimeout = propagationTimeout
|
||||||
|
tencentCloudConfig.PollingInterval = pollingInterval
|
||||||
|
tencentCloudConfig.TTL = ttl
|
||||||
|
p, err = tencentcloud.NewDNSProviderConfig(tencentCloudConfig)
|
||||||
|
case RainYun:
|
||||||
|
rainyunConfig := rainyun.NewDefaultConfig()
|
||||||
|
rainyunConfig.APIKey = param.APIkey
|
||||||
|
rainyunConfig.PropagationTimeout = propagationTimeout
|
||||||
|
rainyunConfig.PollingInterval = pollingInterval
|
||||||
|
rainyunConfig.TTL = ttl
|
||||||
|
p, err = rainyun.NewDNSProviderConfig(rainyunConfig)
|
||||||
|
case Volcengine:
|
||||||
|
volcConfig := volcengine.NewDefaultConfig()
|
||||||
|
volcConfig.SecretKey = param.SecretKey
|
||||||
|
volcConfig.AccessKey = param.AccessKey
|
||||||
|
volcConfig.PropagationTimeout = propagationTimeout
|
||||||
|
volcConfig.PollingInterval = pollingInterval
|
||||||
|
volcConfig.TTL = ttl
|
||||||
|
p, err = volcengine.NewDNSProviderConfig(volcConfig)
|
||||||
|
case HuaweiCloud:
|
||||||
|
huaweiCloudConfig := huaweicloud.NewDefaultConfig()
|
||||||
|
huaweiCloudConfig.AccessKeyID = param.AccessKey
|
||||||
|
huaweiCloudConfig.SecretAccessKey = param.SecretKey
|
||||||
|
huaweiCloudConfig.Region = param.Region
|
||||||
|
huaweiCloudConfig.PropagationTimeout = propagationTimeout
|
||||||
|
huaweiCloudConfig.PollingInterval = pollingInterval
|
||||||
|
huaweiCloudConfig.TTL = int32(ttl)
|
||||||
|
p, err = huaweicloud.NewDNSProviderConfig(huaweiCloudConfig)
|
||||||
|
case FreeMyIP:
|
||||||
|
freeMyIpConfig := freemyip.NewDefaultConfig()
|
||||||
|
freeMyIpConfig.Token = param.Token
|
||||||
|
freeMyIpConfig.PropagationTimeout = propagationTimeout
|
||||||
|
freeMyIpConfig.PollingInterval = pollingInterval
|
||||||
|
p, err = freemyip.NewDNSProviderConfig(freeMyIpConfig)
|
||||||
|
case Vercel:
|
||||||
|
vercelConfig := vercel.NewDefaultConfig()
|
||||||
|
vercelConfig.AuthToken = param.Token
|
||||||
|
vercelConfig.PropagationTimeout = propagationTimeout
|
||||||
|
vercelConfig.PollingInterval = pollingInterval
|
||||||
|
p, err = vercel.NewDNSProviderConfig(vercelConfig)
|
||||||
|
case Spaceship:
|
||||||
|
spaceshipConfig := spaceship.NewDefaultConfig()
|
||||||
|
spaceshipConfig.APIKey = param.APIkey
|
||||||
|
spaceshipConfig.APISecret = param.APISecret
|
||||||
|
spaceshipConfig.PropagationTimeout = propagationTimeout
|
||||||
|
spaceshipConfig.PollingInterval = pollingInterval
|
||||||
|
spaceshipConfig.TTL = ttl
|
||||||
|
p, err = spaceship.NewDNSProviderConfig(spaceshipConfig)
|
||||||
|
case WestCN:
|
||||||
|
westcnConfig := westcn.NewDefaultConfig()
|
||||||
|
westcnConfig.Username = param.Username
|
||||||
|
westcnConfig.Password = param.Password
|
||||||
|
westcnConfig.PropagationTimeout = propagationTimeout
|
||||||
|
westcnConfig.PollingInterval = pollingInterval
|
||||||
|
westcnConfig.TTL = ttl
|
||||||
|
p, err = westcn.NewDNSProviderConfig(westcnConfig)
|
||||||
|
|
||||||
|
case ClouDNS:
|
||||||
|
cloudnsConfig := cloudns.NewDefaultConfig()
|
||||||
|
cloudnsConfig.AuthID = param.AuthID
|
||||||
|
cloudnsConfig.SubAuthID = param.SubAuthID
|
||||||
|
cloudnsConfig.AuthPassword = param.AuthPassword
|
||||||
|
cloudnsConfig.PropagationTimeout = propagationTimeout
|
||||||
|
cloudnsConfig.PollingInterval = pollingInterval
|
||||||
|
cloudnsConfig.TTL = ttl
|
||||||
|
p, err = cloudns.NewDNSProviderConfig(cloudnsConfig)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return p, nil
|
||||||
|
}
|
|
@ -73,6 +73,7 @@ const handleClose = () => {
|
||||||
em('close', true);
|
em('close', true);
|
||||||
open.value = false;
|
open.value = false;
|
||||||
bus.emit('refreshTask', true);
|
bus.emit('refreshTask', true);
|
||||||
|
bus.emit('refreshApp', true);
|
||||||
};
|
};
|
||||||
|
|
||||||
defineExpose({ openWithResourceID, openWithTaskID });
|
defineExpose({ openWithResourceID, openWithTaskID });
|
||||||
|
|
|
@ -282,7 +282,7 @@ const searchByName = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
bus.on('refreshTask', () => {
|
bus.on('refreshApp', () => {
|
||||||
search(req);
|
search(req);
|
||||||
});
|
});
|
||||||
if (router.currentRoute.value.query.install) {
|
if (router.currentRoute.value.query.install) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue