Fix: reply 235 when client auth success, according to rfc2554 (#1)
[mailpopbox.git] / server.go
1 // mailpopbox
2 // Copyright 2020 Blue Static <https://www.bluestatic.org>
3 // This program is free software licensed under the GNU General Public License,
4 // version 3.0. The full text of the license can be found in LICENSE.txt.
5 // SPDX-License-Identifier: GPL-3.0-only
6
7 package main
8
9 import (
10 "net"
11 "os"
12 "os/signal"
13 "syscall"
14
15 "go.uber.org/zap"
16 )
17
18 type ServerControlMessage int
19
20 const (
21 ServerControlFatalError ServerControlMessage = iota
22 ServerControlRestart
23 )
24
25 func RunAcceptLoop(l net.Listener, c chan<- net.Conn, log *zap.Logger) {
26 for {
27 conn, err := l.Accept()
28 if err != nil {
29 log.Error("accept", zap.Error(err))
30 close(c)
31 return
32 }
33
34 c <- conn
35 }
36 }
37
38 func CreateReloadSignal() <-chan os.Signal {
39 reloadChan := make(chan os.Signal, 1)
40 signal.Notify(reloadChan, syscall.SIGHUP)
41 return reloadChan
42 }