From c01b9156f3b8f6ebc5abcbc8951b1710a2cd640e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 11 Dec 2016 23:05:57 -0500 Subject: [PATCH] Lay out basic config file structure. --- .gitignore | 2 ++ config.go | 25 +++++++++++++++++++++++++ mailpopbox.go | 27 +++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .gitignore create mode 100644 config.go create mode 100644 mailpopbox.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a79c853 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +config.json +mailpopbox diff --git a/config.go b/config.go new file mode 100644 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: . + 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 index 0000000..984acb3 --- /dev/null +++ b/mailpopbox.go @@ -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() +} -- 2.22.5