feat(desktop): choose the network interface used for LAN pairing URLs #10838
ClosedPJalv(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/10838/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -69,3 +72,10 @@6972 !address.startsWith("169.254.") &&7073 !isTailscaleIpv4Address(address);717475+/**76+ * Interface name patterns that are container/VM/tunnel bridges rather than a77+ * physical adapter the phone would share a LAN with. Never advertised unless78+ * nothing else exists.79+ */80+const VIRTUAL_INTERFACE_NAME_PATTERN =81+ /^(?:docker\d*|br-[0-9a-f]+|virbr\d*|veth\w*|vmnet\d*|vEthernet[\s\w]*|wg\d*|tun\d+|lo)$/iu;@@ -3099,3 +3142,10 @@30993142 control={renderNetworkAccessToggle()}31003143 />31013144 );3145+ const renderPreferredLanInterfaceRow = () => {3146+ if (!desktopBridge || desktopLanInterfaces.length < 2) {3147+ return null;3148+ }3149+ const selectValue = preferredLanInterfaceName ?? "auto";3150+ const automaticCandidate = desktopLanInterfaces.find(3151+ (candidate) => candidate.name === desktopServerExposureState?.advertisedHost,@@ -168,3 +221,4 @@168221 ];169222170223 if (input.exposure.endpointUrl) {224+ const lanCandidates = enumerateLanInterfaces(input.networkInterfaces ?? {}).filter(@@ -176,6 +242,8 @@176242 reachability: "lan",177243 status: "available",178244 isDefault: true,245+ ...(advertisedInterfaceName ? { interfaceName: advertisedInterfaceName } : {}),179246 description: "Reachable from devices on the same network.",180247 }),181248 );249+ for (const candidate of alternativeInterfaces.slice(0, 8)) {@@ -98,3 +106,4 @@98106 mainWindowBounds: Schema.optionalKey(Schema.NullOr(DesktopWindowBoundsDocument)),99107 mainWindowMaximized: Schema.optionalKey(Schema.Boolean),100108 serverExposureMode: Schema.optionalKey(DesktopServerExposureModeSchema),109+ preferredLanInterfaceName: Schema.optionalKey(Schema.NullOr(Schema.String)),
- apps/desktop/src/backend/DesktopServerExposure.ts line 81OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -69,3 +72,10 @@6972 !address.startsWith("169.254.") &&7073 !isTailscaleIpv4Address(address);717475+/**76+ * Interface name patterns that are container/VM/tunnel bridges rather than a77+ * physical adapter the phone would share a LAN with. Never advertised unless78+ * nothing else exists.79+ */80+const VIRTUAL_INTERFACE_NAME_PATTERN =81+ /^(?:docker\d*|br-[0-9a-f]+|virbr\d*|veth\w*|vmnet\d*|vEthernet[\s\w]*|wg\d*|tun\d+|lo)$/iu;apps/desktop/src/backend/DesktopServerExposure.ts lines 698 to 699Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -532,7 +651,21 @@651+ settings: result.settings,652+ port: previous.port,653+ networkInterfaces: currentNetworkInterfaces,654+ advertisedHostOverride: config.desktopLanHostOverride,655+ });656+ yield* Ref.set(stateRef, resolved.state);657+ return {658+ state: toContractState(resolved.state),659+ requiresRelaunch: requiresBackendRelaunch(previous, resolved.state),660+ };661+ });662+532663 const getAdvertisedEndpoints = Effect.gen(function* () {533664 const state = yield* Ref.get(stateRef);534665 const currentNetworkInterfaces = yield* readNetworkInterfaces;535666 const coreEndpoints = resolveDesktopCoreAdvertisedEndpoints({536667 port: state.port,537668 exposure: toResolvedExposure(state),538669 customHttpsEndpointUrls: config.desktopHttpsEndpointUrls,670+ networkInterfaces: currentNetworkInterfaces,671+ advertisedHostOverride: Option.getOrNull(config.desktopLanHostOverride),apps/web/src/components/settings/ConnectionsSettings.tsx lines 3146 to 3148OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -3099,3 +3142,7 @@30993142 control={renderNetworkAccessToggle()}31003143 />31013144 );3145+ const renderPreferredLanInterfaceRow = () => {3146+ if (!desktopBridge || desktopLanInterfaces.length < 2) {3147+ return null;3148+ }@@ -3099,3 +3142,11 @@30993142 control={renderNetworkAccessToggle()}31003143 />31013144 );3145+ const renderPreferredLanInterfaceRow = () => {3146+ if (!desktopBridge || desktopLanInterfaces.length < 2) {3147+ return null;3148+ }3149+ const selectValue = preferredLanInterfaceName ?? "auto";3150+ const automaticCandidate = desktopLanInterfaces.find(3151+ (candidate) => candidate.name === desktopServerExposureState?.advertisedHost,3152+ );
- apps/desktop/src/backend/DesktopServerExposure.ts line 81OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -69,3 +72,10 @@6972 !address.startsWith("169.254.") &&7073 !isTailscaleIpv4Address(address);717475+/**76+ * Interface name patterns that are container/VM/tunnel bridges rather than a77+ * physical adapter the phone would share a LAN with. Never advertised unless78+ * nothing else exists.79+ */80+const VIRTUAL_INTERFACE_NAME_PATTERN =81+ /^(?:docker\d*|br-[0-9a-f]+|virbr\d*|veth\w*|vmnet\d*|vEthernet[\s\w()]*|wg\d*|tun\d+|lo)$/iu;
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed