浏览代码

lib/connections: Correctly add port to portless tcp:// URLs (fixes #3115)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3116
Jakob Borg 9 年之前
父节点
当前提交
8e060e23e3
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      lib/connections/tcp_listen.go

+ 1 - 1
lib/connections/tcp_listen.go

@@ -185,7 +185,7 @@ func fixupPort(uri *url.URL) *url.URL {
 	host, port, err := net.SplitHostPort(uri.Host)
 	host, port, err := net.SplitHostPort(uri.Host)
 	if err != nil && strings.HasPrefix(err.Error(), "missing port") {
 	if err != nil && strings.HasPrefix(err.Error(), "missing port") {
 		// addr is on the form "1.2.3.4"
 		// addr is on the form "1.2.3.4"
-		copyURI.Host = net.JoinHostPort(host, "22000")
+		copyURI.Host = net.JoinHostPort(uri.Host, "22000")
 	} else if err == nil && port == "" {
 	} else if err == nil && port == "" {
 		// addr is on the form "1.2.3.4:"
 		// addr is on the form "1.2.3.4:"
 		copyURI.Host = net.JoinHostPort(host, "22000")
 		copyURI.Host = net.JoinHostPort(host, "22000")