Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearer naming of nat override options #878

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,20 @@ func DefaultStaticRelays() Option {
}
}

// WithReachability overrides automatic reachability detection to force the local node
// to believe it is either unreachable or reachable externally.
func WithReachability(reachable bool) Option {
// ForceReachabilityPublic overrides automatic reachability detection in the AutoNAT subsystem,
// forcing the local node to believe it is reachable externally.
func ForceReachabilityPublic() Option {
return func(cfg *Config) error {
if reachable {
cfg.Reachability = network.ReachabilityPublic
} else {
cfg.Reachability = network.ReachabilityPrivate
}
cfg.Reachability = network.ReachabilityPublic
return nil
}
}

// ForceReachabilityPrivate overrides automatic reachability detection in the AutoNAT subsystem,
// forceing the local node to believe it is behind a NAT and not reachable externally.
func ForceReachabilityPrivate() Option {
return func(cfg *Config) error {
cfg.Reachability = network.ReachabilityPrivate
return nil
}
}
Expand Down