1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2026-01-06 11:27:18 +00:00

Config file loading/validation implemented.

Builds, does not run!
This commit is contained in:
James Hillyerd
2012-10-20 19:20:42 -07:00
parent ec0823b452
commit ce9289140a
4 changed files with 123 additions and 2 deletions

52
inbucketd/inbucketd.go Normal file
View File

@@ -0,0 +1,52 @@
/*
This is the inbucket daemon launcher
*/
package main
import (
"flag"
"fmt"
"github.com/jhillyerd/inbucket"
"github.com/jhillyerd/inbucket/smtpd"
"os"
)
var help = flag.Bool("help", false, "Displays this help")
func main() {
flag.Parse()
if *help {
flag.Usage()
return
}
// Load & Parse config
if flag.NArg() != 1 {
flag.Usage()
os.Exit(1)
}
err := inbucket.LoadConfig(flag.Arg(0))
configError(err)
// Startup SMTP server
domain, err := inbucket.Config.String("smtp", "domain")
configError(err)
port, err := inbucket.Config.Int("smtp", "ip4.port")
configError(err)
server := smtpd.New(domain, port)
go server.Start()
}
func init() {
flag.Usage = func() {
fmt.Fprintln(os.Stderr, "Usage of inbucketd [options] <conf file>:")
flag.PrintDefaults()
}
}
func configError(err error) {
if err != nil {
fmt.Fprintf(os.Stderr, "Error parsing config file: %v\n", err)
os.Exit(1)
}
}