Skip to content

Commit

Permalink
Merge pull request #58 from openziti/fix.2473.fix.idenity.reloading.l…
Browse files Browse the repository at this point in the history
…inux

fix #2473 clean path for all os, linux defaults storage type to file
  • Loading branch information
andrewpmartinez authored Oct 8, 2024
2 parents 8e9b360 + 24a656a commit 85b0d17
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
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

0 comments on commit 85b0d17

Please sign in to comment.