Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2473 clean path for all os, linux defaults storage type to file #58

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions address.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

/*
Expand Down Expand Up @@ -33,11 +34,21 @@ func parseAddr(addr string) (*url.URL, error) {
// As of go 1.12, url.Parse returns an error when given URLs that contain control characters.
// https://golang.org/doc/go1.12#net/url
if strings.HasPrefix(addr, "pem:") || strings.HasPrefix(addr, "-----BEGIN") {
url := &url.URL{
ret := &url.URL{
Scheme: "pem",
Opaque: strings.TrimPrefix(addr, "pem:"),
}
return url, nil
return ret, nil
}
return url.Parse(addr)
urlParts, err := url.Parse(addr)

if err != nil {
return nil, err
}

if urlParts.Scheme == "" {
urlParts.Scheme = StorageFile
}

return urlParts, nil
}
13 changes: 7 additions & 6 deletions identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"os"
"path/filepath"
"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -185,28 +186,28 @@ func (id *ID) Reload() error {
func (id *ID) getFiles() []string {
var files []string
if path, ok := IsFile(id.Config.Cert); ok {
files = append(files, path)
files = append(files, filepath.Clean(path))
}

if path, ok := IsFile(id.Config.ServerCert); ok {
files = append(files, path)
files = append(files, filepath.Clean(path))
}

if path, ok := IsFile(id.Config.Key); ok {
files = append(files, path)
files = append(files, filepath.Clean(path))
}

if path, ok := IsFile(id.Config.ServerKey); ok {
files = append(files, path)
files = append(files, filepath.Clean(path))
}

for _, altServerCert := range id.Config.AltServerCerts {
if path, ok := IsFile(altServerCert.ServerKey); ok {
files = append(files, path)
files = append(files, filepath.Clean(path))
}

if path, ok := IsFile(altServerCert.ServerCert); ok {
files = append(files, path)
files = append(files, filepath.Clean(path))
}

}
Expand Down
Loading