Skip to content

Commit

Permalink
Clearer naming of nat override options
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott committed Apr 8, 2020
1 parent 0045194 commit 1f18d0f
Showing 1 changed file with 13 additions and 8 deletions.
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

0 comments on commit 1f18d0f

Please sign in to comment.