代码拉取完成,页面将自动刷新
同步操作将从 keengo/autocert 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"flag"
"fmt"
"os"
"strings"
"time"
)
const (
LISTEN_ADDR = "127.0.0.1:19981"
//LISTEN_ADDR = ":80"
)
const (
VERSION = "1.0.0"
)
var (
//kangle_path *string = flag.String("k", "", "kangle path")
domains *string = flag.String("a", "", "add domains(domain1,domain2,..)")
remove_domains *string = flag.String("d", "", "delete domains(domain1,domain2,...)")
list *bool = flag.Bool("l", false, "list domains")
//renew *int = flag.Int("r", -1, "renew domain days")
)
func autoCertDomains(domains []string) {
err := startServer()
if err != nil {
fmt.Printf("cann't listen [%s]\n", LISTEN_ADDR)
os.Exit(1)
}
err = prepareKangle()
if err != nil {
fmt.Printf("prepare kangle error [%s]\n", err.Error())
os.Exit(1)
}
time.Sleep(time.Second)
defer cleanKangle()
err = loadCertAccount()
if err != nil {
fmt.Printf("load account error [%s]\n", err.Error())
os.Exit(1)
return
}
any_success := false
for _, domain := range domains {
fmt.Printf("auto cert for domain = [%s]\n", domain)
err = autoCertDomain(domain)
if err != nil {
fmt.Printf("auto cert domain [%s] error [%s]\n", domain, err.Error())
} else {
any_success = true
}
}
if any_success {
err := saveCertIndex()
if err != nil {
fmt.Printf("save cert index failed. error=[%s]\n", err.Error())
os.Exit(1)
}
}
}
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Auto certificate for kangle web server version: %s\nUsage: %s [OPTIONS]\r\n", VERSION, os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
loadCertIndex()
if *list {
printCertIndex()
return
}
if len(*remove_domains) > 0 {
defer reloadKangle()
domain_array := strings.Split(*remove_domains, ",")
any_success := false
for _, domain := range domain_array {
result := deleteCert(domain)
if result {
any_success = true
}
fmt.Printf("remove domain [%s] ", domain)
if result {
fmt.Printf("success\n")
} else {
fmt.Printf("failed\n")
}
}
if any_success {
err := saveCertIndex()
if err != nil {
fmt.Printf("save cert index failed. error=[%s]\n", err.Error())
os.Exit(1)
}
}
return
}
if len(*domains) > 0 {
add_domains := strings.Split(*domains, ",")
autoCertDomains(add_domains)
return
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。