Fix firmware detection for AR01.05.063.15_082825_735.PC20.20.VF - #378
Open
schumischumi wants to merge 2 commits into
Open
Fix firmware detection for AR01.05.063.15_082825_735.PC20.20.VF#378schumischumi wants to merge 2 commits into
schumischumi wants to merge 2 commits into
Conversation
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
There was a problem hiding this comment.
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.swVersionand_ga.swVerHTML patterns. - Add GET-based probing of
/index.phpas 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 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix firmware detection for AR01.05.063.15_082825_735.PC20.20.VF
FYI: This code was generated with opencode and Qwen3.5:9b locally and tested manually with my router