82 lines
1.5 KiB
Go
82 lines
1.5 KiB
Go
package dumper
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/go-acme/lego/certcrypto"
|
|
"github.com/go-acme/lego/registration"
|
|
)
|
|
|
|
// StoredData represents the data managed by the Store
|
|
type StoredData struct {
|
|
Account *Account
|
|
Certificates []*Certificate
|
|
HTTPChallenges map[string]map[string][]byte
|
|
TLSChallenges map[string]*Certificate
|
|
}
|
|
|
|
// Certificate is a struct which contains all data needed from an ACME certificate
|
|
type Certificate struct {
|
|
Domain Domain
|
|
Certificate []byte
|
|
Key []byte
|
|
}
|
|
|
|
// Domain holds a domain name with SANs
|
|
type Domain struct {
|
|
Main string
|
|
SANs []string
|
|
}
|
|
|
|
// Account is used to store lets encrypt registration info
|
|
type Account struct {
|
|
Email string
|
|
Registration *registration.Resource
|
|
PrivateKey []byte
|
|
KeyType certcrypto.KeyType
|
|
}
|
|
|
|
// Tree FIXME move
|
|
func Tree(root, indent string) error {
|
|
fi, err := os.Stat(root)
|
|
if err != nil {
|
|
return fmt.Errorf("could not stat %s: %v", root, err)
|
|
}
|
|
|
|
fmt.Println(fi.Name())
|
|
if !fi.IsDir() {
|
|
return nil
|
|
}
|
|
|
|
fis, err := ioutil.ReadDir(root)
|
|
if err != nil {
|
|
return fmt.Errorf("could not read dir %s: %v", root, err)
|
|
}
|
|
|
|
var names []string
|
|
for _, fi := range fis {
|
|
if fi.Name()[0] != '.' {
|
|
names = append(names, fi.Name())
|
|
}
|
|
}
|
|
|
|
for i, name := range names {
|
|
add := "│ "
|
|
if i == len(names)-1 {
|
|
fmt.Printf(indent + "└──")
|
|
add = " "
|
|
} else {
|
|
fmt.Printf(indent + "├──")
|
|
}
|
|
|
|
if err := Tree(filepath.Join(root, name), indent+add); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|