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 (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"errors"
|
||||||
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/satori/go.uuid"
|
"github.com/satori/go.uuid"
|
||||||
"math/big"
|
"math/big"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"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 {
|
func SanitizeString(s string) string {
|
||||||
// URL safe base64 alphabet without padding as defined in ACME
|
// URL safe base64 alphabet without padding as defined in ACME
|
||||||
re, err := regexp.Compile("[^A-Za-z\\-\\_0-9]+")
|
re, err := regexp.Compile("[^A-Za-z\\-\\_0-9]+")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user