-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Enable AutoNATService on _all_ nodes by default. If it's an issue, we can disable it in RC3 but this will give us the best testing results. 2. Expose options to configure AutoNAT rate limiting.
- Loading branch information
Showing
5 changed files
with
91 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
package libp2p | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/ipfs/go-ipfs-config" | ||
"github.com/libp2p/go-libp2p" | ||
) | ||
|
||
var NatPortMap = simpleOpt(libp2p.NATPortMap()) | ||
var AutoNATService = simpleOpt(libp2p.EnableNATService()) | ||
|
||
func AutoNATService(throttle *config.AutoNATThrottleConfig) func() Libp2pOpts { | ||
return func() (opts Libp2pOpts) { | ||
opts.Opts = append(opts.Opts, libp2p.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, | ||
libp2p.AutoNATServiceRateLimit(global, peer, interval), | ||
) | ||
} | ||
return opts | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters