Repository: syncthing/syncthing (language: go)

Issue:
Usage report transport type is wrong for QUIC
Will over represent IPv6.

```
jb@ses:~ % syncthing cli show usage | grep -A2 transport
  "transportStats": {
    "quic6": 1
  },
jb@ses:~ % syncthing cli show connections | egrep 'address|type'
      ...
      "address": "83.233.124.224:22000",
      "type": "quic-client"
```


Discussion / hints:
https://github.com/syncthing/syncthing/blob/f25a169c4c0943b34777a306e93d8fbefc9d8109/lib/connections/structs.go#L127-L137

I wonder if it's simply caused by the transport listening on `[::]` ? Switching to `c.RemoteAddr()` should solve that.
It is.

```go
func (c internalConn) Transport() string {
	transport := c.connType.Transport()
	ip, err := osutil.IPFromAddr(c.LocalAddr())
	fmt.Println("Local IP:", c.LocalAddr())
	fmt.Println("Remote IP:", c.RemoteAddr())
	if err != nil {
		return transport
	}
	if ip.To4() != nil {
		return transport + "4"
	}
	return transport + "6"
}
```

```
Local IP: [::]:22001
Remote IP: 192.168.178.2:22000
```
Looks like `LocalAddr()` provides only the unresolved address we're listening on?
@marten-seemann we're using `LocalAddr()` as provided by quic-go's `Connection` interface as far as I can see.
So we switch to using the remote address? No need to investigate much deeper, imho.
From our project's perspective, yes. This still looks like a bug to me, which, if correct, should be fixed upstream.
Maybe? Do other "regular" sockets behave differently? For UDP I think this might be expected regardless of what QUIC does.

Fix patch:
diff --git a/lib/connections/structs.go b/lib/connections/structs.go
index 37c8ef48492..21fe7a9f664 100644
--- a/lib/connections/structs.go
+++ b/lib/connections/structs.go
@@ -126,7 +126,7 @@ func (c internalConn) Crypto() string {
 
 func (c internalConn) Transport() string {
 	transport := c.connType.Transport()
-	ip, err := osutil.IPFromAddr(c.LocalAddr())
+	ip, err := osutil.IPFromAddr(c.RemoteAddr())
 	if err != nil {
 		return transport
 	}


Test patch: