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

Bug - failed to start and crashed #146

Open
xxjoe2 opened this issue Apr 4, 2023 · 18 comments
Open

Bug - failed to start and crashed #146

xxjoe2 opened this issue Apr 4, 2023 · 18 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@xxjoe2
Copy link

xxjoe2 commented Apr 4, 2023

hi

installed powertunnel v2.6.3 on my phone but it failed to start
powertunnel

after readling the log, the possible cause could be:
I/o*.l*.p*.i*.ProxyUtils(9429): Could not lookup localhost

so far i have tried:

  1. since my phone dont have /etc/hosts, so i added it
  • dig resolved localhost successfully but powertunnel failed to start with same error
  1. added hosts-cache.txt according to the sources
  • log showed I/HostsPlugin(7772): Loaded 1 hosts, no luck
  1. added a url to fetch a default hosts file, failed too
  • from log:
    I/HostsPlugin(9429): Loaded 2 hosts
    I/LittleProxyServer(9429): Starting LittleProxy Server...
    I/PlatformDependent(9429): Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
    D/EnterpriseController(4412): netId is 0
    E/Netd(4412): getNetworkForDns: getNetId from enterpriseCtrl is netid 0
    D/DnsProxyListener(4412): DNSDBG::dns addrinfo af 2 - 10330
    I/o*.l*.p*.i*.ProxyUtils(9429): Could not lookup localhost

full exceptions:
E/TunnelingVpnService(7772): Failed to establish VPN Service: Cannot set address
E/TunnelingVpnService(7772): java.lang.IllegalStateException: Cannot set address
E/TunnelingVpnService(7772): at android.os.Parcel.createException(Parcel.java:2096)
E/TunnelingVpnService(7772): at android.os.Parcel.readException(Parcel.java:2056)
E/TunnelingVpnService(7772): at android.os.Parcel.readException(Parcel.java:2004)
E/TunnelingVpnService(7772): at android.net.IConnectivityManager$Stub$Proxy.establishVpn(IConnectivityManager.java:4048)
E/TunnelingVpnService(7772): at android.net.VpnService$Builder.establish(VpnService.java:1133)
E/TunnelingVpnService(7772): at io.github.krlvm.powertunnel.android.services.TunnelingVpnService.connect(TunnelingVpnService.java:155)
E/TunnelingVpnService(7772): at io.github.krlvm.powertunnel.android.services.TunnelingVpnService.lambda$onStartCommand$0$io-github-krlvm-powertunnel-android-services-TunnelingVpnService(TunnelingVpnService.java:105)
E/TunnelingVpnService(7772): at io.github.krlvm.powertunnel.android.services.TunnelingVpnService$$ExternalSyntheticLambda0.accept(Unknown Source:4)
E/TunnelingVpnService(7772): at io.github.krlvm.powertunnel.android.managers.ProxyManager.lambda$start$0$io-github-krlvm-powertunnel-android-managers-ProxyManager(ProxyManager.java:128)
E/TunnelingVpnService(7772): at io.github.krlvm.powertunnel.android.managers.ProxyManager$$ExternalSyntheticLambda0.run(Unknown Source:2)
E/TunnelingVpnService(7772): at java.lang.Thread.run(Thread.java:919)
E/TunnelingVpnService(7772): Caused by: android.os.RemoteException: Remote stack trace:
E/TunnelingVpnService(7772): at com.android.server.connectivity.Vpn.jniSetAddresses(Native Method)
E/TunnelingVpnService(7772): at com.android.server.connectivity.Vpn.establish(Vpn.java:1303)
E/TunnelingVpnService(7772): at com.android.server.ConnectivityService.establishVpn(ConnectivityService.java:5644)
E/TunnelingVpnService(7772): at android.net.IConnectivityManager$Stub.onTransact(IConnectivityManager.java:1730)
E/TunnelingVpnService(7772): at android.os.Binder.execTransactInternal(Binder.java:1056)
W/TunnelingVpnService(7772): VPN Service is still not established, stopping...
I/ProxyManager(7772): Stopping server...
I/LittleProxyServer(7772): Stopping LittleProxy Server...
I/DefaultHttpProxyServer(7772): Shutting down proxy server gracefully
I/DefaultHttpProxyServer(7772): Closing all channels (graceful)
I/o*.l*.p*.i*.ServerGroup(7772): Shutting down server group event loops (graceful)

