mirror of https://github.com/allinssl/allinssl
后端代码同步
parent
5124663aab
commit
312f10d06d
|
@ -37,8 +37,9 @@ func Deploy(cfg map[string]any, logger *public.Logger) error {
|
||||||
case "aliyun-cdn":
|
case "aliyun-cdn":
|
||||||
logger.Debug("部署到阿里云CDN...")
|
logger.Debug("部署到阿里云CDN...")
|
||||||
return DeployAliCdn(cfg)
|
return DeployAliCdn(cfg)
|
||||||
// case "aliyun-oss":
|
case "aliyun-oss":
|
||||||
|
logger.Debug("部署到阿里云OSS...")
|
||||||
|
return DeployOss(cfg)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("不支持的部署: %s", providerName)
|
return fmt.Errorf("不支持的部署: %s", providerName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ type SSHConfig struct {
|
||||||
Password string // 可选
|
Password string // 可选
|
||||||
PrivateKey string // 可选
|
PrivateKey string // 可选
|
||||||
Host string
|
Host string
|
||||||
Port string
|
Port float64
|
||||||
}
|
}
|
||||||
|
|
||||||
type RemoteFile struct {
|
type RemoteFile struct {
|
||||||
|
@ -45,7 +45,7 @@ func buildAuthMethods(password, privateKey string) ([]ssh.AuthMethod, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeMultipleFilesViaSSH(config SSHConfig, files []RemoteFile, preCmd, postCmd string) error {
|
func writeMultipleFilesViaSSH(config SSHConfig, files []RemoteFile, preCmd, postCmd string) error {
|
||||||
addr := fmt.Sprintf("%s:%s", config.Host, config.Port)
|
addr := fmt.Sprintf("%s:%d", config.Host, int(config.Port))
|
||||||
|
|
||||||
authMethods, err := buildAuthMethods(config.Password, config.PrivateKey)
|
authMethods, err := buildAuthMethods(config.Password, config.PrivateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -127,7 +127,7 @@ func DeploySSH(cfg map[string]any) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("参数错误:keyPath")
|
return fmt.Errorf("参数错误:keyPath")
|
||||||
}
|
}
|
||||||
certPath, ok := cfg["keyPath"].(string)
|
certPath, ok := cfg["certPath"].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("参数错误:certPath")
|
return fmt.Errorf("参数错误:certPath")
|
||||||
}
|
}
|
||||||
|
@ -155,8 +155,8 @@ func DeploySSH(cfg map[string]any) error {
|
||||||
}
|
}
|
||||||
// 自动创建多级目录
|
// 自动创建多级目录
|
||||||
files := []RemoteFile{
|
files := []RemoteFile{
|
||||||
{Path: keyPath, Content: certPem},
|
{Path: certPath, Content: certPem},
|
||||||
{Path: certPath, Content: keyPem},
|
{Path: keyPath, Content: keyPem},
|
||||||
}
|
}
|
||||||
err = writeMultipleFilesViaSSH(providerConfig, files, beforeCmd, afterCmd)
|
err = writeMultipleFilesViaSSH(providerConfig, files, beforeCmd, afterCmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -98,10 +98,12 @@ func Save(setting *Setting) error {
|
||||||
if setting.Timeout != 0 {
|
if setting.Timeout != 0 {
|
||||||
s.Where("key = 'timeout'", []interface{}{}).Update(map[string]interface{}{"value": setting.Timeout})
|
s.Where("key = 'timeout'", []interface{}{}).Update(map[string]interface{}{"value": setting.Timeout})
|
||||||
public.TimeOut = setting.Timeout
|
public.TimeOut = setting.Timeout
|
||||||
|
restart = true
|
||||||
}
|
}
|
||||||
if setting.Secure != "" {
|
if setting.Secure != "" {
|
||||||
s.Where("key = 'secure'", []interface{}{}).Update(map[string]interface{}{"value": setting.Secure})
|
s.Where("key = 'secure'", []interface{}{}).Update(map[string]interface{}{"value": setting.Secure})
|
||||||
public.TimeOut = setting.Timeout
|
public.TimeOut = setting.Timeout
|
||||||
|
restart = true
|
||||||
}
|
}
|
||||||
if setting.Https == "1" {
|
if setting.Https == "1" {
|
||||||
if setting.Key == "" || setting.Cert == "" {
|
if setting.Key == "" || setting.Cert == "" {
|
||||||
|
@ -122,7 +124,6 @@ func Save(setting *Setting) error {
|
||||||
os.WriteFile("data/https/cert.pem", []byte(setting.Cert), 0644)
|
os.WriteFile("data/https/cert.pem", []byte(setting.Cert), 0644)
|
||||||
restart = true
|
restart = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if restart {
|
if restart {
|
||||||
Restart()
|
Restart()
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue