Skip to content

Commit 02582d2

Browse files
committed
Don't try to connect to local network peers
1 parent b0f78ea commit 02582d2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/ipfs/root.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ type path struct {
3131
path string
3232
}
3333

34+
35+
var defaultServerFilters = []string{
36+
"/ip4/10.0.0.0/ipcidr/8",
37+
"/ip4/100.64.0.0/ipcidr/10",
38+
"/ip4/169.254.0.0/ipcidr/16",
39+
"/ip4/172.16.0.0/ipcidr/12",
40+
"/ip4/192.0.0.0/ipcidr/24",
41+
"/ip4/192.0.2.0/ipcidr/24",
42+
"/ip4/192.168.0.0/ipcidr/16",
43+
"/ip4/198.18.0.0/ipcidr/15",
44+
"/ip4/198.51.100.0/ipcidr/24",
45+
"/ip4/203.0.113.0/ipcidr/24",
46+
"/ip4/240.0.0.0/ipcidr/4",
47+
"/ip6/100::/ipcidr/64",
48+
"/ip6/2001:2::/ipcidr/48",
49+
"/ip6/2001:db8::/ipcidr/32",
50+
"/ip6/fc00::/ipcidr/7",
51+
"/ip6/fe80::/ipcidr/10",
52+
}
53+
3454
func setupPlugins(externalPluginsPath string) error {
3555
// Load any external plugins if available on externalPluginsPath
3656
plugins, err := loader.NewPluginLoader(filepath.Join(externalPluginsPath, "plugins"))
@@ -63,6 +83,11 @@ func createTempRepo(ctx context.Context) (string, error) {
6383
return "", err
6484
}
6585

86+
cfg.Addresses.NoAnnounce = defaultServerFilters
87+
cfg.Swarm.AddrFilters = defaultServerFilters
88+
cfg.Discovery.MDNS.Enabled = false
89+
cfg.Swarm.DisableNatPortMap = true
90+
6691
// Create the repo with the config
6792
err = fsrepo.Init(repoPath, cfg)
6893
if err != nil {

0 commit comments

Comments
 (0)