veez21/mod-util

Connection test unfriendly to chinese users.

Closed this issue · 25 comments

test_connection() { (ping -q -c 1 -W 1 google.com >/dev/null 2>&1 & e_spinner "Testing internet connection") && echo " - OK" || { echo " - Error"; false; } }
Google can't access in CN.Some VPN,especially Shadowsocks,do not handle ping requests,so the test will always fail for CN users.

https://github.com/Magisk-Modules-Repo/ccbins/issues/1

Submitted pull request with fix #6

@eebssk1 pull request merged and incorporated into ccbins so you can close this :)

@Zackptg5
When shadowsocks is active,ping always goes through it's vitual interface because it's default.Which makes test still fail.Ther's no time for users to disconnect SS when magisk flashing the zip.So try to iterate through real interface like rmnet_data* and wlan* ,or add a warnning and delay so people have time to disconnect SS.

@eebssk1 Do all android devices have a wlan* interface? My p4a has 4 different rmnet_data interfaces butn only wlan0 so wlan seems like the more straightforward option

@eebssk1 Do all android devices have a wlan* interface? My p4a has 4 different rmnet_data interfaces butn only wlan0 so wlan seems like the more straightforward option

Well..I think wlan is must-have since it's available on all(maybe) phones and developing boards.

Actually it's more suiltable to use curl for checking,but i think it may not available on all rom and intergrate such binary may make the utilily fat?

@eebssk1 Do all android devices have a wlan* interface? My p4a has 4 different rmnet_data interfaces butn only wlan0 so wlan seems like the more straightforward option

Well..I think wlan is must-have since it's available on all(maybe) phones and developing boards.

Actually it's more suiltable to use curl for checking,but i think it may not available on all rom and intergrate such binary may make the utilily fat?

Can't speak for @veez21 with the template itself but I already have curl for my ccbins mod - which commands specifically would you want curl for in this usage case?

@eebssk1 Do all android devices have a wlan* interface? My p4a has 4 different rmnet_data interfaces butn only wlan0 so wlan seems like the more straightforward option

Well..I think wlan is must-have since it's available on all(maybe) phones and developing boards.
Actually it's more suiltable to use curl for checking,but i think it may not available on all rom and intergrate such binary may make the utilily fat?

Can't speak for @veez21 with the template itself but I already have curl for my ccbins mod - which commands specifically would you want curl for in this usage case?

like this...

curl -Is --connect-timeout 4 connect.rom.miui.com/generate_204 |grep -Fq 204
if [ $? != 0 ]
then
echo something wrong with network
exit
fi

@eebssk1 Do all android devices have a wlan* interface? My p4a has 4 different rmnet_data interfaces butn only wlan0 so wlan seems like the more straightforward option

Well..I think wlan is must-have since it's available on all(maybe) phones and developing boards.
Actually it's more suiltable to use curl for checking,but i think it may not available on all rom and intergrate such binary may make the utilily fat?

Can't speak for @veez21 with the template itself but I already have curl for my ccbins mod - which commands specifically would you want curl for in this usage case?

like this...

curl -Is --connect-timeout 4 connect.rom.miui.com/generate_204 |grep -Fq 204
if [ $? != 0 ]
then
echo something wrong with network
exit
fi

Ok, I can replace ping with that. I'll probably stick with google and baidu and check for 200 though

This is actually what I was looking for to replace wget --spider too. I can do everything with curl now :)

test_connection() {
  (
  if curl -Is --connect-timeout 3 https://www.google.com | grep -q 'HTTP/.* 200'; then
    true
  elif curl -Is --connect-timeout 3 https://www.baidu.com | grep -q 'HTTP/.* 200'; then
    true
  else
    false
  fi & e_spinner "Testing internet connection"
  ) && echo " - OK" || { echo " - Error"; false; }
}

How does this work for you?

@eebssk1 Do all android devices have a wlan* interface? My p4a has 4 different rmnet_data interfaces butn only wlan0 so wlan seems like the more straightforward option

Well..I think wlan is must-have since it's available on all(maybe) phones and developing boards.
Actually it's more suiltable to use curl for checking,but i think it may not available on all rom and intergrate such binary may make the utilily fat?

Can't speak for @veez21 with the template itself but I already have curl for my ccbins mod - which commands specifically would you want curl for in this usage case?

like this...

curl -Is --connect-timeout 4 connect.rom.miui.com/generate_204 |grep -Fq 204
if [ $? != 0 ]
then
echo something wrong with network
exit
fi

Ok, I can replace ping with that. I'll probably stick with google and baidu and check for 200 though

This is actually what I was looking for to replace wget --spider too. I can do everything with curl now :)

test_connection() {
  (
  if curl -Is --connect-timeout 3 https://www.google.com | grep -q 'HTTP/.* 200'; then
    true
  elif curl -Is --connect-timeout 3 https://www.baidu.com | grep -q 'HTTP/.* 200'; then
    true
  else
    false
  fi & e_spinner "Testing internet connection"
  ) && echo " - OK" || { echo " - Error"; false; }
}

How does this work for you?

@eebssk1 Do all android devices have a wlan* interface? My p4a has 4 different rmnet_data interfaces butn only wlan0 so wlan seems like the more straightforward option

