From dcff2bdaabaa99ef4c05bda1dc89e9b02b415ddd Mon Sep 17 00:00:00 2001
From: Michael Gernoth <michael@gernoth.net>
Date: Tue, 28 Apr 2020 11:20:44 +0200
Subject: [PATCH] Determine IP version on the basis of the source address

This allows to "tunnel" IPv6 connections in IPv4 connections between
haproxy and go-mmproxy.
---
 tcp.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tcp.go b/tcp.go
index e142fac..e424f69 100644
--- a/tcp.go
+++ b/tcp.go
@@ -51,7 +51,7 @@ func tcpHandleConnection(conn net.Conn, logger *zap.Logger) {
 	}
 
 	targetAddr := Opts.TargetAddr6
-	if AddrVersion(conn.RemoteAddr()) == 4 {
+	if AddrVersion(saddr) == 4 {
 		targetAddr = Opts.TargetAddr4
 	}
 
-- 
GitLab