Skip to content

Commit

Permalink
remove deprecated Filter option
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jul 23, 2021
1 parent d38694b commit 08aaa43
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 171 deletions.
55 changes: 0 additions & 55 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package libp2p
import (
"errors"
"fmt"
"net"
"time"

circuit "github.com/libp2p/go-libp2p-circuit"
Expand Down Expand Up @@ -327,60 +326,6 @@ func AutoNATServiceRateLimit(global, perPeer int, interval time.Duration) Option
}
}

// FilterAddresses configures libp2p to never dial nor accept connections from
// the given addresses. FilterAddresses should be used for cases where the
// addresses you want to deny are known ahead of time.
//
// Note: Using Filter + FilterAddresses at the same time is fine, but you cannot
// configure a both ConnectionGater and filtered addresses.
//
// Deprecated: Please use ConnectionGater() instead.
func FilterAddresses(addrs ...*net.IPNet) Option {
return func(cfg *Config) error {
var f *filtersConnectionGater

// preserve backwards compatibility.
// if we have a connection gater, try to cast it to a *filtersConnectionGater.
if cfg.ConnectionGater != nil {
var ok bool
if f, ok = cfg.ConnectionGater.(*filtersConnectionGater); !ok {
return errors.New("cannot configure both Filters and Connection Gater; please consider configuring just a ConnectionGater instead")
}
}

if f == nil {
f = (*filtersConnectionGater)(ma.NewFilters())
cfg.ConnectionGater = f
}

for _, addr := range addrs {
(*ma.Filters)(f).AddFilter(*addr, ma.ActionDeny)
}

return nil
}
}

// Filters configures libp2p to use the given filters for accepting/denying
// certain addresses. Filters offers more control and should be used when the
// addresses you want to accept/deny are not known ahead of time and can
// dynamically change.
//
// Note: You cannot configure both a ConnectionGater and a Filter at the same
// time. Under the hood, the Filters object is converted to a ConnectionGater.
//
// Deprecated: use ConnectionGater() instead.
func Filters(filters *ma.Filters) Option {
return func(cfg *Config) error {
if cfg.ConnectionGater != nil {
return errors.New("cannot configure both Filters and Connection Gater; please consider configuring just a ConnectionGater instead")

}
cfg.ConnectionGater = (*filtersConnectionGater)(filters)
return nil
}
}

// ConnectionGater configures libp2p to use the given ConnectionGater
// to actively reject inbound/outbound connections based on the lifecycle stage
// of the connection.
Expand Down
116 changes: 0 additions & 116 deletions options_test.go

This file was deleted.

0 comments on commit 08aaa43

Please sign in to comment.