Lay out basic config file structure.
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 12 Dec 2016 04:05:57 +0000 (23:05 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 12 Dec 2016 04:05:57 +0000 (23:05 -0500)
.gitignore [new file with mode: 0644]
config.go [new file with mode: 0644]
mailpopbox.go [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..a79c853
--- /dev/null
@@ -0,0 +1,2 @@
+config.json
+mailpopbox
diff --git a/config.go b/config.go
new file mode 100644 (file)
index 0000000..8f3c734
--- /dev/null
+++ b/config.go
@@ -0,0 +1,25 @@
+package main
+
+type Config struct {
+       SMTPPort int
+       POP3Port int
+
+       Servers []Server
+}
+
+type Server struct {
+       // Domain is the second component of a mail address: <local-part@domain.com>.
+       Domain string
+
+       // Hostname is the name of the MX server that is running.
+       Hostname string
+
+       TLSKeyPath  string
+       TLSCertPath string
+
+       // Password for the POP3 mailbox user, mailbox@domain.com.
+       MailboxPassword string
+
+       // Blacklisted addresses that should not accept mail.
+       BlacklistedAddresses []string
+}
diff --git a/mailpopbox.go b/mailpopbox.go
new file mode 100644 (file)
index 0000000..984acb3
--- /dev/null
@@ -0,0 +1,27 @@
+package main
+
+import (
+       "encoding/json"
+       "fmt"
+       "os"
+)
+
+func main() {
+       if len(os.Args) != 2 {
+               fmt.Fprintf(os.Stderr, "Usage: %s config.json\n", os.Args[0])
+               os.Exit(1)
+       }
+
+       configFile, err := os.Open(os.Args[1])
+       if err != nil {
+               fmt.Fprintf(os.Stderr, "config file: %s\n", err)
+               os.Exit(2)
+       }
+
+       var config Config
+       if err := json.NewDecoder(configFile).Decode(&config); err != nil {
+               fmt.Fprintf(os.Stderr, "config file: %s\n", err)
+               os.Exit(3)
+       }
+       configFile.Close()
+}