package dms3p2p import ( "time" config "gitlab.dms3.io/dms3/go-dms3-config" "gitlab.dms3.io/p2p/go-p2p" ) var NatPortMap = simpleOpt(p2p.NATPortMap()) func AutoNATService(throttle *config.AutoNATThrottleConfig) func() P2pOpts { return func() (opts P2pOpts) { opts.Opts = append(opts.Opts, p2p.EnableNATService()) if throttle != nil { global := throttle.GlobalLimit peer := throttle.PeerLimit interval := time.Duration(throttle.Interval) if interval == 0 { interval = time.Minute } opts.Opts = append(opts.Opts, p2p.AutoNATServiceRateLimit(global, peer, interval), ) } return opts } }