-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes: #4788 default ip4/ip6 blocked ranges https://github.com/spacemeshos/go-spacemesh/blob/a8f86a19fffde6141110b21d398b65bf017d2c57/p2p/host.go#L48-L66C1 to disable them set `"ip4-blocklist": []` or `"ip6-blocklist": []` in config. if `private-network` is set to true, blocklists will be ignored. that option meant to be used only in testing networks. `direct` peers will bypass blocklists validation.
- Loading branch information
Showing
3 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package p2p | ||
|
||
import ( | ||
"testing" | ||
|
||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" | ||
"github.com/multiformats/go-multiaddr" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGater(t *testing.T) { | ||
cfg := DefaultConfig() | ||
h, err := mocknet.New().GenPeer() | ||
require.NoError(t, err) | ||
gater, err := newGater(cfg) | ||
require.NoError(t, err) | ||
gater.updateHost(h) | ||
for _, tc := range []struct { | ||
address string | ||
allowed bool | ||
}{ | ||
{address: "/ip4/127.0.0.1/tcp/8000"}, | ||
{address: "/ip4/192.168.0.3/tcp/8000"}, | ||
{address: "/ip6/fe80::42:44ff:fe2a:87c5/tcp/8000"}, | ||
{address: "/ip6/fe80::42:44ff:fe2a:87c5/tcp/8000"}, | ||
{address: "/ip4/95.217.200.84/tcp/8000", allowed: true}, | ||
} { | ||
t.Run(tc.address, func(t *testing.T) { | ||
addr, err := multiaddr.NewMultiaddr(tc.address) | ||
require.NoError(t, err) | ||
require.Equal(t, tc.allowed, gater.InterceptAddrDial("", addr)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters