summaryrefslogtreecommitdiff
path: root/internal/tcpserver.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tcpserver.go')
-rw-r--r--internal/tcpserver.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/tcpserver.go b/internal/tcpserver.go
index f264d9e..c65fb0b 100644
--- a/internal/tcpserver.go
+++ b/internal/tcpserver.go
@@ -28,7 +28,6 @@ func startTcpServer(ctx context.Context, address string, ch chan<- vote) error {
log.Printf("Client connected: %s\n", conn.RemoteAddr().String())
- // Handle the connection in a new goroutine
go handleConnection(ctx, conn, ch)
}
}
@@ -36,6 +35,7 @@ func startTcpServer(ctx context.Context, address string, ch chan<- vote) error {
func handleConnection(ctx context.Context, conn net.Conn, ch chan<- vote) {
defer conn.Close()
remoteAddr := conn.RemoteAddr().String()
+ // TODO: Reject remote connection when not in participant list!
log.Printf("Client %s connected\n", remoteAddr)
reader := bufio.NewReader(conn)
@@ -48,7 +48,7 @@ func handleConnection(ctx context.Context, conn net.Conn, ch chan<- vote) {
message, err := reader.ReadString('\n')
if err != nil {
log.Printf("Client %s disconnected: %s\n", remoteAddr, err.Error())
- break
+ return
}
log.Printf("Received message from %s: %s", remoteAddr, message)