Skip to content

Add peer-share toggle to lantern-core (Share My Connection PR 3/4)#8729

Open
myleshorton wants to merge 1 commit intomainfrom
fisk/peer-ffi
Open

Add peer-share toggle to lantern-core (Share My Connection PR 3/4)#8729
myleshorton wants to merge 1 commit intomainfrom
fisk/peer-ffi

Conversation

@myleshorton
Copy link
Copy Markdown
Contributor

PR 3 of 4 implementing the lantern-side wiring for Share My Connection (peer-proxy). Builds on radiance #458 (peer module) and #460 (LocalBackend wiring).

Blocked on radiance #460 merging. This PR temporarily bumps radiance to the tip of fisk/peer-localbackend so the new settings.PeerShareEnabledKey is available. Re-pin to a release tag after radiance #460 merges.

Lifecycle

```
Dart toggle → setPeerProxyEnabled(C.int)
→ LanternCore.SetPeerShareEnabled(bool)
→ ipc.Client.PatchSettings({PeerShareEnabledKey: ...})
→ radiance LocalBackend.PatchSettings dispatch
→ peer.Client.Start / Stop
```

What's in here

  • lantern-core/core.go — new PeerShare interface (mirrors Ads / SmartRouting), embedded in Core. SetPeerShareEnabled patches via the radiance IPC client; IsPeerShareEnabled reads the snapshot.
  • lantern-core/ffi/ffi.go//export setPeerProxyEnabled and //export isPeerProxyEnabled, mirroring setBlockAdsEnabled / isBlockAdsEnabled exactly.
  • lantern-core/mobile/mobile.go — gomobile-bind surface (SetPeerShareEnabled / IsPeerShareEnabled) so Android can toggle once Dart wires it up.
  • go.mod / go.sum — provisional radiance bump to 6a238ce (fisk/peer-localbackend tip).

Naming

C export name uses PeerProxy to match the existing user-facing terminology in this repo (the toggle stub in lib/features/setting/vpn_setting.dart was drafted as "Peer Proxy"). Internal Go names use PeerShare to match the radiance setting key (PeerShareEnabledKey). The Dart side will route setPeerProxyEnabled in PR 4.

What's NOT in here (PR 4)

Test plan

  • go build ./lantern-core/...
  • go test ./lantern-core/...
  • golangci-lint run --new-from-rev=origin/main ./lantern-core/...
  • End-to-end manual deferred until PR 4 (when the Dart toggle lands).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 5, 2026 11:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Lantern-side wiring for the Share My Connection feature by introducing a new peer-share toggle in lantern-core, exposed through both gomobile bindings and the existing C FFI surface, and backed by a radiance settings patch.

Changes:

  • Add a PeerShare interface to lantern-core and implement SetPeerShareEnabled / IsPeerShareEnabled via radiance settings (PatchSettings + snapshot read).
  • Expose the toggle through FFI exports (setPeerProxyEnabled / isPeerProxyEnabled) and gomobile (SetPeerShareEnabled / IsPeerShareEnabled).
  • Temporarily bump github.com/getlantern/radiance to a newer pseudo-version containing settings.PeerShareEnabledKey.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lantern-core/mobile/mobile.go Adds gomobile-facing setters/getters to toggle peer-share and query its current state.
lantern-core/ffi/ffi.go Adds C-exported functions to toggle/query peer-share from the Dart/FFI layer.
lantern-core/core.go Introduces PeerShare interface and core implementation backed by radiance settings.
go.mod Updates the radiance dependency to a newer pseudo-version for the new settings key.
go.sum Updates sums to match the radiance version bump.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

myleshorton pushed a commit that referenced this pull request May 5, 2026
Final PR in the four-PR stack. Stacks on lantern #8729 (FFI exports);
combined with radiance #458 / #460 / lantern-cloud #2678-#2681 this
ships a feature-complete Phase 1 of "Share My Connection" for desktop
(macOS + Linux + Windows).

* lantern_generated_bindings.dart: add setPeerProxyEnabled +
  isPeerProxyEnabled. Manually inserted to match the existing pattern
  rather than regenerating the whole file (a local ffigen run from
  the macOS header would drop ~5K lines of Windows-only declarations
  the upstream generator emits).
* LanternCoreService / LanternFFIService / LanternPlatformService /
  LanternService: add setPeerProxyEnabled / isPeerProxyEnabled across
  all four service layers, mirroring the setBlockAdsEnabled pattern.
  FFI path on isFFISupported platforms (Windows + Linux), MethodChannel
  fallback on macOS / mobile.
