Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add username/password SOCKS5 auth #1683

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nurupo
Copy link
Member

@nurupo nurupo commented Feb 13, 2021

Fixes #1682

Not tested. Can someone with a SOCKS5 proxy with username/password test this?

I'm not sure how to prevent APIDSL from generating tox_options_set_proxy_socks5_username_length() and tox_options_set_proxy_socks5_password_length() function declarations. Those seem pointless as the user already sets the length in tox_options_set_proxy_socks5_username() and tox_options_set_proxy_socks5_password(). Savedata has the same issue with a pointless tox_options_set_savedata_length().


This change is Reviewable

@nurupo nurupo added enhancement New feature for the user, not a new feature for build script help wanted Extra attention is needed network Network labels Feb 13, 2021
@nurupo
Copy link
Member Author

nurupo commented Feb 13, 2021

@cryptogospod
Copy link

@nurupo Does this still need testing? I'm willing to test it.

@nurupo
Copy link
Member Author

nurupo commented Sep 20, 2021

Yep, so far no one has tested it as far as I'm aware.

@nurupo nurupo force-pushed the socks5-username-password-auth branch from 1f15b48 to b5f2735 Compare September 20, 2021 07:31
@nurupo nurupo force-pushed the socks5-username-password-auth branch 3 times, most recently from abbf3db to bbb3a45 Compare September 20, 2021 07:48
@nurupo
Copy link
Member Author

nurupo commented Sep 20, 2021

Fixed a couple of issues I have noticed after reviewing with a fresh set of eyes.

@cryptogospod
Copy link

I managed to verify that SOCKS5 authenticated connections work. Currently I've only tested with toxic, but I will test qTox as soon as possible and post another update here.

@cryptogospod
Copy link

cryptogospod commented Sep 21, 2021

Update: I managed to verify that SOCKS5 authenticated connections work in qTox too. When using correct credentials, the client connects to a TCP relay and all traffic goes through it. In the case of incorrect credentials or lack of credentials, qTox fails to connect. In all cases, I noticed this in the log: net/updatecheck.cpp:137 : Warning: Failed to check for update: QNetworkReply::ProxyAuthenticationRequiredError.

EDIT (comment from IRC):
anthonybilinski: re: that log, qTox will need to update our http version check to use the same user/pass. unrelated to toxcore

@nurupo
Copy link
Member Author

nurupo commented Sep 24, 2021

Cool, thanks for testing.

In all cases, I noticed this in the log: net/updatecheck.cpp:137 : Warning: Failed to check for update: QNetworkReply::ProxyAuthenticationRequiredError

This is a qTox-specific thing, it says nothing about toxcore or this PR working or non-working.

Would be great if someone else could test this too, I'm not too sure if @cryptogospod tested it correctly. The way it should have been tested, that QNetworkReply::ProxyAuthenticationRequiredError shouldn't have triggered.

Since @cryptogospod has asked this on IRC, I want to point it out here too: for this to be merged, there are a few more steps that need to be done:

  • I would like someone else to test it
  • APIDSL needs to be fixed so that it doesn't generate tox_options_set_proxy_socks5_username_length() and tox_options_set_proxy_socks5_password_length() functions
  • Someone has to review and approve this PR

@anthonybilinski
Copy link

@nurupo I walked through testing with qTox with @cryptogospod at the time, the diff was adding the calls to the new API here: https://github.com/qTox/qTox/blob/da5c165f4116dce736def63b1b917523b848db09/src/core/toxoptions.cpp#L133.

The QNetworkReply::ProxyAuthenticationRequiredError was triggered from https://github.com/qTox/qTox/blob/da5c165f4116dce736def63b1b917523b848db09/src/net/updatecheck.cpp#L137 when qTox tries to check its release version over https, because it's loading its proxy info from settings, but not the proxy password which was just hacked in to toxoptions.

Agreed that the error doesn't say anything about toxcore, but I do think that @cryptogospod's testing showing that toxcore either connects or doesn't connect when using the proxy with the correct or incorrect password shows password support's working.

@nurupo
Copy link
Member Author

nurupo commented Oct 18, 2021