Well..I think wlan is must-have since it's available on all(maybe) phones and developing boards.
Actually it's more suiltable to use curl for checking,but i think it may not available on all rom and intergrate such binary may make the utilily fat?

Can't speak for @veez21 with the template itself but I already have curl for my ccbins mod - which commands specifically would you want curl for in this usage case?

like this...

curl -Is --connect-timeout 4 connect.rom.miui.com/generate_204 |grep -Fq 204
if [ $? != 0 ]
then
echo something wrong with network
exit
fi

Ok, I can replace ping with that. I'll probably stick with google and baidu and check for 200 though

This is actually what I was looking for to replace wget --spider too. I can do everything with curl now :)

test_connection() {
  (
  if curl -Is --connect-timeout 3 https://www.google.com | grep -q 'HTTP/.* 200'; then
    true
  elif curl -Is --connect-timeout 3 https://www.baidu.com | grep -q 'HTTP/.* 200'; then
    true
  else
    false
  fi & e_spinner "Testing internet connection"
  ) && echo " - OK" || { echo " - Error"; false; }
}

How does this work for you?

I replaced e_spinner with echo for testing because i'm too lazy to import utility.
I always get OK in this way,after i move the echo(e_spinner) before the if ,it then works correctly.I think you should move spinner before if just in case(just too lazy to see the code haha).

Just got enough time to test your script.Yeah it always return OK.However e_spiner not supposed to be invoked first,so i think we should try something else?

Just got enough time to test your script.Yeah it always return OK.However e_spiner not supposed to be invoked first,so i think we should try something else?

Confirmed, I'll have to rework that

Edit: Fixed in test branch. Still working on some other stuff before next stable release

Looks like ccbins works for me now.

"Terminal Modifications not module detected!'" this sentence looks weired for me ..

Another unsolveble problem is china mobile network return back fake poisoned ip addr for github content link which make further step fail and shadowsocks won't handle this if not in full proxy mode. I think you won't care about this though haha.

Anyway thanks for the changes.

@Zackptg5
Should we close this issue ?

I'd keep it open since @veez21 hasn't decided what to do yet on the template side of things. I'm still tweaking it myself
I'll look into dns poisoning but probably won't do anything about it on my end

@eebssk1
I might be able to fix the dns poisoning issue actually. My curl binary has support for doh so I may be able to run everything through cloudflare doh as a workaround, similar to what magisk manager does now

Can you try this in terminal with my curl binary?

curl -LI --connect-timeout 3 --doh-url https://cloudflare-dns.com/dns-query https://github.com

@eebssk1
I might be able to fix the dns poisoning issue actually. My curl binary has support for doh so I may be able to run everything through cloudflare doh as a workaround, similar to what magisk manager does now

Can you try this in terminal with my curl binary?

curl -LI --connect-timeout 3 --doh-url https://cloudflare-dns.com/dns-query https://github.com

Yes it works.However it looks like CF dns is not stable in CN case I often got resolv timeout and need to try many times.

Raise connect timeout to 7 both works for github.com and raw.githubusercontent.com in most case.

Yikes, that's still a long time. After I posted this, I remembered reading about China pushing to block TLS 1.3 and esni traffic altogether. Does doh like this work with/without shadowsocks?

Yikes, that's still a long time. After I posted this, I remembered reading about China pushing to block TLS 1.3 and esni traffic altogether. Does doh like this work with/without shadowsocks?

Looks like DoH request won't go through shadowsocks if not in full proxy mode.Once hostname is resolved the download handle by shadowsocks normally.So this is weired why shadowsocks don't care about DoH.Maybe because 1.1.1.1 is not included in SS's proxy db.

Doesn't sound like this will fix the issues. Magisk manager now uses jsdelivr cdn apparently, not just cloudflare doh. I can't use a cdn like that from just a shell script so don't think I'll be able to do anything about this on my end

Doesn't sound like this will fix the issues. Magisk manager now uses jsdelivr cdn apparently, not just cloudflare doh. I can't use a cdn like that from just a shell script so don't think I'll be able to do anything about this on my end

Well anyways just keep the doh things for us.These actually won't be a big problem for us,just a little troubles.

Dns poisoning only happens with a specific list of sites right? I've been debating moving ccbins over to my website rather than using github (I'll still keep latest binaries on there for people who want to download them independently of the ccbins mod).
Think that'll solve the problem?

Dns poisoning only happens with a specific list of sites right? I've been debating moving ccbins over to my website rather than using github (I'll still keep latest binaries on there for people who want to download them independently of the ccbins mod).
Think that'll solve the problem?

Yes this is a way too.I also have free VPS that maybe can be a reverse-proxy.By the way,I just write a APP to auto reset the DNS for mobile network,however the custom dns only works for binary,APP's dns request is still handled by ISP,Which makes me feel unworthy.

Probably best to move this over to ccbins so this can be closed

test_connection() { (ping -q -c 1 -W 1 google.com >/dev/null 2>&1 & e_spinner "Testing internet connection") && echo " - OK" || { echo " - Error"; false; } }
Google can't access in CN.Some VPN,especially Shadowsocks,do not handle ping requests,so the test will always fail for CN users.

Magisk-Modules-Repo/ccbins#1

Closed due to inactivity (historitic issues cleanup).

//No attention on this issue