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

DNS over UDP relay #13

Merged
merged 5 commits into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion android/java/build-extras.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'org.uproxy.jsocks:jsocks:1.0.1'
}
288 changes: 0 additions & 288 deletions android/java/org/uproxy/tun2socks/DnsResolverService.java

This file was deleted.

2 changes: 1 addition & 1 deletion android/java/org/uproxy/tun2socks/Tun2SocksJni.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static native int runTun2Socks(
String vpnIpAddress,
String vpnNetMask,
String socksServerAddress,
String dnsServerAddress,
String dnsResolverAddress,
int transparentDNS);

public static native int terminateTun2Socks();
Expand Down
16 changes: 9 additions & 7 deletions android/java/org/uproxy/tun2socks/Tunnel.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ public synchronized boolean startRouting() throws Exception {
}

// Starts tun2socks. Returns true on success.
public synchronized boolean startTunneling(String socksServerAddress, String dnsServerAddress)
public synchronized boolean startTunneling(String socksServerAddress)
throws Exception {
return routeThroughTunnel(socksServerAddress, dnsServerAddress);
return routeThroughTunnel(socksServerAddress);
}

// Stops routing traffic through the tunnel by stopping tun2socks.
Expand All @@ -126,6 +126,8 @@ public synchronized void stop() {

private static final String VPN_INTERFACE_NETMASK = "255.255.255.0";
private static final int VPN_INTERFACE_MTU = 1500;
private static final String DNS_RESOLVER_IP = "8.8.8.8";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth adding TODO comments for any of the following?

  • support multiple dns resolvers (e.g. 8.8.4.4, 208.67.222.222, etc.)
  • get config-type values like this from actual config rather than hard-coding

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather add issues for these.

  • Multiple DNS servers is more of a feature. Is the second for fallback?
  • A change like this is likely to include some UI component if the user is to choose these servers.

Copy link
Collaborator

@jab jab Apr 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that allowing the client to intelligently select among several options would allow more resilience to poorer quality of service (or outright blocking) of any one of them (more baskets for our eggs, so to speak). Since it sounds like it might not be YAGNI, I opened #16 to track this.

private static final int DNS_RESOLVER_PORT = 53;

// Note: Atomic variables used for getting/setting local proxy port, routing flag, and
// tun fd, as these functions may be called via callbacks. Do not use
Expand All @@ -152,7 +154,7 @@ private boolean startVpn() throws Exception {
.setMtu(VPN_INTERFACE_MTU)
.addAddress(mPrivateAddress.mIpAddress, mPrivateAddress.mPrefixLength)
.addRoute("0.0.0.0", 0)
.addDnsServer(mPrivateAddress.mRouter)
.addDnsServer(DNS_RESOLVER_IP)
.addDisallowedApplication(mHostService.getContext().getPackageName())
.establish();
} catch (NameNotFoundException e) {
Expand Down Expand Up @@ -183,7 +185,7 @@ private boolean startVpn() throws Exception {
return true;
}

private boolean routeThroughTunnel(String socksServerAddress, String dnsServerAddress) {
private boolean routeThroughTunnel(String socksServerAddress) {
if (!mRoutingThroughTunnel.compareAndSet(false, true)) {
return false;
}
Expand All @@ -198,7 +200,7 @@ private boolean routeThroughTunnel(String socksServerAddress, String dnsServerAd
mPrivateAddress.mRouter,
VPN_INTERFACE_NETMASK,
socksServerAddress,
dnsServerAddress,
String.format("%s:%d", DNS_RESOLVER_IP, DNS_RESOLVER_PORT),
true /* transparent DNS */);

mHostService.onTunnelConnected();
Expand Down Expand Up @@ -243,7 +245,7 @@ private void startTun2Socks(
final String vpnIpAddress,
final String vpnNetMask,
final String socksServerAddress,
final String dnsServerAddress,
final String dnsResolverAddress,
final boolean transparentDns) {
if (mTun2SocksThread != null) {
return;
Expand All @@ -259,7 +261,7 @@ public void run() {
vpnIpAddress,
vpnNetMask,
socksServerAddress,
dnsServerAddress,
dnsResolverAddress,
transparentDns ? 1 : 0);
}
});
Expand Down
Loading