Skip to content

Fix firmware detection for AR01.05.063.15_082825_735.PC20.20.VF - #378

Open
schumischumi wants to merge 2 commits into
totev:mainfrom
schumischumi:main
Open

Fix firmware detection for AR01.05.063.15_082825_735.PC20.20.VF#378
schumischumi wants to merge 2 commits into
totev:mainfrom
schumischumi:main

Conversation

@schumischumi

Copy link
Copy Markdown

Fix firmware detection for AR01.05.063.15_082825_735.PC20.20.VF

  • Support both _ga.swVersion and _ga.swVer patterns in html-parser.ts
  • Add fallback to GET requests when HEAD requests fail in discovery.ts
  • Add test case for swVer firmware pattern

FYI: This code was generated with opencode and Qwen3.5:9b locally and tested manually with my router

Fix firmware detection for AR01.05.063.15_082825_735.PC20.20.VF
Fix firmware detection for AR01.05.063.15_082825_735.PC20.20.VF

- Support both _ga.swVersion and _ga.swVer patterns in html-parser.ts
- Add fallback to GET requests when HEAD requests fail in discovery.ts
- Add test case for swVer firmware pattern

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves modem firmware detection for Arris devices reporting firmware via _ga.swVer (in addition to _ga.swVersion) and makes modem discovery more resilient by falling back to GET probing when HEAD probing doesn’t find a reachable modem UI.

Changes:

  • Extend firmware version extraction to support both _ga.swVersion and _ga.swVer HTML patterns.
  • Add GET-based probing of /index.php as a fallback when HEAD probing doesn’t produce a usable result.
  • Add a discovery-level test case intended to cover the swVer firmware pattern.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/modem/tools/html-parser.ts Extend firmware-version regex to match both swVersion and swVer.
src/modem/discovery.ts Add GET fallback probing logic when HEAD probing fails to identify a modem location.
src/modem/discovery.test.ts Add a test case related to the swVer firmware variant during Arris discovery.

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

Comment on lines 7 to +31
@@ -24,7 +24,11 @@ export function extractCryptoVars(html: string): CryptoVars {
}

export function extractFirmwareVersion(html: string): string | undefined {
return swVersionMatcher.exec(html)?.groups?.swVersion
const match = swVersionMatcher.exec(html)
if (!match?.groups?.swVersion && !match?.groups?.swVersion2) {
return undefined
}
return match?.groups?.swVersion || match?.groups?.swVersion2
Comment thread src/modem/discovery.ts
Comment on lines +54 to +67
axios.get(`http://${ip}/index.php`, {
headers: {Accept: 'text/html,application/xhtml+xml,application/xml'},
validateStatus: () => true, // Accept any status code
}),
axios.get(`https://${ip}/index.php`, {
headers: {Accept: 'text/html,application/xhtml+xml,application/xml'},
validateStatus: () => true,
}),
);
}

throw new Error('Could not find a router/modem under the known addresses.');
} catch (error) {
console.error('Could not find a router/modem under the known addresses.');
throw error;
const results = await Promise.allSettled(getRequests);
maybeResult = results.find(result => result.status === 'fulfilled') as undefined | {value: AxiosResponse};
}
Comment on lines +197 to +207
it('should successfully discover Arris modem with swVer pattern', async () => {
const mockArrisResponse = {
data: '<html><script>var _ga = {}; _ga.swVer = "AR01.05.063.15_082825_735.PC20.20.VF";</script></html>',
};

mockedExtractFirmwareVersion.mockReturnValue('AR01.05.063.15_082825_735.PC20.20.VF');

mockedAxios.get = jest.fn()
.mockResolvedValueOnce(mockArrisResponse) // tryArris succeeds
.mockRejectedValueOnce(new Error('Technicolor failed')); // tryTechnicolor fails

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