Skip to content

Commit

Permalink
Don't try to connect to local network peers
Browse files Browse the repository at this point in the history
  • Loading branch information
hayzamjs committed Jul 11, 2021
1 parent b0f78ea commit 02582d2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/ipfs/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ type path struct {
path string
}


var defaultServerFilters = []string{
"/ip4/10.0.0.0/ipcidr/8",
"/ip4/100.64.0.0/ipcidr/10",
"/ip4/169.254.0.0/ipcidr/16",
"/ip4/172.16.0.0/ipcidr/12",
"/ip4/192.0.0.0/ipcidr/24",
"/ip4/192.0.2.0/ipcidr/24",
"/ip4/192.168.0.0/ipcidr/16",
"/ip4/198.18.0.0/ipcidr/15",
"/ip4/198.51.100.0/ipcidr/24",
"/ip4/203.0.113.0/ipcidr/24",
"/ip4/240.0.0.0/ipcidr/4",
"/ip6/100::/ipcidr/64",
"/ip6/2001:2::/ipcidr/48",
"/ip6/2001:db8::/ipcidr/32",
"/ip6/fc00::/ipcidr/7",
"/ip6/fe80::/ipcidr/10",
}

func setupPlugins(externalPluginsPath string) error {
// Load any external plugins if available on externalPluginsPath
plugins, err := loader.NewPluginLoader(filepath.Join(externalPluginsPath, "plugins"))
Expand Down Expand Up @@ -63,6 +83,11 @@ func createTempRepo(ctx context.Context) (string, error) {
return "", err
}

cfg.Addresses.NoAnnounce = defaultServerFilters
cfg.Swarm.AddrFilters = defaultServerFilters
cfg.Discovery.MDNS.Enabled = false
cfg.Swarm.DisableNatPortMap = true

// Create the repo with the config
err = fsrepo.Init(repoPath, cfg)
if err != nil {
Expand Down

0 comments on commit 02582d2

Please sign in to comment.