mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
27 lines
557 B
Go
27 lines
557 B
Go
package libp2p
|
|
|
|
import (
|
|
"time"
|
|
|
|
config "github.com/ipfs/kubo/config"
|
|
"github.com/libp2p/go-libp2p"
|
|
)
|
|
|
|
var NatPortMap = simpleOpt(libp2p.NATPortMap())
|
|
|
|
func AutoNATService(throttle *config.AutoNATThrottleConfig) func() Libp2pOpts {
|
|
return func() (opts Libp2pOpts) {
|
|
opts.Opts = append(opts.Opts, libp2p.EnableNATService())
|
|
if throttle != nil {
|
|
opts.Opts = append(opts.Opts,
|
|
libp2p.AutoNATServiceRateLimit(
|
|
throttle.GlobalLimit,
|
|
throttle.PeerLimit,
|
|
throttle.Interval.WithDefault(time.Minute),
|
|
),
|
|
)
|
|
}
|
|
return opts
|
|
}
|
|
}
|