Allow setting listen address when calling runServer()

This commit is contained in:
Jan Philipp Timme 2019-11-23 19:46:31 +01:00
parent c748253803
commit 19e4cf14ae
2 changed files with 4 additions and 7 deletions

View File

@ -5,11 +5,8 @@ import (
"bytes"
"encoding/binary"
"encoding/hex"
"os"
)
import (
"milter-experiment/logging"
"os"
)
var (
@ -43,7 +40,7 @@ func handleMtaConnection(clientConnection *bufio.ReadWriter) {
func main() {
logger = logging.NewLogger(os.Stdout, os.Stderr, logging.DEBUG)
err := runServer()
err := runServer("127.0.0.1:7777")
if err != nil {
logger.Errorf("Could not run server: %s\n", err.Error())
os.Exit(1)

View File

@ -6,8 +6,8 @@ import (
"net"
)
func runServer() error {
serverSocket, err := net.Listen("tcp", "127.0.0.1:7777")
func runServer(listenAddr string) error {
serverSocket, err := net.Listen("tcp", listenAddr)
if err != nil {
myError := fmt.Errorf("could not create listening socket: %s", err.Error())
return myError