Skip to content

Bug 2034845 - Fix broken Access Connector on policy modification#809

Open
jporter-dev wants to merge 8 commits into
mozilla:enterprise-mainfrom
jporter-dev:enterprise-bug2034845-access-connector-live-policy-modification
Open

Bug 2034845 - Fix broken Access Connector on policy modification#809
jporter-dev wants to merge 8 commits into
mozilla:enterprise-mainfrom
jporter-dev:enterprise-bug2034845-access-connector-live-policy-modification

Conversation

@jporter-dev
Copy link
Copy Markdown
Contributor

@jporter-dev jporter-dev commented Apr 28, 2026

Description

This PR fixes an issue that occurs when the AccessConnector policy is modified in-place (not added/removed). This results in a broken access connector due to the #inclusionList not being updated when MatchPatterns changes, and the connection not being re-initialized with the new server when the serverlist changes (host/port in policy)

Bugzilla: Bug-2034845

  • IPProtectionServerlist.sys.mjs: fix PrefServerList pref observer registration (was referencing instance instead of class), skip in maybeFetchList() when pref value is unchanged
  • IPPChannelFilter.sys.mjs: register/unregister pref observer to refresh #inclusionSet when changed
  • IPPProxyManager.sys.mjs: add reconnect method for reconnecting to the recommended server from the updated list
  • IPPAutoStart.sys.mjs: add logic to #handleListChanged to reconnect on live changes

Dependencies / Related Issues


Testing

  • Manual testing performed

Steps to verify changes:

  1. Enable AccessConnector policy
  2. Launch browser and navigate to a matching URL
  3. Observe active AccessConnector state
  4. Remove or change matching URL from MatchPatterns
    • This updates the icon live without requiring new navigation or refresh
  5. Observe inactive AccessConnector state
  6. Repeat above for host or port
    • Serverlist changes require new navigation to update
    • Previously new navigation used the old server
    • Changing to an invalid port will result in broken proxy, changing back should fix it

Expected result:

AccessConnector shows active/inactive properly when modifying policy

@jporter-dev jporter-dev self-assigned this Apr 28, 2026
@jporter-dev jporter-dev added bug Something isn't working branch:main PR that should be merged on enterprise-main branch labels Apr 28, 2026
@jporter-dev jporter-dev force-pushed the enterprise-bug2034845-access-connector-live-policy-modification branch 4 times, most recently from 94a8a20 to 47d71ac Compare April 29, 2026 22:15
@jporter-dev jporter-dev marked this pull request as ready for review April 30, 2026 12:51
@jporter-dev jporter-dev force-pushed the enterprise-bug2034845-access-connector-live-policy-modification branch from 47d71ac to 8436997 Compare April 30, 2026 13:05
@lissyx lissyx self-requested a review May 4, 2026 13:41
@lissyx
Copy link
Copy Markdown
Contributor

lissyx commented May 5, 2026

@jporter-dev Now that we have #825 there is no reason not to rebase and add proper testing to ensure this does not regress

