mirror of
https://github.com/joohoi/acme-dns.git
synced 2024-12-22 21:23:52 +07:00
Refactoring
This commit is contained in:
parent
c1277e1aa3
commit
29b666619b
14
config.go
14
config.go
@ -1,14 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
func ReadConfig(fname string) (DnsConfig, error) {
|
||||
var conf DnsConfig
|
||||
if _, err := toml.DecodeFile(fname, &conf); err != nil {
|
||||
return DnsConfig{}, errors.New("Malformed configuration file")
|
||||
}
|
||||
return conf, nil
|
||||
}
|
10
util.go
10
util.go
@ -2,12 +2,22 @@ package main
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/satori/go.uuid"
|
||||
"math/big"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func ReadConfig(fname string) (DnsConfig, error) {
|
||||
var conf DnsConfig
|
||||
if _, err := toml.DecodeFile(fname, &conf); err != nil {
|
||||
return DnsConfig{}, errors.New("Malformed configuration file")
|
||||
}
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
func SanitizeString(s string) string {
|
||||
// URL safe base64 alphabet without padding as defined in ACME
|
||||
re, err := regexp.Compile("[^A-Za-z\\-\\_0-9]+")
|
||||
|
Loading…
Reference in New Issue
Block a user