2019-05-12 19:05:56 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
2019-05-12 21:08:27 +02:00
|
|
|
"fmt"
|
2019-05-12 19:05:56 +02:00
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
2019-05-12 21:08:27 +02:00
|
|
|
func runServer() error {
|
2019-05-12 19:05:56 +02:00
|
|
|
serverSocket, err := net.Listen("tcp", "127.0.0.1:7777")
|
|
|
|
if err != nil {
|
2019-05-12 21:08:27 +02:00
|
|
|
myError := fmt.Errorf("could not create listening socket: %s", err.Error())
|
|
|
|
return myError
|
2019-05-12 19:05:56 +02:00
|
|
|
}
|
2019-05-12 21:08:27 +02:00
|
|
|
logger.Infof("Now listening for incoming connections.\n")
|
|
|
|
defer serverSocket.Close()
|
2019-05-12 19:05:56 +02:00
|
|
|
for {
|
|
|
|
clientConnection, err := serverSocket.Accept()
|
|
|
|
if err != nil {
|
|
|
|
logger.Warnf("Could not accept client connection: %s\n", err.Error())
|
|
|
|
} else {
|
|
|
|
logger.Infof("Accepted client connection.\n")
|
|
|
|
milterReadWriter := bufio.NewReadWriter(bufio.NewReader(clientConnection), bufio.NewWriter(clientConnection))
|
|
|
|
go handleMtaConnection(milterReadWriter)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|