DEVELOPMENT ENVIRONMENT

~liljamo/felu

db9eeca550c8858c3a628535b12c945561c7be75 — Jonni Liljamo 1 year, 1 month ago 244dcf0
feat: config options for service name and dns pattern
2 files changed, 11 insertions(+), 2 deletions(-)

M config/config.go
M dns/server.go
M config/config.go => config/config.go +6 -0
@@ 11,6 11,8 @@ import "git.src.quest/~skye/erya-go/util"
var FeluConfig *config

type config struct {
	ServiceName string

	// Data directory, with trailing slash
	DataDir string



@@ 20,10 22,13 @@ type config struct {

	DNSBindIP   string
	DNSBindPort int32
	DNSPattern  string
}

func InitConfig() {
	FeluConfig = &config {
		ServiceName: util.LoadEnvStr("FELU_SERVICE_NAME", "FeluDDNS"),

		DataDir: util.LoadEnvStr("FELU_DB_PATH", "/var/felu/"),

		FrontendBindAddr: util.LoadEnvStr("FELU_FRONTEND_BIND_ADDR", "0.0.0.0:8080"),


@@ 32,5 37,6 @@ func InitConfig() {

		DNSBindIP: util.LoadEnvStr("FELU_DNS_BIND_IP", "0.0.0.0"),
		DNSBindPort: util.LoadEnvInt32("FELU_DNS_BIND_PORT", 53),
		DNSPattern: util.LoadEnvStr("FELU_DNS_PATTERN", "."),
	}
}

M dns/server.go => dns/server.go +5 -2
@@ 6,10 6,13 @@
 */
package dns

import "github.com/miekg/dns"
import (
	"git.src.quest/~skye/felu-ddns/config"
	"github.com/miekg/dns"
)

func Run(addr string) error {
	dns.HandleFunc("ddns.fuckdns.org.", handleDnsRequest)
	dns.HandleFunc(config.FeluConfig.DNSPattern, handleDnsRequest)

	server := &dns.Server{
		Addr: addr,