Repository: syncthing/syncthing (language: go)

Issue:
Discovery server keeps duplicate entries
The global discovery server has each global `tcp://` address of my node twice:

```json
{
   "seen":"2022-08-02T20:12:05.432835713Z",
   "addresses":[
      "quic://192.168.178.20:22001",
      "quic://80.128.xxx.xxx:22001",
      "quic://[2003:da:xxxx:xxxx:xxxx:xxxx:xxxx:f7a0]:22001",
      "quic://[2003:da:xxxx:xxxx:xxxx:xxxx:xxxx:ddc5]:22001",
      "tcp://192.168.178.20:22001",
      "tcp://80.128.xxx.xxx:22001",
      "tcp://80.128.xxx.xxx:22001",
      "tcp://[2003:da:xxxx:xxxx:xxxx:xxxx:xxxx:f7a0]:22001",
      "tcp://[2003:da:xxxx:xxxx:xxxx:xxxx:xxxx:f7a0]:22001",
      "tcp://[2003:da:xxxx:xxxx:xxxx:xxxx:xxxx:ddc5]:22001",
      "tcp://[2003:da:xxxx:xxxx:xxxx:xxxx:xxxx:ddc5]:22001"
   ]
}
```


Discussion / hints:
We should remove duplicates here:

https://github.com/syncthing/syncthing/blob/38bbdebffa74df9e5937749a3780d39b24adc331/cmd/stdiscosrv/apisrv.go#L389

Fix patch:
diff --git a/cmd/stdiscosrv/apisrv.go b/cmd/stdiscosrv/apisrv.go
index 1140e073db7..dfcf2e162f1 100644
--- a/cmd/stdiscosrv/apisrv.go
+++ b/cmd/stdiscosrv/apisrv.go
@@ -27,6 +27,7 @@ import (
 	"time"
 
 	"github.com/syncthing/syncthing/lib/protocol"
+	"github.com/syncthing/syncthing/lib/stringutil"
 )
 
 // announcement is the format received from and sent to clients
@@ -438,6 +439,9 @@ func fixupAddresses(remote *net.TCPAddr, addresses []string) []string {
 		fixed = append(fixed, uri.String())
 	}
 
+	// Remove duplicate addresses
+	fixed = stringutil.UniqueTrimmedStrings(fixed)
+
 	return fixed
 }
 


Test patch: