LeanderBB / you-have-mail

Application to notify you if an email has arrived in your email Account
GNU Affero General Public License v3.0
78 stars 4 forks source link

[Feature Request] SOCKS5 Proxy Support #3

Closed kalekad closed 1 year ago

LeanderBB commented 1 year ago

Hey @kalekad, I need a bit more information about the use case for this feature.

Are you using the Rust crates or the Android application? If the latter, does setting a proxy through the Android settings work for you?

kalekad commented 1 year ago

I need a bit more information about the use case for this feature.

Yes, of course. I have ProtonMail in my Work Profile, which is linked to banking and government applications. All applications access the network through a local VPN to TOR (I use Orbot). I only turn on the Work Profile when I need to do something, like checking emails in ProtonMail.

I have "You Have Mail" in the Main profile, where all apps access the network via a local VPN to the VPN provider. If "You Have Mail" implemented a SOCKS5 Proxy, it could be connected via TOR like ProtonMail in the Work profile and have notifications.

I assume that within a few months ProtonMail will have implemented notifications without the need to send them via Google (Proton Calendar already has them, they don't take any battery and just work). But in the Work Profile, which is almost always off, notifications are useless to me anyway. I don't count that they implemented SOCKS5 Proxy and I could run ProtonMail in the Main profile via TOR. And this is where "You Have Mail" with SOCKS5 Proxy has its place.

Are you using the Rust crates or the Android application? If the latter, does setting a proxy through the Android settings work for you?

Android app

I don't use the system proxy because it has to be set up for each network separately (I'm not sure if it can be set up for mobile data), and applications are not forced to use it and don't indicate if they support it. So I don't know.

LeanderBB commented 1 year ago

Interesting setup, thanks for the suggestion!

I did a quick check on the libraries currently in use and it seems doable to add socks5 support. It may take a bit longer as I didn't consider proxy support in the original architecture :sweat_smile:.

Once I'm finished with my current activity, I'll start working on this next (provided life doesn't get in the way :))

LeanderBB commented 1 year ago

@kalekad I have added Proxy support for HTTPS and SOCKS5 in https://github.com/LeanderBB/you-have-mail/releases/tag/v0.3.0.

Please let me know if this works for you. I tested the connections against some python libraries and as far as I can tell everything seems to work.

However, I have no "real world" SOCKS5 setup with which I can test this. Would be grateful if you could share your feedback :).

kalekad commented 1 year ago

I tried the proxy and it works, thank you so much for implementing it for each account, that's great.

(poll interval 30 s) In a test with two accounts, each connected via a different proxy: -1 Both accounts connected and online. -2 After switching off one proxy, the account connected to it showed offline, after switching on it reconnected. -3 The other account, with the same steps as above, did not reconnect. -4 I forcibly stopped the application and after opening it, the account that did not connect in the previous step now connected fine and the other was logged out.

After the third step I sent an email to both accounts, but in the fourth step there was no notification to the reconnected account. (nor for the logged out account, but it's clear there)

And another time when I set the poll interval to 60 m the notifications didn't arrive even after 10 hours, I guess the connection died?

LeanderBB commented 1 year ago

Happy to hear it's working.

It is hard to say what may be going wrong. I didn't want to spam notifications for disconnected/connected to not get annoyed during network connection loss/switches. I could look into adding an option for that :thinking:

What I did notice is the status in the Account Details screen doesn't update properly at the moment, but the general account list should display the correct status.

Do you think you could share the logs? There maybe some more information there that might help diagnose the problem.

LeanderBB commented 1 year ago

In the logs I can see:

 observer: Account Error: [redacted] => dev.lbeernaert.youhavemail.ServiceException$Unknown: msg=An error occurred preparing the request

Did you happen to get an error notification for this?

I'm not sure what may have caused this, I will try to get a new build out with more information surrounding this error.

Edit: Digging through the source code of the network library it could be related to connection timeouts.

LeanderBB commented 1 year ago

If you update to v0.3.1 we should have more details about why the request is failing.

LeanderBB commented 1 year ago

Can you give me the logs for this run?

-------- Original Message -------- On Mar 24, 2023, 11:19, kalekad < @.> wrote: After updating to 0.3.1 I got this.  — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "[https://github.com](<a href=)/LeanderBB/you-have-mail/issues/3#issuecomment-1482566637">https://github.com/LeanderBB/you-have-mail/issues/3#issuecomment-1482566637", "url": "[https://github.com](<a href=)/LeanderBB/you-have-mail/issues/3#issuecomment-1482566637">https://github.com/LeanderBB/you-have-mail/issues/3#issuecomment-1482566637", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

LeanderBB commented 1 year ago

Ok. I will need to spend some time to dig deeper into this, but it seems that is related to a network transmission issue such as the connection being lost halfway through the transmission of data.

I will close this issue as the feature itself is complete. I will open a new issue to track improvements for the network transmission.

LeanderBB commented 1 year ago

You can follow the progress with #4