From 1f18d0f3e293476bbfd51531e85cf6a69087181f Mon Sep 17 00:00:00 2001 From: Will Scott Date: Tue, 7 Apr 2020 12:34:00 -0700 Subject: [PATCH] Clearer naming of nat override options --- options.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/options.go b/options.go index 107e38db46..8efe9a834b 100644 --- a/options.go +++ b/options.go @@ -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 } }