Ok, makes sense and also explains why QNetworkReply::ProxyAuthenticationRequiredError was triggered when I didn't expect it to. I had a different diff in mind for the purpose of testing - hardcode to have toxcore always connect to a proxy, i.e. it would do so even with the proxy in qTox settings turned off, which why I was surprised to see that error.

That's a valid way to test it too, so it sounds like it was tested correctly.

@iphydf iphydf added this to the v0.2.x milestone Feb 4, 2022
@iphydf iphydf added P3 Low priority and removed P3 Low priority labels Feb 5, 2022
@iphydf iphydf modified the milestones: v0.2.x, v0.2.17 Feb 6, 2022
@iphydf iphydf modified the milestones: v0.2.17, v0.2.18, v0.2.19 Feb 24, 2022
@iphydf iphydf modified the milestones: v0.2.19, v0.2.20 Apr 18, 2022
@emdee-is
Copy link

emdee-is commented Feb 4, 2024

@nurupo what's the state of this? Can it be merged?

Mentioned in:
#1682 (comment)

@nurupo nurupo force-pushed the socks5-username-password-auth branch from 4213205 to f6e42c9 Compare February 13, 2024 12:50
@nurupo
Copy link
Member Author

nurupo commented Feb 14, 2024

Regarding #1683 (comment), after a discussion with @iphydf on IRC it was decided to keep the username and password setter functions separate, as a single setter function setting both would be bad for binding generation. (An alternative could have been an opaque username-password-socks5-auth struct with a separate constructior/destructor/setter/getter functions, which we would set on Tox_Options, but it seemed a bit excessive).

@iphydf iphydf modified the milestones: v0.2.20, v0.2.21 Nov 6, 2024
@iphydf iphydf modified the milestones: v0.2.21, v0.2.x Nov 27, 2024
@Green-Sky
Copy link
Member

@nurupo can you rebase this pr?

@nurupo nurupo force-pushed the socks5-username-password-auth branch from f6e42c9 to 3a40adf Compare February 4, 2025 21:29
@nurupo nurupo modified the milestones: v0.2.x, v0.2.21 Feb 4, 2025
@nurupo nurupo force-pushed the socks5-username-password-auth branch from 3a40adf to e4203a3 Compare February 4, 2025 21:35
@nurupo
Copy link
Member Author

nurupo commented Feb 4, 2025

@Green-Sky done

@TokTok TokTok deleted a comment from CLAassistant Feb 4, 2025
* @brief Owned pointer to the SOCKS5 proxy username.
* @private
*/
uint8_t *owned_proxy_socks5_username;
Copy link
Member

Choose a reason for hiding this comment

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

We're introducing new data members here. Do we need them to not be owned by default as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would make the API inconsistent - some things are not owned and require a flag to be set, but others are owned.

Copy link
Member

Choose a reason for hiding this comment

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

Does it functionally matter? If clients think it's not owned, they will save their pointers. If they enable the flag or happen to know that it is owned, they don't. It's making things more complicated, and 0.3.0 will get rid of this un-owned mode entirely.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe I got this addressed now.

Per the IRC discussion:

<iphy> Maybe name the fields internal_do_not_set_directly_proxy_socks5_username etc
<iphy> No new code should be setting those fields, and we shouldn't build complexity to cover for that case

@pull-request-attention pull-request-attention bot assigned iphydf and nurupo and unassigned nurupo and iphydf Feb 5, 2025
@nurupo nurupo force-pushed the socks5-username-password-auth branch 5 times, most recently from 169bd2f to bd81c1f Compare February 10, 2025 02:34
@pull-request-attention pull-request-attention bot assigned iphydf and unassigned nurupo Feb 10, 2025
@nurupo nurupo force-pushed the socks5-username-password-auth branch from bd81c1f to c3f5aa8 Compare February 10, 2025 02:54
@nurupo nurupo force-pushed the socks5-username-password-auth branch from c3f5aa8 to 083bfd4 Compare February 10, 2025 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature for the user, not a new feature for build script help wanted Extra attention is needed network Network
Development

Successfully merging this pull request may close these issues.

Feature request: authentication support for proxies
7 participants