Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skip changelog]feat: p2p: environment variables for disabling DHT query filter and routing table filter #12289

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: p2p: environment variables for disabling DHT query filter and r…
…outing table filter
hanabi1224 committed Jul 24, 2024
commit 8fd8378cd9142676bde9b84dc4fe7527c246adfd
20 changes: 18 additions & 2 deletions node/modules/lp2p/host.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@ package lp2p
import (
"context"
"fmt"
"os"
"strings"

"github.com/libp2p/go-libp2p"
dht "github.com/libp2p/go-libp2p-kad-dht"
@@ -92,8 +94,22 @@ func DHTRouting(mode dht.ModeOpt) interface{} {
dht.Datastore(dstore),
dht.Validator(validator),
dht.ProtocolPrefix(build.DhtProtocolName(nn)),
dht.QueryFilter(dht.PublicQueryFilter),
dht.RoutingTableFilter(dht.PublicRoutingTableFilter),
dht.QueryFilter(func(_dht interface{}, ai peer.AddrInfo) bool {
env := strings.ToLower(os.Getenv("LOTUS_P2P_DHT_NO_QUERY_FILTER"))
if env == "1" || env == "true" {
log.Warnf("DHT query filter is disabled. (LOTUS_P2P_DHT_NO_QUERY_FILTER=%s)", env)
return true
}
return dht.PublicQueryFilter(_dht, ai)
}),
dht.RoutingTableFilter(func(_dht interface{}, p peer.ID) bool {
env := strings.ToLower(os.Getenv("LOTUS_P2P_DHT_NO_ROUTING_TABLE_FILTER"))
if env == "1" || env == "true" {
log.Warnf("DHT query filter is disabled. (LOTUS_P2P_DHT_NO_ROUTING_TABLE_FILTER=%s)", env)
return true
}
return dht.PublicRoutingTableFilter(_dht, p)
}),
dht.DisableProviders(),
dht.DisableValues()}
d, err := dht.New(