blob: f1c28baa66eadd906e73b8d8d767088e42a78c2d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package main
import (
"context"
"errors"
"flag"
"io"
"net"
"go.lindenii.runxiyu.org/lindenii-common/clog"
)
const VERSION = "lindenii-maild v0.0.0"
func main() {
config_path := flag.String("config", "/etc/lindenii/maild.scfg", "path to configuration file")
flag.Parse()
err := load_config(*config_path)
if err != nil {
panic(err)
}
listener, err := net.Listen(config.MX.Net, config.MX.Addr)
if err != nil {
panic(err)
}
defer listener.Close()
for {
conn, err := listener.Accept()
if err != nil {
panic(err)
}
go func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := handle_mx_recv_conn(ctx, conn)
if err != nil && !errors.Is(err, io.EOF) {
clog.Error("connection handler returned error", "err", err)
}
}()
}
}
|