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

make IPv6 subnet colocation optional as a peer score parameter #387

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions score.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,12 +976,14 @@ func (ps *peerScore) getIPs(p peer.ID) []string {
ip4 := ip.String()
res = append(res, ip4)
} else {
// IPv6 address -- we add both the actual address and the /64 subnet
// IPv6 address -- we add both the actual address and (optionally) the /64 subnet
ip6 := ip.String()
res = append(res, ip6)

ip6mask := ip.Mask(net.CIDRMask(64, 128)).String()
res = append(res, ip6mask)
if ps.params.IPv6SubnetColocation {
ip6mask := ip.Mask(net.CIDRMask(64, 128)).String()
res = append(res, ip6mask)
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions score_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ type PeerScoreParams struct {
IPColocationFactorThreshold int
IPColocationFactorWhitelist map[string]struct{}

// IPv6SubnetColocation controls whether /64 IPv6 subnets should be considered colocated.
IPv6SubnetColocation bool

// P7: behavioural pattern penalties.
// This parameter has an associated counter which tracks misbehaviour as detected by the
// router. The router currently applies penalties for the following behaviors:
Expand Down