Selaa lähdekoodia

lib/connections: Indicate stack in transport (fixes #4463)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4486
AudriusButkevicius 8 vuotta sitten
vanhempi
sitoutus
0ee1146e1c
1 muutettua tiedostoa jossa 13 lisäystä ja 1 poistoa
  1. 13 1
      lib/connections/structs.go

+ 13 - 1
lib/connections/structs.go

@@ -93,7 +93,19 @@ func (c internalConn) Type() string {
 }
 
 func (c internalConn) Transport() string {
-	return c.connType.Transport()
+	transport := c.connType.Transport()
+	host, _, err := net.SplitHostPort(c.LocalAddr().String())
+	if err != nil {
+		return transport
+	}
+	ip := net.ParseIP(host)
+	if ip == nil {
+		return transport
+	}
+	if ip.To4() != nil {
+		return transport + "4"
+	}
+	return transport + "6"
 }
 
 func (c internalConn) String() string {