From fa95c82daf1f569f36c9c54d867379f94c283005 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 11 Sep 2015 15:07:38 +0200 Subject: [PATCH] Add custom networks that are considered local (internal routing, VPN etc) Allows things like this in the element: 10.0.0.0/8 --- cmd/syncthing/main.go | 8 ++++++++ lib/config/config.go | 1 + 2 files changed, 9 insertions(+) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 061cf30be..13ae21f1c 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -595,6 +595,14 @@ func syncthingMain() { for _, lan := range lans { networks = append(networks, lan.String()) } + for _, lan := range opts.AlwaysLocalNets { + _, ipnet, err := net.ParseCIDR(lan) + if err != nil { + l.Infoln("Network", lan, "is malformed:", err) + continue + } + networks = append(networks, ipnet.String()) + } l.Infoln("Local networks:", strings.Join(networks, ", ")) } diff --git a/lib/config/config.go b/lib/config/config.go index 3e4e18083..a1f227622 100644 --- a/lib/config/config.go +++ b/lib/config/config.go @@ -249,6 +249,7 @@ type OptionsConfiguration struct { PingIdleTimeS int `xml:"pingIdleTimeS" json:"pingIdleTimeS" default:"60"` MinHomeDiskFreePct float64 `xml:"minHomeDiskFreePct" json:"minHomeDiskFreePct" default:"1"` ReleasesURL string `xml:"releasesURL" json:"releasesURL" default:"https://api.github.com/repos/syncthing/syncthing/releases?per_page=30"` + AlwaysLocalNets []string `xml:"alwaysLocalNet" json:"alwaysLocalNets"` } func (orig OptionsConfiguration) Copy() OptionsConfiguration {