From 622568c327dab8d0d030bb878d6785daa135ec96 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 16 Apr 2014 15:28:45 +0200 Subject: [PATCH] Handle static addresses without port (fixes #131) --- cmd/syncthing/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 04d6008ba..aa16b163d 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -397,6 +397,14 @@ func listenConnect(myID string, disc *discover.Discoverer, m *Model, tlsCfg *tls } for _, addr := range addrs { + host, port, err := net.SplitHostPort(addr) + if err != nil && strings.HasPrefix(err.Error(), "missing port") { + // addr is on the form "1.2.3.4" + addr = net.JoinHostPort(addr, "22000") + } else if err == nil && port == "" { + // addr is on the form "1.2.3.4:" + addr = net.JoinHostPort(host, "22000") + } if debugNet { dlog.Println("dial", nodeCfg.NodeID, addr) }