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

Fix premature psiphon CONNECTED state #65

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

ameerhossein
Copy link
Contributor

When using Psiphon mode, the local port (default 8086) is opened before psiphon is actually connected. This confuses OblivionVpnService into thinking the connection is made, publishing invalid CONNECTED state too early. This PR implements a method to wait for psiphon to completely connect, then publish CONNECTED state.

@ameerhossein ameerhossein changed the title Fix premature psiphon CONNECTED state fix Fix premature psiphon CONNECTED state Feb 22, 2024
@markpash markpash merged commit 6e6c129 into bepass-org:main Feb 22, 2024
@markpash
Copy link
Member

@ameerhossein Can you test the current main branch to see if you experience any issues? There are many complains that this feature is no longer working. Personally I'm also unable to connect when Psiphon mode is enabled.

@ameerhossein
Copy link
Contributor Author

ameerhossein commented Feb 23, 2024

@markpash I tested the v1 release and it connects like usual. Actually I did not touch the way it tries to connect. I just modified the way it presents the connection state. So can you please try some steps to investigate the issue?

Screenshot_20240223_115843_Oblivion.jpg

Can you confirm you reach this log on v1 logs and it still says CONNECTING?

IMG_20240223_120223_439.jpg

If it reaches this log and still says CONNECTING, please try and check if you actually can access any website now or no? It might log psiphon started but if its connected without being able to access internet, its not really useful and it makes sense to not show the CONNECTED state.

If you can confirm it reaches the psiphon started log and its able to access the internet, then it's a problem caused by this PR and we need to investigate further.

If it does not reach the psiphon started log, please try the previous version. Was it reaching this log on old versions? Can you confirm it was not a false positive and is able to access the internet?

Because this PR eliminates false positives, We need to make sure previous CONNECTED states in old version were true and not just connected but unable to access the internet.

Thanks.

@markpash
Copy link
Member

@ameerhossein I'm unable to test this at the moment. Maybe @DanielcoderX can help and try to recreate the issue and post the logs?

@DanielcoderX
Copy link
Collaborator

Give me a minute

@markpash
Copy link
Member

I did a test in an android emulator in the (Android 14 image) and everything works perfectly. But on my personal phone running Android 13, the Psiphon mode doesn't work. This is just an anecdote. BTW I'm the UK so there's no filtering or strange networking happening.

@DanielcoderX
Copy link
Collaborator

@ameerhossein
based on some signs, I've found that the issue is related to the commits after #57 commit.
These commits look suspicious: 92a9c74 - a6a3311 - 6e6c129
I'll be glad if you help and fix it.

@ameerhossein
Copy link
Contributor Author

ameerhossein commented Feb 23, 2024

92a9c74 just decouples the same code from each activity so its effectively the same.

6e6c129 just avoids multiple calls for the same state. This has nothing to do with state changes.

a6a3311 This could be the issue but I can't reproduce it. First I need to know the problem is occuring on which level. Is psiphon started but the state is not being updated? I need someone with this problem help me identify the cause.

@DanielcoderX did you have this problem too? Did you check the logs?

Btw we released v1 too early. Android apps need more testing due to their nature (strange behaviors across different OEMs)

@DanielcoderX
Copy link
Collaborator

The problem is that the app works well on the emulator but not on a Real device, LOL
yes I have the same. before version 1 it was ok.
I've checked the logs and it sometimes shows that Psiphon is also connected.
I think it's related to the GO lib.

yeah, that was too soon for releasing version 1 but unfortunately, users community was embarsed by the slow development due to political, social, and security reasons and we needed some sedative ASAP.

@markpash
Copy link
Member

markpash commented Feb 23, 2024

I just took a quick look at the code. Could this be the problem?

I was playing with the app in an emulator with api version 31. I tried normal mode and psiphon and they worked fine. Then I tried gool and it didn't work until a couple of reconnects and waiting. Perhaps the bug exists for gool mode?

@DanielcoderX
Copy link
Collaborator

I just took a quick look at the code. Could this be the problem?

I was playing with the app in an emulator with api version 31. I tried normal mode and psiphon and they worked fine. Then I tried gool and it didn't work until a couple of reconnects and waiting. Perhaps the bug exists for gool mode?

In the exact moment, I'm using Psiphon mode and it's working very well with high speed connection :/ everything works as expected.
Looks like it's based on luckiness, LoL

@ameerhossein
Copy link
Contributor Author

I just took a quick look at the code. Could this be the problem?

That just keeps pinging 1.1.1.1 until the first successful request which means you now have access to the internet. because you don't have access to internet while psiphon is trying to connect through warp. so just checking the local port is not enough to present the connected state. This behavior is for psiphon mode only so normal or gool mode is still the same as previous version.

I was playing with the app in an emulator with api version 31. I tried normal mode and psiphon and they worked fine. Then I tried gool and it didn't work until a couple of reconnects and waiting. Perhaps the bug exists for gool mode?

I guess this has something to do with Cloudflare ip scanner of Go lib. You connect to warp through different IPs each time you try to connect. If you clear the endpoint option in settings, it shouldn't run the scanner so it worth trying it. It seems it only runs the IP scanner on each connection attempt if the value of that option equals "engage.cloudflare.com:2408"

I don't think the problem is pinging. even if we don't ping to ensure connection, the connected state is just fake and you'd be unable to access the internet. I'm suspicious to the built-in IP scanner because @DanielcoderX says the behavior is random. That's the only thing that changes on every reconnect.

@ameerhossein
Copy link
Contributor Author

The problem is that the app works well on the emulator but not on a Real device, LOL

Are they using the same network? I switched to Irancell and none of the methods connects. the normal mode says connected but it has no access to the internet (false-positive because the ping is only on psiphon mode.)
Psiphon mode does not connect because it pings to check if there is proper internet connection access or no.
After many tries it actually had access to the internet (both normal mode and psiphon)
However everything works smoothly on the home network so I'm 80% sure there's a problem with IP scanning 🤔

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