You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
peer: manual port-forward override for UPnP-less networks (#500)
* peer: read PeerManualPortKey setting alongside RADIANCE_PEER_EXTERNAL_PORT
Adds settings.PeerManualPortKey so the user-facing Advanced UI can
persist the manual port forward without an env var. Resolution order
in peer.Client.Start's NewForwarder:
1. settings.PeerManualPortKey (Advanced UI in lantern Flutter)
2. RADIANCE_PEER_EXTERNAL_PORT env var (developer / power-user)
3. UPnP discovery (default)
The setting is wired through lantern-core's
PatchSettings(PeerShareEnabledKey...) path on a separate branch — the
new `setPeerManualPort` FFI export over there calls
PatchSettings({PeerManualPortKey: <int>}) which lands in radiance's
settings store and gets picked up on the next peer.Client.Start.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* portforward: extract manual port forwarder to its own file
The manual port forwarder landed in peer/peer.go via #466 (commit a342889)
to support routers without UPnP. Move it to the portforward package
alongside the UPnP-based Forwarder so every portForwarder implementation
lives in one place.
Net zero functional change, just relocation:
peer/peer.go
- manualPortForwarder type + 4 method receivers
- manualPort() env-parser helper
- 'strconv' import (no longer needed)
+ NewForwarder closure now calls portforward.NewManualForwarder /
portforward.ParseManualPort
peer/peer_test.go
- TestManualPort + TestManualPortForwarder (moved out of peer pkg)
portforward/manual.go (new)
+ ManualForwarder + NewManualForwarder
+ ParseManualPort (the env-parser, factored out so callers can decide
whether to log + fall through or treat as a hard error)
+ MapPort/UnmapPort/StartRenewal/ExternalIP methods
+ 'manual' method tag (was 'manual-env'; dropped the -env suffix
since this implementation now serves both env and setting paths)
portforward/manual_test.go (new)
+ TestParseManualPort (9 input cases — boundaries, invalid, empty)
+ TestManualForwarder (full portForwarder contract)
The peer package retains the portForwarder *interface* — that's where
peer expresses what it needs from a forwarder; the concrete implementations
live in portforward.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* peer/portforward/settings: address Copilot review on #500
Four substantive findings; three additional Copilot comments review a
pre-consolidation state of portforward/manual.go that the consolidation
commit (22d1533) replaced wholesale — those are answered with the
relevant context in the thread replies.
1. peer.Client.Start now range-checks the PeerManualPortKey setting
before casting to uint16. A raw uint16 cast silently wraps negative
values (-5 → 65531) and values above the port space (70000 → 4464),
which would register a port the peer doesn't listen on (or, worse,
one it does listen on for a different service). Out-of-range values
are now logged at Warn and fall through to env-var / UPnP as if the
setting were unset.
2. common/settings PeerManualPortKey doc now documents the 1..65535
valid range, behavior on out-of-range values, and the 0=unset
contract. Dropped the peer.Client.Start / portforward.ManualForwarder
code-location references — describes the contract generically.
3. portforward.NewManualForwarder doc tightened to state the caller-
side validation contract (port must be 1..65535) without naming
ParseManualPort or 'env-var path' / 'setting' as callers.
No behavior change in #2 or #3; only #1 changes runtime behavior, and
only for invalid setting values.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* peer/portforward: address Copilot review on #500 (round 2)
Two doc-lint follow-ups per AGENTS.md (no code-location refs in
comments):
1. portforward.ManualForwarder doc dropped the 'satisfies the
portForwarder contract' phrasing (portForwarder is the peer
package's private interface; mentioning it crosses a package
boundary) and the 'peer.Client at it via setting or env var'
reference. The new wording describes the type in terms of this
package's own exported API: 'exposes the same Map/Unmap/
StartRenewal/ExternalIP surface as Forwarder but does no UPnP
work.'
2. peer.Client.Start's resolution-order comment now spells the
persisted setting name in quotes ('peer_manual_port') rather than
the Go identifier (settings.PeerManualPortKey). The persisted
name is the stable contract — if the Go identifier ever moves or
renames, the comment stays correct without needing to be updated.
Same treatment for the env-var line, which already used the
stable name string.
No behavior change.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Adam Fisk <afisk@mini.local>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments