Refactoring

This commit is contained in:
Joona Hoikkala 2016-11-16 15:31:40 +02:00
parent c1277e1aa3
commit 29b666619b
No known key found for this signature in database
GPG Key ID: C14AAE0F5ADCB854
2 changed files with 10 additions and 14 deletions

View File

@ -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
View File

@ -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]+")