Skip to content

Conversation

@reporter29
Copy link

@reporter29 reporter29 commented Nov 12, 2025

This request addresses request #184 that I raised to supporting additional proxy formats. I tested my changes using my own proxy. The cases I tested are:

  1. proxy.host.com
  2. proxy.host.com:1234
  3. user_12345,type_residential,session_123:pass@proxy.host.com:1080
  4. proxy.host.com:1080:user_12345,type_residential,session_123:pass
  5. proxy.host.com:1080@user_12345,type_residential,session_123:pass
  6. user_12345,type_residential,session_123:pass:proxy.host.com:1080
  7. user_12345,type_residential,session_123:pass:proxy.host.com:1080:extra (invalid)
  8. user_12345,type_residential,session_123:pass:https://proxy.host.com:1080 (invalid)

Proxies in the format of 4-6 get saved to the rulesStore as format 3. Note that the username contains , and _.

@CLAassistant
Copy link

CLAassistant commented Nov 12, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@pimterry pimterry left a comment

Choose a reason for hiding this comment

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

Thanks for this! I wasn't aware of those proxy URL formats before but it makes sense, I'm happy to support that. I think there's a few tweaks we should make here but in general it looks like a good approach imo, thanks for taking the time to dig into this! 👍

// Translates the proxy host input into standard form if needed
const normalizeProxyHost = (host: string): string => {
const idx = PROXY_HOST_REGEXES.findIndex(regex => regex.test(host));
if (idx === -1) return host; // Should not occur
Copy link
Member

Choose a reason for hiding this comment

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

Given that it shouldn't happen, let's throw an error instead.

Copy link
Author

@reporter29 reporter29 Nov 14, 2025

Choose a reason for hiding this comment

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

Addressed in #186

default: // Does not include auth or already in standard format
return host;
}
};
Copy link
Member

Choose a reason for hiding this comment

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

I think we should test this, and probably pull it out of the pure UI code too. Can you please:

  • Move all this proxy logic into the model, e.g. src/model/http/proxy.ts. I think validateProxyHost should stay here (it's linked to the UI input logic) but the rest should be imported.
  • Create a unit test in test/unit/model/http/proxy.spec.ts that covers each of these different URL format cases, and a few invalid examples.

Copy link
Author

Choose a reason for hiding this comment

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

Addressed in #186.

// 3) host:port:user:pass
new RegExp(`^(${HOST_PATTERN}):(${PORT_PATTERN}):(${CRED_PATTERN}):(${CRED_PATTERN})$`),
// 4) user:pass:host:port
new RegExp(`^(${CRED_PATTERN}):(${CRED_PATTERN}):(${HOST_PATTERN}):(${PORT_PATTERN})$`),
Copy link
Member

Choose a reason for hiding this comment

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

Apparently user@host:port also exists (implicitly empty password) and isn't that rare. I'm pretty sure that works now so it would be good not to break it.

Technically user:@..., :password@... and even :@... are valid as well but I think we can probably ignore those as too weird to appear in practice, and just wait & see if anybody complains.

Copy link
Author

Choose a reason for hiding this comment

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

Updated the logic in #186 to support this. I also ended up allowing an optional port user:pass@host (and user@host) as the previous regex allowed this.

@reporter29
Copy link
Author

Ran into some rebasing issues, created a new CR: #186

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.

3 participants