Closed alalamav closed 8 years ago
Review status: 0 of 19 files reviewed at latest revision, 13 unresolved discussions.
_plugin.xml, line 27 [r2] (raw file):_
<config-file target="AndroidManifest.xml" parent="/manifest/application">
Nit: blank line
src/android/libs/jsocks.jar, line 0 [r2] (raw file): Obviously it's a bit unfortunate to be committing a JAR file. How big is this file? Do we have an alternative way to include it in the build?
src/android/org/uproxy/tun2socks/DnsResolverService.java, line 28 [r2] (raw file):
// This class listens on a UDP socket for incoming DNS traffic, which is proxy'd // through SOCKS over TCP to Honest DNS.
Nobody calls it Honest DNS :)
src/android/org/uproxy/tun2socks/DnsResolverService.java, line 141 [r2] (raw file):
Log.i(LOG_TAG, "listening on " + udpSocket.getLocalSocketAddress().toString()); try { udpSocket.receive(udpPacket);
What happens if someone sends a packet that's bigger than 512 bytes?
src/android/org/uproxy/tun2socks/DnsResolverService.java, line 199 [r2] (raw file):
} catch (Throwable e) { if (!isInterrupted()) { e.printStackTrace();
What state is the app now in? Is it silently broken?
src/android/org/uproxy/tun2socks/DnsResolverService.java, line 208 [r2] (raw file):
} private boolean validateDnsRequest(DatagramPacket packet) {
Nit: Prefer isValid
over validate
. Also, could this method be static?
src/android/org/uproxy/tun2socks/Tun2Socks.java, line 97 [r2] (raw file):
} private boolean hasVpnService() {
Nit: I think it would be worth exposing this as a command. Then maybe we wouldn't need to check the OS version in the JS code; we could just ask the plugin whether it's going to work.
_src/android/org/uproxy/tun2socks/Tun2Socks.java, line 104 [r2] (raw file):_
protected boolean prepareVpnService() throws ActivityNotFoundException { // VpnService: need to display OS user warning. If whole device // option is selected and we expect to use VpnService, so the prompt here in
Nit: "show the prompt"?
src/android/org/uproxy/tun2socks/Tunnel.java, line 127 [r2] (raw file):
// synchronized functions as stop() is synchronized and a deadlock is possible as callbacks // can be called while stop holds the lock. @TargetApi(Build.VERSION_CODES.LOLLIPOP)
Why lollipop? Deserves a comment.
src/android/org/uproxy/tun2socks/TunnelManager.java, line 59 [r2] (raw file):
// Implementation of android.app.Service.onStartCommand @TargetApi(Build.VERSION_CODES.M)
Why M? Needs comment.
src/badvpn/tun2socks/tun2socks.c, line 323 [r2] (raw file):
// Initializes a UDP socket, binds it locally and connects it to a local // address.
What's the return value?
src/badvpn/tun2socks/tun2socks.c, line 337 [r2] (raw file):
return 0; } // Bind to any local address in order to receive data
INADDR_ANY is not the same as "any local address". It's more like "the ANY address".
src/badvpn/tun2socks/tun2socks.h, line 48 [r2] (raw file):
//#define OVERRIDE_DEST_ADDR "10.111.0.2:2000" // maximum number of bytes for udp send/recv
Is this ever applied to UDP sending?
Comments from Reviewable
Review status: 0 of 19 files reviewed at latest revision, 13 unresolved discussions.
_plugin.xml, line 27 [r2] (raw file):_
Done.
src/android/libs/jsocks.jar, line [r2] (raw file):
The JAR is 395 KB. The source code is in SourceForge, but seems like it's not actively maintained. We could create our fork, and include the JAR ad hoc. But I don't know if this is a better alternative.
_src/android/org/uproxy/tun2socks/DnsResolverService.java, line 28 [r2] (raw file):_
lol
src/android/org/uproxy/tun2socks/DnsResolverService.java, line 141 [r2] (raw file):
As discussed offline, the DNS over UDP limit is 512 bytes and it's very unlikely that a query will exceed this size. However, the response could have a size of 32767 (max UDP packet size). I'll increase the buffer size to account for this.
src/android/org/uproxy/tun2socks/DnsResolverService.java, line 199 [r2] (raw file):
I've refactored this class to catch all exceptions, so this catch is no longer needed and there's no ambiguity about what went wrong.
src/android/org/uproxy/tun2socks/DnsResolverService.java, line 208 [r2] (raw file):
Done. It cannot because non-static nested classes are not allowed to declare static methods.
_src/android/org/uproxy/tun2socks/Tun2Socks.java, line 104 [r2] (raw file):_
Done.
src/android/org/uproxy/tun2socks/Tunnel.java, line 127 [r2] (raw file):
Done.
src/android/org/uproxy/tun2socks/TunnelManager.java, line 59 [r2] (raw file):
Done.
src/badvpn/tun2socks/tun2socks.c, line 323 [r2] (raw file):
Done.
_src/badvpn/tun2socks/tun2socks.c, line 337 [r2] (raw file):_
Done.
_src/badvpn/tun2socks/tun2socks.h, line 48 [r2] (raw file):_
See my previous comment on DNS/UDP limits.
Comments from Reviewable
Review status: 0 of 19 files reviewed at latest revision, 7 unresolved discussions.
src/android/org/uproxy/tun2socks/DnsResolverService.java, line 141 [r2] (raw file):
Seems like the max UDP packet size is 65535. (However, I agree that 32K is probably plenty.)
_src/android/org/uproxy/tun2socks/TunnelManager.java, line 59 [r2] (raw file):_
Hmm. I don't see a comment.
_src/badvpn/tun2socks/tun2socks.c, line 323 [r2] (raw file):_
It looks like it returns the socket's file descriptor number, not the IP address.
src/badvpn/tun2socks/tun2socks.c, line 337 [r2] (raw file):
OK ... this means that you can receive packets from anyone on the internet who manages to send a packet to this port, because ANY includes the public interface(s). Is that a problem?
Comments from Reviewable
Review status: 0 of 19 files reviewed at latest revision, 7 unresolved discussions.
src/android/org/uproxy/tun2socks/Tun2Socks.java, line 97 [r2] (raw file):
Done. I'll call this method from uProxy once it has been checked in.
src/android/org/uproxy/tun2socks/TunnelManager.java, line 59 [r2] (raw file):
This method used to call bindProcessToNetwork. The TargetApi annotation is no longer necessary. I updated the comment of pluginInitalize, which now calls bindProcessToNetwork.
src/badvpn/tun2socks/tun2socks.c, line 323 [r2] (raw file):
yes. fixed now.
_src/badvpn/tun2socks/tun2socks.c, line 337 [r2] (raw file):_
Although unlikely, it is not impossible for an attacker to inject fake DNS responses. I'm binding the socket to a the loopback address instead.
Comments from Reviewable
Great work. I've been running VPN on my own phone, too, with good results.
I'm mostly looking at this from the perspective of maintainability:
I think we should expand the README. Thanks to chatting with @albertolalama and my own poking around, is this the following a fair summary?:
We re-use and have used as a starting point a bunch of open source from Psiphon, specifically https://github.com/mei3am/ps
src/android
:
Android/app/src/main/java/ca/psiphon/PsiphonTunnel.java
-> src/android/org/uproxy/tun2socks/Tunnel.java
Android/app/src/main/java/com/psiphon3/psiphonlibrary/TunnelManager.java
-> src/android/org/uproxy/tun2socks/Tunnel.java
*Android/app/src/main/java/com/psiphon3/psiphonlibrary/TunnelVpnService.java
-> src/android/org/uproxy/tun2socks/TunnelVpnService.java
src/badvpn
:
// ==== UPROXY ====
(like Psiphon-specific changes)src/android/libs/jsocks.jar
:
Thank you for compiling a succinct summary, Trevor. I'll make sure to update the README with the code sources. You raise an interesting question around code maintenance and how to keep up with upstream fixes. I don't have a straight answer at this point, but I think this is something we should discuss with @bemasc.
:+1: with nits. I know you have more improvements queued up, so let's land this and get to the next one!
src/android/libs/jsocks.jar, line [r2] (raw file):
Fixed!
Comments from Reviewable
with one tiny nit
Review status: 0 of 18 files reviewed at latest revision, 1 unresolved discussion.
_src/android/org/uproxy/tun2socks/DnsResolverService.java, line 91 [r4] (raw file):_
Nit: This is not related to Google DNS. The DNS TCP protocol only has two bytes for length, so larger packets are cannot even be represented.
_Comments from Reviewable_
Review status: 0 of 18 files reviewed at latest revision, 2 unresolved discussions.
_src/android/org/uproxy/tun2socks/DnsResolverService.java, line 91 [r4] (raw file):_
Done.
Comments from Reviewable
This change is