Comment thread toolkit/components/ipprotection/IPPAutoStart.sys.mjs Outdated
Comment on lines +61 to +82
if (this.autoStart) {
const state = lazy.IPPProxyManager.state;
if (state === lazy.IPPProxyStates.ACTIVE) {
lazy.IPPProxyManager.switch();
return;
}
if (state === lazy.IPPProxyStates.ERROR) {
await lazy.IPPProxyManager.reset();
lazy.IPPProxyManager.start(
false,
PrivateBrowsingUtils.permanentPrivateBrowsing
);
return;
}
if (state === lazy.IPPProxyStates.READY) {
lazy.IPPProxyManager.start(
false,
PrivateBrowsingUtils.permanentPrivateBrowsing
);
return;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this really the right place? Can we get feedback from people working on IPProtection for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've pinged @strseb for some feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The autostart component's job is to "connect once when ready, asap".

So the way i'd read that code is, if autostart is enabled and something changes force-start no matter the current state.
If that always-on is the desired behavior, i'd probably move this into it's own little helper component. And swap out this helper component with the ipp-always-on in IPProtectionActivator.

Otherwise, given the bug-problem text, it sounds like just applying this while active should be sufficient. In that case ProxyManager should observe the serverlist and call switch() while in active.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@strseb I've extracted the logic into a enterprise/IPPAlwaysOn.sys.mjs component that gets loaded in alongside the other helpers in a similar fashion to your IPPEnterpriseAuthProvider PR.

Let me know what you think! If it's the right approach then I can prepare this for upstream

Comment thread toolkit/components/ipprotection/IPPAutoStart.sys.mjs Outdated
Comment thread toolkit/components/ipprotection/IPPChannelFilter.sys.mjs Outdated
Comment thread toolkit/components/ipprotection/IPProtectionServerlist.sys.mjs
Comment thread toolkit/components/ipprotection/IPProtectionServerlist.sys.mjs Outdated
Comment thread toolkit/components/ipprotection/IPProtectionServerlist.sys.mjs Outdated
Comment thread toolkit/components/ipprotection/IPProtectionServerlist.sys.mjs Outdated
Copy link
Copy Markdown
Contributor

@lissyx lissyx left a comment

Choose a reason for hiding this comment

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

LGTM; please verify with a peer of IPProtection for the #handleListChanged implementation if that is the right place.

@jporter-dev jporter-dev force-pushed the enterprise-bug2034845-access-connector-live-policy-modification branch from 0592a3d to e0c6d9c Compare May 6, 2026 15:23
@jporter-dev jporter-dev force-pushed the enterprise-bug2034845-access-connector-live-policy-modification branch 6 times, most recently from 919b96c to 03240f8 Compare May 15, 2026 19:24
@jporter-dev jporter-dev requested a review from strseb May 15, 2026 19:52
@jporter-dev jporter-dev force-pushed the enterprise-bug2034845-access-connector-live-policy-modification branch from 03240f8 to 2ebdb9c Compare May 18, 2026 13:29
Copy link
Copy Markdown
Contributor

@strseb strseb left a comment

Choose a reason for hiding this comment

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

Overall looks great! Just a few comments :)

Comment on lines +29 to +31
IPPAutoRestoreHelper,
...IPPAutoStartHelpers,
...(AppConstants.MOZ_ENTERPRISE ? lazy.IPPAlwaysOnHelpers : []),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wondering whether you actually need the AutoRestore (on session restore starts vpn when it was on) or the IPPAutostartHelpers (for the start on boot pref) on enterprise. Otherwise less objects that can start/stop are preferable :)

... AppConstants.MOZ_ENTERPRISE ? lazy.IPPAlwaysOnHelpers : [IPPAutoRestoreHelper,...IPPAutoStartHelpers ]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I may need to augment IPPAlwaysOn a bit more if removing those to handle the scenarios those handle, but it makes sense to rework it this way to avoid start/stop conflicts. I'll take a look at removing those and making sure IPPAlwaysOn has parity with them

# ignores the pref-based server list set up in add_setup, so hasList stays false
# and proxy activation tests time out.
["test_IPPAlwaysOn.js"]
run-if = ["enterprise"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thats a good point. Maybe we should have a head_enterpise.js for enterprise tests, so add_setup correctly creates the enviroment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call, I'll fix this up properly in the Phab PR.

Comment on lines +243 to +253
/**
* Registers the channel filter at startup to prevent data leaks before the
* proxy connection is fully established in always-on mode. Mirrors
* IPPEarlyStartupFilter from IPPAutoStart but uses the AlwaysOn policy check.
*/
class IPPAlwaysOnEarlyStartupFilter {
#alwaysOnAtStartup = false;

constructor() {
this.handleEvent = this.#handleEvent.bind(this);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wondering, this is pretty much the same as IPPEarlyStartupFilter - only with a diffrent condition.

WDYT if we do

class IPPEarlyStartupFilter{
      constructor( shouldActivate:Function<bool>){...}

     init() {
        if(!this.shouldActivate()) return;
        ...
     }
}


export IPPAutostartFilter = new IPPEarlyStartupFilter(()=>IPPAutoStart.autoStart)
export IPPAlwaysOnEarlyStartupFilter = new IPPEarlyStartupFilter(()=>IPPAlwaysOn.alwaysOnEnabled))

@jporter-dev jporter-dev force-pushed the enterprise-bug2034845-access-connector-live-policy-modification branch from 2ebdb9c to 8d7cfe2 Compare May 21, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch:main PR that should be merged on enterprise-main branch bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants