From 97f334b5abfb53f324f8768e6a645bbab2dee789 Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Tue, 22 Oct 2024 07:31:47 +0800 Subject: [PATCH 1/6] v0.2.6 --- .github/workflows/push_image.yml | 3 ++- ui/src/domain/version.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 22802cbf..141cb8fd 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -53,6 +53,7 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true tags: ${{ steps.meta.outputs.tags }} + diff --git a/ui/src/domain/version.ts b/ui/src/domain/version.ts index 9585a43e..1a412f6a 100644 --- a/ui/src/domain/version.ts +++ b/ui/src/domain/version.ts @@ -1 +1 @@ -export const version = "Certimate v0.2.5"; +export const version = "Certimate v0.2.6"; From 4e86c1eb45f1552754e1a9cdb70ea6ad61b8b47e Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Tue, 22 Oct 2024 08:26:27 +0800 Subject: [PATCH 2/6] v0.2.6 --- .github/workflows/push_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 141cb8fd..dbcc776c 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -53,7 +53,7 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} From ea4bcb4aaff9fb71dc2f968c39cac48cabd457b3 Mon Sep 17 00:00:00 2001 From: liburdi Date: Tue, 22 Oct 2024 12:17:43 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20reamdme=E9=87=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E5=90=AF=E5=8A=A8=E5=91=BD=E4=BB=A4=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E5=A4=B1=E6=95=88=EF=BC=8C=E5=9B=A0=E4=B8=BAui/dist?= =?UTF-8?q?=E4=B8=8D=E5=9C=A8=E4=BB=A3=E7=A0=81=E4=BB=93=E5=BA=93=E4=B8=AD?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 +++ README.md | 3 +-- README_EN.md | 3 +-- main.go | 6 +++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7c2f0d6d..af32f777 100644 --- a/Makefile +++ b/Makefile @@ -35,3 +35,6 @@ help: @echo " make help - 显示此帮助信息" .PHONY: all build clean help + +local.run: + go mod vendor&& npm --prefix ./ui install && npm --prefix ./ui run build && go run main.go serve diff --git a/README.md b/README.md index cb3b0b29..3f5ef4fc 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,7 @@ mkdir -p ~/.certimate && cd ~/.certimate && curl -O https://raw.githubuserconten ```bash git clone EMAIL:usual2970/certimate.git cd certimate -go mod vendor -go run main.go serve +make local.run ``` ## 二、使用 diff --git a/README_EN.md b/README_EN.md index d048cecb..f8923c44 100644 --- a/README_EN.md +++ b/README_EN.md @@ -54,8 +54,7 @@ mkdir -p ~/.certimate && cd ~/.certimate && curl -O https://raw.githubuserconten ```bash git clone EMAIL:usual2970/certimate.git cd certimate -go mod vendor -go run main.go serve +make local.run ``` ## Usage diff --git a/main.go b/main.go index 7a0bf641..3cd0bd06 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "github.com/usual2970/certimate/ui" "log" "os" "strings" @@ -16,6 +15,7 @@ import ( "github.com/usual2970/certimate/internal/domains" "github.com/usual2970/certimate/internal/routes" "github.com/usual2970/certimate/internal/utils/app" + "github.com/usual2970/certimate/ui" _ "time/tzdata" ) @@ -46,6 +46,10 @@ func main() { return nil }) + defer log.Println("Exit!") + go func() { + log.Println("Visit the website:", "http://127.0.0.1:8090") + }() if err := app.Start(); err != nil { log.Fatal(err) From 0c35928eee9dd653bc542c5b91e77e49a606abc7 Mon Sep 17 00:00:00 2001 From: liburdi Date: Tue, 22 Oct 2024 12:26:08 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E7=BB=88=E7=AB=AF=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 3cd0bd06..fa1d38d2 100644 --- a/main.go +++ b/main.go @@ -46,10 +46,9 @@ func main() { return nil }) + defer log.Println("Exit!") - go func() { - log.Println("Visit the website:", "http://127.0.0.1:8090") - }() + log.Println("Visit the website:", "http://127.0.0.1:8090") if err := app.Start(); err != nil { log.Fatal(err) From 265842feebcf592fb243f52352a2cd5720f5323b Mon Sep 17 00:00:00 2001 From: liburdi Date: Tue, 22 Oct 2024 13:52:33 +0800 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20=E6=A0=B9=E6=8D=AE=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E5=8F=82=E6=95=B0=EF=BC=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- main.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index af32f777..d5987872 100644 --- a/Makefile +++ b/Makefile @@ -37,4 +37,4 @@ help: .PHONY: all build clean help local.run: - go mod vendor&& npm --prefix ./ui install && npm --prefix ./ui run build && go run main.go serve + go mod vendor&& npm --prefix ./ui install && npm --prefix ./ui run build && go run main.go serve --http 127.0.0.1:8090 diff --git a/main.go b/main.go index fa1d38d2..39758d42 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "log" "os" "strings" @@ -25,6 +26,12 @@ func main() { isGoRun := strings.HasPrefix(os.Args[0], os.TempDir()) + // 获取启动命令中的http参数 + var httpFlag string + flag.StringVar(&httpFlag, "http", "127.0.0.1:8090", "HTTP server address") + // "serve"影响解析 + _ = flag.CommandLine.Parse(os.Args[2:]) + migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{ // enable auto creation of migration files when making collection changes in the Admin UI // (the isGoRun check is to enable it only during development) @@ -48,7 +55,7 @@ func main() { }) defer log.Println("Exit!") - log.Println("Visit the website:", "http://127.0.0.1:8090") + log.Printf("Visit the website: http://%s", httpFlag) if err := app.Start(); err != nil { log.Fatal(err) From dbfb84ec6d94ba8283d7d1250c3bfa154051b31e Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Tue, 22 Oct 2024 15:41:44 +0800 Subject: [PATCH 6/6] qiniu cdn supports wildcard domain deployment --- internal/deployer/qiniu_cdn.go | 10 +++++++--- internal/domain/domains.go | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/internal/deployer/qiniu_cdn.go b/internal/deployer/qiniu_cdn.go index f6e6b167..fa74a0cb 100644 --- a/internal/deployer/qiniu_cdn.go +++ b/internal/deployer/qiniu_cdn.go @@ -76,7 +76,8 @@ func (d *QiniuCDNDeployer) Deploy(ctx context.Context) error { } func (d *QiniuCDNDeployer) enableHttps(certId string) error { - path := fmt.Sprintf("/domain/%s/sslize", getDeployString(d.option.DeployConfig, "domain")) + domain := d.option.DeployConfig.GetDomain() + path := fmt.Sprintf("/domain/%s/sslize", domain) body := &qiniuModifyDomainCertReq{ CertID: certId, @@ -102,7 +103,9 @@ type qiniuDomainInfo struct { } func (d *QiniuCDNDeployer) getDomainInfo() (*qiniuDomainInfo, error) { - path := fmt.Sprintf("/domain/%s", getDeployString(d.option.DeployConfig, "domain")) + domain := d.option.DeployConfig.GetDomain() + + path := fmt.Sprintf("/domain/%s", domain) res, err := d.req(qiniuGateway+path, http.MethodGet, nil) if err != nil { @@ -164,7 +167,8 @@ type qiniuModifyDomainCertReq struct { } func (d *QiniuCDNDeployer) modifyDomainCert(certId string) error { - path := fmt.Sprintf("/domain/%s/httpsconf", getDeployString(d.option.DeployConfig, "domain")) + domain := d.option.DeployConfig.GetDomain() + path := fmt.Sprintf("/domain/%s/httpsconf", domain) body := &qiniuModifyDomainCertReq{ CertID: certId, diff --git a/internal/domain/domains.go b/internal/domain/domains.go index 7aaa9051..d706a1c7 100644 --- a/internal/domain/domains.go +++ b/internal/domain/domains.go @@ -1,5 +1,7 @@ package domain +import "strings" + type ApplyConfig struct { Email string `json:"email"` Access string `json:"access"` @@ -16,6 +18,29 @@ type DeployConfig struct { Config map[string]any `json:"config"` } +// GetDomain returns the domain from the deploy config +// if the domain is a wildcard domain, and wildcard is true, return the wildcard domain +func (d *DeployConfig) GetDomain(wildcard ...bool) string { + if _, ok := d.Config["domain"]; !ok { + return "" + } + + val, ok := d.Config["domain"].(string) + if !ok { + return "" + } + + if !strings.HasPrefix(val, "*") { + return val + } + + if len(wildcard) > 0 && wildcard[0] { + return val + } + + return strings.TrimPrefix(val, "*") +} + type KV struct { Key string `json:"key"` Value string `json:"value"`