From 19e4cf14ae80f6c3f13e00e57f72982eca05eb11 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 23 Nov 2019 19:46:31 +0100 Subject: [PATCH] Allow setting listen address when calling runServer() --- main.go | 7 ++----- socket.go | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 10a41a6..50fb88b 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/socket.go b/socket.go index 2d7566e..3986b8c 100644 --- a/socket.go +++ b/socket.go @@ -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