Commit ed4fee21 authored by semihalev's avatar semihalev
Browse files

fix config file generation

parent 077a4273
......@@ -81,7 +81,7 @@ nfpms:
builds:
- nf
homepage: https://sdns.dev
description: SDNS is resolving DNS queries recursively fast and secure
description: Privacy important, fast, recursive dns resolver server with dnssec support
maintainer: Yasar Alev <semihalev@gmail.com>
license: MIT
bindir: /usr/bin
......@@ -114,7 +114,7 @@ brews:
name: homebrew-tap
folder: Formula
homepage: https://sdns.dev
description: SDNS is resolving DNS queries recursively fast and secure
description: Privacy important, fast, recursive dns resolver server with dnssec support
dependencies:
- name: go
type: build
......
......@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"strings"
"time"
......@@ -249,25 +250,25 @@ emptyzones = []
`
// Load loads the given config file
func Load(path, version string) (*Config, error) {
func Load(cfgfile, version string) (*Config, error) {
config := new(Config)
if _, err := os.Stat(path); os.IsNotExist(err) {
if path == "sdns.conf" {
if _, err := os.Stat(cfgfile); os.IsNotExist(err) {
if path.Base(cfgfile) == "sdns.conf" {
// compatibility for old default conf file
if _, err := os.Stat("sdns.toml"); os.IsNotExist(err) {
if err := generateConfig(path); err != nil {
if err := generateConfig(cfgfile); err != nil {
return nil, err
}
} else {
path = "sdns.toml"
cfgfile = "sdns.toml"
}
}
}
log.Info("Loading config file", "path", path)
log.Info("Loading config file", "path", cfgfile)
if _, err := toml.DecodeFile(path, config); err != nil {
if _, err := toml.DecodeFile(cfgfile, config); err != nil {
return nil, fmt.Errorf("could not load config: %s", err)
}
......
......@@ -16,7 +16,7 @@ import (
"github.com/semihalev/sdns/server"
)
const version = "1.1.4"
const version = "1.1.5"
var (
flagcfgpath = flag.String("config", "sdns.conf", "location of the config file, if config file not found, a config will generate")
......
......@@ -2,7 +2,7 @@ name: sdns
adopt-info: sdns
summary: A DNS Resolver Server.
description: |
SDNS is resolving DNS queries recursively fast and secure.
Privacy important, fast, recursive dns resolver server with dnssec support
architectures:
- build-on: armhf
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment