]> src.bluestatic.org Git - mailpopbox.git/blob - mailpopbox.go
Add small program to help debug TLS issues using a non-Go stack.
[mailpopbox.git] / mailpopbox.go
1 package main
2
3 import (
4 "encoding/json"
5 "fmt"
6 "os"
7
8 "github.com/uber-go/zap"
9 )
10
11 func main() {
12 if len(os.Args) != 2 {
13 fmt.Fprintf(os.Stderr, "Usage: %s config.json\n", os.Args[0])
14 os.Exit(1)
15 }
16
17 configFile, err := os.Open(os.Args[1])
18 if err != nil {
19 fmt.Fprintf(os.Stderr, "config file: %s\n", err)
20 os.Exit(2)
21 }
22
23 var config Config
24 if err := json.NewDecoder(configFile).Decode(&config); err != nil {
25 fmt.Fprintf(os.Stderr, "config file: %s\n", err)
26 os.Exit(3)
27 }
28 configFile.Close()
29
30 log := zap.New(zap.NewTextEncoder())
31
32 pop3 := runPOP3Server(config, log)
33 smtp := runSMTPServer(config, log)
34
35 select {
36 case err := <-pop3:
37 fmt.Println(err)
38 case err := <-smtp:
39 fmt.Println(err)
40 }
41 }