1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00
Files
go-inbucket/inbucketd/inbucketd.go
James Hillyerd ce9289140a Config file loading/validation implemented.
Builds, does not run!
2012-10-20 19:20:42 -07:00

53 lines
923 B
Go

/*
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)
}
}