Merge pull request #5735 from filecoin-project/feat/pubsub-ip-colocatio-whitelist
Add configuration option for pubsub IPColocationWhitelist subnets
This commit is contained in:
commit
b13046293f
2
go.mod
2
go.mod
@ -106,7 +106,7 @@ require (
|
|||||||
github.com/libp2p/go-libp2p-mplex v0.3.0
|
github.com/libp2p/go-libp2p-mplex v0.3.0
|
||||||
github.com/libp2p/go-libp2p-noise v0.1.2
|
github.com/libp2p/go-libp2p-noise v0.1.2
|
||||||
github.com/libp2p/go-libp2p-peerstore v0.2.6
|
github.com/libp2p/go-libp2p-peerstore v0.2.6
|
||||||
github.com/libp2p/go-libp2p-pubsub v0.4.1
|
github.com/libp2p/go-libp2p-pubsub v0.4.2-0.20210212194758-6c1addf493eb
|
||||||
github.com/libp2p/go-libp2p-quic-transport v0.9.0
|
github.com/libp2p/go-libp2p-quic-transport v0.9.0
|
||||||
github.com/libp2p/go-libp2p-record v0.1.3
|
github.com/libp2p/go-libp2p-record v0.1.3
|
||||||
github.com/libp2p/go-libp2p-routing-helpers v0.2.3
|
github.com/libp2p/go-libp2p-routing-helpers v0.2.3
|
||||||
|
4
go.sum
4
go.sum
@ -923,8 +923,8 @@ github.com/libp2p/go-libp2p-protocol v0.0.1/go.mod h1:Af9n4PiruirSDjHycM1QuiMi/1
|
|||||||
github.com/libp2p/go-libp2p-protocol v0.1.0/go.mod h1:KQPHpAabB57XQxGrXCNvbL6UEXfQqUgC/1adR2Xtflk=
|
github.com/libp2p/go-libp2p-protocol v0.1.0/go.mod h1:KQPHpAabB57XQxGrXCNvbL6UEXfQqUgC/1adR2Xtflk=
|
||||||
github.com/libp2p/go-libp2p-pubsub v0.1.1/go.mod h1:ZwlKzRSe1eGvSIdU5bD7+8RZN/Uzw0t1Bp9R1znpR/Q=
|
github.com/libp2p/go-libp2p-pubsub v0.1.1/go.mod h1:ZwlKzRSe1eGvSIdU5bD7+8RZN/Uzw0t1Bp9R1znpR/Q=
|
||||||
github.com/libp2p/go-libp2p-pubsub v0.3.2-0.20200527132641-c0712c6e92cf/go.mod h1:TxPOBuo1FPdsTjFnv+FGZbNbWYsp74Culx+4ViQpato=
|
github.com/libp2p/go-libp2p-pubsub v0.3.2-0.20200527132641-c0712c6e92cf/go.mod h1:TxPOBuo1FPdsTjFnv+FGZbNbWYsp74Culx+4ViQpato=
|
||||||
github.com/libp2p/go-libp2p-pubsub v0.4.1 h1:j4umIg5nyus+sqNfU+FWvb9aeYFQH/A+nDFhWj+8yy8=
|
github.com/libp2p/go-libp2p-pubsub v0.4.2-0.20210212194758-6c1addf493eb h1:HExLcdXn8fgtXPciUw97O5NNhBn31dt6d9fVUD4cngo=
|
||||||
github.com/libp2p/go-libp2p-pubsub v0.4.1/go.mod h1:izkeMLvz6Ht8yAISXjx60XUQZMq9ZMe5h2ih4dLIBIQ=
|
github.com/libp2p/go-libp2p-pubsub v0.4.2-0.20210212194758-6c1addf493eb/go.mod h1:izkeMLvz6Ht8yAISXjx60XUQZMq9ZMe5h2ih4dLIBIQ=
|
||||||
github.com/libp2p/go-libp2p-quic-transport v0.1.1/go.mod h1:wqG/jzhF3Pu2NrhJEvE+IE0NTHNXslOPn9JQzyCAxzU=
|
github.com/libp2p/go-libp2p-quic-transport v0.1.1/go.mod h1:wqG/jzhF3Pu2NrhJEvE+IE0NTHNXslOPn9JQzyCAxzU=
|
||||||
github.com/libp2p/go-libp2p-quic-transport v0.5.0/go.mod h1:IEcuC5MLxvZ5KuHKjRu+dr3LjCT1Be3rcD/4d8JrX8M=
|
github.com/libp2p/go-libp2p-quic-transport v0.5.0/go.mod h1:IEcuC5MLxvZ5KuHKjRu+dr3LjCT1Be3rcD/4d8JrX8M=
|
||||||
github.com/libp2p/go-libp2p-quic-transport v0.9.0 h1:WPuq5nV/chmIZIzvrkC2ulSdAQ0P0BDvgvAhZFOZ59E=
|
github.com/libp2p/go-libp2p-quic-transport v0.9.0 h1:WPuq5nV/chmIZIzvrkC2ulSdAQ0P0BDvgvAhZFOZ59E=
|
||||||
|
@ -116,6 +116,7 @@ type Libp2p struct {
|
|||||||
type Pubsub struct {
|
type Pubsub struct {
|
||||||
Bootstrapper bool
|
Bootstrapper bool
|
||||||
DirectPeers []string
|
DirectPeers []string
|
||||||
|
IPColocationWhitelist []string
|
||||||
RemoteTracer string
|
RemoteTracer string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package lp2p
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
host "github.com/libp2p/go-libp2p-core/host"
|
host "github.com/libp2p/go-libp2p-core/host"
|
||||||
@ -198,6 +199,16 @@ func GossipSub(in GossipIn) (service *pubsub.PubSub, err error) {
|
|||||||
drandTopics = append(drandTopics, topic)
|
drandTopics = append(drandTopics, topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IP colocation whitelist
|
||||||
|
var ipcoloWhitelist []*net.IPNet
|
||||||
|
for _, cidr := range in.Cfg.IPColocationWhitelist {
|
||||||
|
_, ipnet, err := net.ParseCIDR(cidr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("error parsing IPColocation subnet %s: %w", cidr, err)
|
||||||
|
}
|
||||||
|
ipcoloWhitelist = append(ipcoloWhitelist, ipnet)
|
||||||
|
}
|
||||||
|
|
||||||
options := []pubsub.Option{
|
options := []pubsub.Option{
|
||||||
// Gossipsubv1.1 configuration
|
// Gossipsubv1.1 configuration
|
||||||
pubsub.WithFloodPublish(true),
|
pubsub.WithFloodPublish(true),
|
||||||
@ -228,8 +239,7 @@ func GossipSub(in GossipIn) (service *pubsub.PubSub, err error) {
|
|||||||
// This sets the IP colocation threshold to 5 peers before we apply penalties
|
// This sets the IP colocation threshold to 5 peers before we apply penalties
|
||||||
IPColocationFactorThreshold: 5,
|
IPColocationFactorThreshold: 5,
|
||||||
IPColocationFactorWeight: -100,
|
IPColocationFactorWeight: -100,
|
||||||
// TODO we want to whitelist IPv6 /64s that belong to datacenters etc
|
IPColocationFactorWhitelist: ipcoloWhitelist,
|
||||||
// IPColocationFactorWhitelist: map[string]struct{}{},
|
|
||||||
|
|
||||||
// P7: behavioural penalties, decay after 1hr
|
// P7: behavioural penalties, decay after 1hr
|
||||||
BehaviourPenaltyThreshold: 6,
|
BehaviourPenaltyThreshold: 6,
|
||||||
|
Loading…
Reference in New Issue
Block a user