Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion p2p/protocol/autonatv2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ func amplificationAttackPrevention(observedAddr, dialAddr ma.Multiaddr) bool {
if err != nil {
return true
}
dialIP, _ := manet.ToIP(dialAddr) // must be an IP multiaddr
dialIP, err := manet.ToIP(dialAddr) // can be dns addr
if err != nil {
return true
}
return !observedIP.Equal(dialIP)
}
7 changes: 7 additions & 0 deletions p2p/protocol/autonatv2/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,13 @@ func TestDefaultAmplificationAttackPrevention(t *testing.T) {

t2 := ma.StringCast("/ip4/1.1.1.1/tcp/1235") // different IP
require.True(t, amplificationAttackPrevention(q2, t2))

// always ask dial data for dns addrs
d1 := ma.StringCast("/dns/localhost/udp/1/quic-v1")
d2 := ma.StringCast("/dnsaddr/libp2p.io/tcp/1")
require.True(t, amplificationAttackPrevention(d1, t1))
require.True(t, amplificationAttackPrevention(d2, t1))

}

func FuzzServerDialRequest(f *testing.F) {
Expand Down
Loading