Browse Source

add a ResourceManager option

pull/1275/head
Marten Seemann 3 years ago
parent
commit
5f9c4075aa
  1. 3
      config/config.go
  2. 11
      options.go

3
config/config.go

@ -181,6 +181,9 @@ func (cfg *Config) addTransports(h host.Host) error {
if cfg.ConnectionGater != nil {
opts = append(opts, tptu.WithConnectionGater(cfg.ConnectionGater))
}
if cfg.ResourceManager != nil {
opts = append(opts, tptu.WithResourceManager(cfg.ResourceManager))
}
upgrader, err := tptu.New(secure, muxer, opts...)
if err != nil {
return err

11
options.go

@ -346,6 +346,17 @@ func ConnectionGater(cg connmgr.ConnectionGater) Option {
}
}
// ResourceManager configures libp2p to use the given ResourceManager.
func ResourceManager(rcmgr network.ResourceManager) Option {
return func(cfg *Config) error {
if cfg.ResourceManager != nil {
return errors.New("cannot configure multiple resource managers")
}
cfg.ResourceManager = rcmgr
return nil
}
}
// NATPortMap configures libp2p to use the default NATManager. The default
// NATManager will attempt to open a port in your network's firewall using UPnP.
func NATPortMap() Option {

Loading…
Cancel
Save