Skip to content

Conversation

@QuiteDiam0nd
Copy link

@QuiteDiam0nd QuiteDiam0nd commented Sep 27, 2025

Description

This PR adds support for using authentication in forward proxies, using RFC1929 and RFC7235.

How this can be tested?

Used some socks5 & http proxies with authentication.

  • Possibly cover with unit/autotests in future

…roxies

1) Now there are 3 additional cli flags, controlling authentication for forward proxies.
Authentication is realized via RFC1929 and RFC7235.
2) Improve a little bit error handling for HTTP headers
3) Make some types optional for clearness
Copy link
Collaborator

@JonSnowWhite JonSnowWhite left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR, looks good, I only have minor comments

if args.forward_proxy_mode.name == "SOCKSv4" and (username or password):
print("[warn] Credentials are ignored for SOCKS4 forward proxy", file=sys.stderr)

if args.forward_proxy_socks5_auth == 'no_auth' and (username or password):
Copy link
Collaborator

Choose a reason for hiding this comment

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

add a warning for incomplete credentials for HTTPS proxy mode and a warning for a configured SOCKSv5 proxy auth when the mode is HTTPS

Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed I should add sanity checks to the rest of the parameters as well... thanks for the implicit heads up!

Copy link
Author

Choose a reason for hiding this comment

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

@JonSnowWhite I think cli is starting to bloat significantly due to the large number of command flags. Maybe migrate to some sort of config? Probably as part of a separate issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely an option for the future, yes

The proxy type of the forward proxy
--forward_proxy_resolve_address, --no-forward_proxy_resolve_address
Whether to resolve domains before including them in the HTTP CONNECT request to the second proxy (default: False)
--forward_proxy_username FORWARD_PROXY_USERNAME
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add warnings to the Readme, help command, and execution when any kind of authentication is used that passwords are transmitted in cleartext. Users should be aware, but I would still like to provide an explicit hint.

# receive SOCKSv4 OK
answer = server_socket.recv(STANDARD_SOCKET_RECEIVE_SIZE)
if not answer.upper().startswith(Socksv4.socks4_ok()) and len(answer) != 8:
if not answer.startswith(Socksv4.socks4_ok()) or len(answer) != 8:
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add parantheses here

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