note: i have not enabled any plugin yet, and i have tried v1.9.1 as suggested
mine is running android 10 and other vpns like orbot can be started without problem

any idea?

thanks

@krlvm
Copy link
Owner

krlvm commented Apr 4, 2023

I think you've set your proxy server address as local server address, that's why it can't bind to it.

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 4, 2023

I think you've set your proxy server address as local server address, that's why it can't bind to it.

yes i have a proxy server running. but how come? they are in the same address but with different ports

i have proxy and dns server running on the phone
so i created an alias 10.255.255.1 and set the proxy to listen to this ip. however, powertunnel still failed to start
then, i have stopped those servers and pointing to another upstream proxy server, didnt work. tried to start without upstream proxy, still no luck

any idea to solve this?

@krlvm
Copy link
Owner

krlvm commented Apr 4, 2023

I mean that PowerTunnel also runs a proxy server locally on your device (port 8085 by default), and you changed its IP address from local (0.0.0.0, 127.0.0.1 or any other accessible interface) so something else, where the proxy can't bind port.

You can try clearing the application data.

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 5, 2023

I mean that PowerTunnel also runs a proxy server locally on your device (port 8085 by default), and you changed its IP address from local (0.0.0.0, 127.0.0.1 or any other accessible interface) so something else, where the proxy can't bind port.

You can try clearing the application data.

i have tried to set powertunnel to listen on 192.168 10.1 but it still didint start

and it should not cause any problem even they are listening to the same ip (different ports). i installed powertunnel on another non-root device with orbot installed and both of them are listening to 127.0.0.1 without problem

it's weird

been uninstalled and reinstalled a few times, so not caching or data problem

@krlvm
Copy link
Owner

krlvm commented Apr 5, 2023

Are you using a custom ROM?

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 5, 2023

yes, rooted
samsung, android Q

@krlvm
Copy link
Owner

krlvm commented Apr 5, 2023

Seems like an issue with ROM, and the logs don't shed enough light on this, I can hardly do anything about it

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 5, 2023

that was an excerpt which contains critial logs

here you are the full log, after successfully resolved localhost
https://paste.c-net.org/ParishPuppet

@krlvm
Copy link
Owner

krlvm commented Apr 5, 2023

The error is, in fact, on the system side.

15388 27727 I TunnelingVpnService: Establishing VPN Service...
15388 27727 E TunnelingVpnService: Failed to establish VPN Service: Cannot set address
15388 27727 E TunnelingVpnService: java.lang.IllegalStateException: Cannot set address
15388 27727 E TunnelingVpnService: 	at android.os.Parcel.createException(Parcel.java:2096)
15388 27727 E TunnelingVpnService: 	at android.os.Parcel.readException(Parcel.java:2056)
15388 27727 E TunnelingVpnService: 	at android.os.Parcel.readException(Parcel.java:2004)
15388 27727 E TunnelingVpnService: 	at android.net.IConnectivityManager$Stub$Proxy.establishVpn(IConnectivityManager.java:4048)
15388 27727 E TunnelingVpnService: 	at android.net.VpnService$Builder.establish(VpnService.java:1133)
15388 27727 E TunnelingVpnService: 	at io.github.krlvm.powertunnel.android.services.TunnelingVpnService.connect(TunnelingVpnService.java:155)
15388 27727 E TunnelingVpnService: 	at io.github.krlvm.powertunnel.android.services.TunnelingVpnService.lambda$onStartCommand$0$io-github-krlvm-powertunnel-android-services-TunnelingVpnService(TunnelingVpnService.java:105)
15388 27727 E TunnelingVpnService: 	at io.github.krlvm.powertunnel.android.services.TunnelingVpnService$$ExternalSyntheticLambda0.accept(Unknown Source:4)
15388 27727 E TunnelingVpnService: 	at io.github.krlvm.powertunnel.android.managers.ProxyManager.lambda$start$0$io-github-krlvm-powertunnel-android-managers-ProxyManager(ProxyManager.java:128)
15388 27727 E TunnelingVpnService: 	at io.github.krlvm.powertunnel.android.managers.ProxyManager$$ExternalSyntheticLambda0.run(Unknown Source:2)
15388 27727 E TunnelingVpnService: 	at java.lang.Thread.run(Thread.java:919)
15388 27727 E TunnelingVpnService: Caused by: android.os.RemoteException: Remote stack trace:
15388 27727 E TunnelingVpnService: 	at com.android.server.connectivity.Vpn.jniSetAddresses(Native Method)
15388 27727 E TunnelingVpnService: 	at com.android.server.connectivity.Vpn.establish(Vpn.java:1303)
15388 27727 E TunnelingVpnService: 	at com.android.server.ConnectivityService.establishVpn(ConnectivityService.java:5644)
15388 27727 E TunnelingVpnService: 	at android.net.IConnectivityManager$Stub.onTransact(IConnectivityManager.java:1730)
15388 27727 E TunnelingVpnService: 	at android.os.Binder.execTransactInternal(Binder.java:1056)
15388 27727 E TunnelingVpnService: 
15388 27727 W TunnelingVpnService: VPN Service is still not established, stopping...