* RadianceSettingsState: new peerProxy bool field with copyWith and
  equality.
* RadianceSettings notifier: new setPeerProxy method (pessimistic —
  call FFI, log on failure, update state on success — matching
  setBlockAds). _refresh now reads peerProxy alongside the others.
* vpn_setting.dart: SwitchButton tile gated to PlatformUtils.isDesktop
  with i18n strings share_my_connection / share_my_connection_subtitle
  in en.po. Other locales will pick up via the standard translation
  flow.

Lifecycle end-to-end:

  Dart toggle → RadianceSettings.setPeerProxy(bool)
  → LanternService.setPeerProxyEnabled
  → FFI: setPeerProxyEnabled(int) -> *char
  → Core.SetPeerShareEnabled(bool)
  → ipc.Client.PatchSettings({PeerShareEnabledKey: ...})
  → radiance LocalBackend.PatchSettings dispatch
  → peer.Client.Start / Stop
  → UPnP MapPort + register + sing-box samizdat inbound + heartbeat

flutter analyze: clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PR 3 of 4 implementing the lantern-side wiring for "Share My
Connection". Bumps radiance to fisk/peer-localbackend tip so we can
reference the new PeerShareEnabledKey setting; that bump is provisional
and should be re-pinned to a release tag once radiance #460 merges.

* lantern-core/core.go: new PeerShare interface (mirrors Ads /
  SmartRouting), embedded in Core. SetPeerShareEnabled patches
  PeerShareEnabledKey via the radiance ipc client; IsPeerShareEnabled
  reads the snapshot.
* lantern-core/ffi/ffi.go: new //export setPeerProxyEnabled and
  //export isPeerProxyEnabled, mirroring setBlockAdsEnabled exactly.
  The Dart FFI binding name uses "PeerProxy" to match the existing
  user-facing naming in the lantern repo (vpn_setting.dart toggle was
  drafted as "Peer Proxy").
* lantern-core/mobile/mobile.go: SetPeerShareEnabled / IsPeerShareEnabled
  for the gomobile-bind surface so Android can toggle once Dart wires
  it up in PR 4.

The lifecycle path:

  Dart toggle → setPeerProxyEnabled(enabled)
  → LanternCore.SetPeerShareEnabled
  → ipc.Client.PatchSettings({PeerShareEnabledKey: ...})
  → radiance LocalBackend.PatchSettings dispatch
  → peer.Client.Start / Stop

ffigen regen for the Dart bindings happens in PR 4 alongside the Dart
wire-through and rollback logic.

go test ./lantern-core/... and golangci-lint --new-from-rev=origin/main
both clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
myleshorton pushed a commit that referenced this pull request May 5, 2026
Final PR in the four-PR stack. Stacks on lantern #8729 (FFI exports);
combined with radiance #458 / #460 / lantern-cloud #2678-#2681 this
ships a feature-complete Phase 1 of "Share My Connection" for desktop
(macOS + Linux + Windows).

* lantern_generated_bindings.dart: add setPeerProxyEnabled +
  isPeerProxyEnabled. Manually inserted to match the existing pattern
  rather than regenerating the whole file (a local ffigen run from
  the macOS header would drop ~5K lines of Windows-only declarations
  the upstream generator emits).
* LanternCoreService / LanternFFIService / LanternPlatformService /
  LanternService: add setPeerProxyEnabled / isPeerProxyEnabled across
  all four service layers, mirroring the setBlockAdsEnabled pattern.
  FFI path on isFFISupported platforms (Windows + Linux), MethodChannel
  fallback on macOS / mobile.
* RadianceSettingsState: new peerProxy bool field with copyWith and
  equality.
* RadianceSettings notifier: new setPeerProxy method (pessimistic —
  call FFI, log on failure, update state on success — matching
  setBlockAds). _refresh now reads peerProxy alongside the others.
* vpn_setting.dart: SwitchButton tile gated to PlatformUtils.isDesktop
  with i18n strings share_my_connection / share_my_connection_subtitle
  in en.po. Other locales will pick up via the standard translation
  flow.

Lifecycle end-to-end:

  Dart toggle → RadianceSettings.setPeerProxy(bool)
  → LanternService.setPeerProxyEnabled
  → FFI: setPeerProxyEnabled(int) -> *char
  → Core.SetPeerShareEnabled(bool)
  → ipc.Client.PatchSettings({PeerShareEnabledKey: ...})
  → radiance LocalBackend.PatchSettings dispatch
  → peer.Client.Start / Stop
  → UPnP MapPort + register + sing-box samizdat inbound + heartbeat

flutter analyze: clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants