From: Robert Sesek Date: Mon, 12 Dec 2016 04:05:57 +0000 (-0500) Subject: Lay out basic config file structure. X-Git-Tag: v1.0.0~26 X-Git-Url: https://src.bluestatic.org/?a=commitdiff_plain;h=c01b9156f3b8f6ebc5abcbc8951b1710a2cd640e;p=mailpopbox.git Lay out basic config file structure. --- 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() +}