From 6bb77caf73e3bd30b5719886ba808dc352f02bb2 Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Wed, 14 Mar 2018 16:13:34 +0200 Subject: [PATCH] Add configuration option to disable registration endpoint --- README.md | 2 ++ config.cfg | 2 ++ main.go | 4 +++- types.go | 21 +++++++++++---------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 64419131..0bd4ea34 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,8 @@ connection = "acme-dns.db" [api] # domain name to listen requests for, mandatory if using tls = "letsencrypt" api_domain = "" +# disable registration endpoint +disable_registration = false # autocert HTTP port, eg. 80 for answering Let's Encrypt HTTP-01 challenges. Mandatory if using tls = "letsencrypt". autocert_port = "80" # listen ip, default "" listens on all interfaces/addresses diff --git a/config.cfg b/config.cfg index f8e91460..2798ad53 100644 --- a/config.cfg +++ b/config.cfg @@ -36,6 +36,8 @@ connection = "/var/lib/acme-dns/acme-dns.db" api_domain = "" # listen ip eg. 127.0.0.1 ip = "0.0.0.0" +# disable registration endpoint +disable_registration = false # autocert HTTP port, eg. 80 for answering Let's Encrypt HTTP-01 challenges. Mandatory if using tls = "letsencrypt". autocert_port = "80" # listen port, eg. 443 for default HTTPS diff --git a/main.go b/main.go index d1cbbd13..adee8385 100644 --- a/main.go +++ b/main.go @@ -67,7 +67,9 @@ func startHTTPAPI() { // Logwriter for saner log output c.Log = stdlog.New(logwriter, "", 0) } - api.POST("/register", webRegisterPost) + if !Config.API.DisableRegistration { + api.POST("/register", webRegisterPost) + } api.POST("/update", Auth(webUpdatePost)) host := Config.API.IP + ":" + Config.API.Port diff --git a/types.go b/types.go index 1f5c4201..fe21581f 100644 --- a/types.go +++ b/types.go @@ -50,16 +50,17 @@ type dbsettings struct { // API config type httpapi struct { - Domain string `toml:"api_domain"` - IP string - AutocertPort string `toml:"autocert_port"` - Port string `toml:"port"` - TLS string - TLSCertPrivkey string `toml:"tls_cert_privkey"` - TLSCertFullchain string `toml:"tls_cert_fullchain"` - CorsOrigins []string - UseHeader bool `toml:"use_header"` - HeaderName string `toml:"header_name"` + Domain string `toml:"api_domain"` + IP string + DisableRegistration bool `toml:"disable_registration"` + AutocertPort string `toml:"autocert_port"` + Port string `toml:"port"` + TLS string + TLSCertPrivkey string `toml:"tls_cert_privkey"` + TLSCertFullchain string `toml:"tls_cert_fullchain"` + CorsOrigins []string + UseHeader bool `toml:"use_header"` + HeaderName string `toml:"header_name"` } // Logging config