bepass-org / oblivion

Unofficial warp client for android
2.97k stars 420 forks source link

Fix premature psiphon CONNECTED state #65

Closed ameerhossein closed 3 months ago

ameerhossein commented 3 months ago

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.

markpash commented 3 months ago

@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 commented 3 months ago

@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 commented 3 months ago

@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 commented 3 months ago

Give me a minute

markpash commented 3 months ago

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 commented 3 months ago

@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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 :thinking: