aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-14 18:48:45 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-14 18:48:45 +0100
commitcd20da69000a1b1a74a3814546c2bb204c4c0aa4 (patch)
tree834286aea5cf42efdeb16cce630761926f36f0a4
parent7ca4c90877a4b45627211307baf9f7aa3bd9e32b (diff)
Add config proposal
-rw-r--r--acme.toml23
-rw-r--r--cmd/conf/main.go16
-rw-r--r--config.go46
3 files changed, 77 insertions, 8 deletions
diff --git a/acme.toml b/acme.toml
index 5476217..4bb71e7 100644
--- a/acme.toml
+++ b/acme.toml
@@ -1,13 +1,19 @@
+[defaults]
+gracetime = "1 week"
+listen = "localhost:8443"
+
[provider.lev1]
directory = "https://acme-v01.api.letsencrypt.org/directory"
[provider.les]
directory = "https://acme-staging.api.letsencrypt.org/directory"
+default = true
[account.example]
mail = "another@example.com"
+phone = "+12025551212"
key = "/etc/acme.key"
-provider = "les"
+default = true
[hook.nginx]
cmd = "sudo service nginx reload"
@@ -18,19 +24,20 @@ cmd = "sudo service dovecot reload"
[hook.smtpd]
cmd = "sudo service smtpd reload"
-[[desire]]
+[desire.web]
+provider = "les"
+account = "example"
altnames = [ "www.example.com", "example.com" ]
key = "/etc/ssl/private/www_example_com.key"
cert = "/etc/ssl/certs/www_example_com.pem"
webroot = "/var/www/htdocs"
-account = "example"
-gracetime = "1 week"
-hook = [ "nginx" ]
+hooks = [ "nginx" ]
-[[desire]]
+[desire.mail]
+provider = "les"
+account = "example"
altnames = [ "mail.example.com" ]
key = "/etc/ssl/private/mail_example_com.key"
cert = "/etc/ssl/certs/mail_example_com.pem"
-account = "example"
gracetime = "1 week"
-hook = [ "dovecot", "smtpd" ]
+hooks = [ "dovecot", "smtpd" ]
diff --git a/cmd/conf/main.go b/cmd/conf/main.go
new file mode 100644
index 0000000..fa59455
--- /dev/null
+++ b/cmd/conf/main.go
@@ -0,0 +1,16 @@
+package main
+
+import (
+ "fmt"
+
+ "dim13.org/acme"
+)
+
+func main() {
+ c, _ := acme.LoadConfig("acme.toml")
+ for _, v := range c.Desire {
+ fmt.Println("Provider", c.Provider[v.Provider])
+ fmt.Println("Account", c.Account[v.Account])
+ fmt.Printf("%+v\n", v)
+ }
+}
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..7b3f256
--- /dev/null
+++ b/config.go
@@ -0,0 +1,46 @@
+package acme
+
+import "github.com/BurntSushi/toml"
+
+type Config struct {
+ Defaults defaults
+ Provider map[string]provider
+ Account map[string]account
+ Hook map[string]hook
+ Desire map[string]desire
+}
+
+type defaults struct {
+ Gracetime string
+ Listen string
+}
+
+type provider struct {
+ Directory string
+}
+
+type account struct {
+ Mail string
+ Phone string
+ Key string
+}
+
+type hook struct {
+ CMD string
+}
+
+type desire struct {
+ Provider string
+ Account string
+ Altnames []string
+ Key string
+ Cert string
+ Webroot string
+ Hooks []string
+}
+
+func LoadConfig(fname string) (*Config, error) {
+ c := &Config{}
+ _, err := toml.DecodeFile(fname, c)
+ return c, err
+}