Other parts of this log are irrelevant.

If you have root access, you can run PowerTunnel in proxy mode and set 127.0.0.1:8085 as a global system proxy.

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 5, 2023

yeah i agreed after reading the log and some source codes
however i have no problem when using other vpn like orbot and some real vpn apps. so maybe different implementation? or android q is not supported by powertunnel?

i have another socks proxy server running on the phone. i don need to run it as proxy mode and forward it to my another local upstream proxy. what i want is to run it as vpn mode to make it possible to dirvert other apps/traffic

@krlvm
Copy link
Owner

krlvm commented Apr 5, 2023

Other VPNs work fine because they are VPNs indeed, while PowerTunnel's VPN is just a local packet interceptor

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 6, 2023

i see

so it's could be due to hardware like the check for samsung model starts with sm- in the sources (mine isnt sm series) or ROM issue

any idea which particular area(s) in the rom? vpn connection? the protocol used/encryption etc, or what? may be i can port it to my phone

edit
i have read VPNService.java and learned that it will throw an illegalStateException if the parama are invalid. and in the establish function, there are 2 params:

mConfig.addresses = mAddresses;

 mConfig.routes = mRoutes;

according to the doc either one can cause an error. so how can i know if it is the address or routes, or both, causing the problem?

edit 2
i just found this https://www.sonicwall.com/support/knowledge-base/mobile-connect-fails-to-establish-sslvpn-connection-with-error-cannot-create-interface/170505292313010/ which shows the same problem but it's for android 4 ice cream.

but still, i am unable to locate the problem area

@krlvm
Copy link
Owner

krlvm commented Apr 6, 2023

If you reinstall the application, do you see something like this?

image

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 6, 2023

vpndialog, yes

rn i am looking for similar forks to see if they can get connected

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 6, 2023

found this, a fork of raise-isayan's TunProxy
https://github.com/yehgdotnet/mobileptrepo/blob/master/android/tunproxy.apk

failed to start too with same errors. so it must be within TunProxy

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 6, 2023

sigh..... i got it....

from one of the forks, i found this in the log
Cannot add address: fd00:1:fd00:1:fd00:1:fd00:1/128: Permission denied

so, i know what's wrong, coz i disabled ipv6 by default
and after i re-enabled ipv6, powertunnel started successfully

so,
1/. can you please make ipv6 optional?
2/. more description about the settings will be great (perhaps most devs hate docs like me), eg

  • under dns, DNSSec (i know what this is but most people dont)
  • under settings, allow request to origin server (?)

most of them are quite technical, may be you assumed most us are advanced users. but for instance, i understand what transparent mode and strict dns mode are, but i am not very sure what "allow requests to origin server" means. do you mean cross-origin server? just wild guess :D

anyway, thanks a lot for your time and help

looking forward to see more features

@krlvm
Copy link
Owner

krlvm commented Apr 6, 2023

I'll make IPv6 an optional feature.

When "Allow requests to origin server" is disabled, LittleProxy rejects HTTP requests if they are direct requests to proxy, i.e. if they treat the proxy server as the origin server - such requests does not have the HTTP scheme in the URI.

@xxjoe2
Copy link
Author

xxjoe2 commented Apr 6, 2023

I'll make IPv6 an optional feature.

When "Allow requests to origin server" is disabled, LittleProxy rejects HTTP requests if they are direct requests to proxy, i.e. if they treat the proxy server as the origin server - such requests does not have the HTTP scheme in the URI.

that's great, thanks!

ok, so it is X-Forwarded-For i believe, which does not affect socks proxies

@krlvm krlvm added bug Something isn't working enhancement New feature or request labels Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants