From 8842a3dfe41a0af5380be94964db759233ec06ba Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 6 Feb 2016 15:07:08 +0100 Subject: [PATCH] Check of emty DNS addresses Refs #290 --- .../eu/faircode/netguard/ForwardService.java | 57 ------------------- .../eu/faircode/netguard/SinkholeService.java | 8 ++- 2 files changed, 5 insertions(+), 60 deletions(-) delete mode 100644 app/src/main/java/eu/faircode/netguard/ForwardService.java diff --git a/app/src/main/java/eu/faircode/netguard/ForwardService.java b/app/src/main/java/eu/faircode/netguard/ForwardService.java deleted file mode 100644 index 538c2ffb..00000000 --- a/app/src/main/java/eu/faircode/netguard/ForwardService.java +++ /dev/null @@ -1,57 +0,0 @@ -package eu.faircode.netguard; - -/* - This file is part of NetGuard. - - NetGuard is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - NetGuard is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with NetGuard. If not, see . - - Copyright 2015-2016 by Marcel Bokhorst (M66B) -*/ - -import android.app.IntentService; -import android.content.Intent; - -public class ForwardService extends IntentService { - private static final String TAG = "NetGuard.Forward"; - private static final String ACTION_START_PORT_FORWARD = "eu.faircode.netguard.START_PORT_FORWARD"; - private static final String ACTION_STOP_PORT_FORWARD = "eu.faircode.netguard.STOP_PORT_FORWARD"; - - private native void jni_start_port_forward(int source, int target, int uid); - - private native void jni_stop_port_forward(int source); - - static { - System.loadLibrary("netguard"); - } - - public ForwardService() { - super(TAG); - } - - @Override - protected void onHandleIntent(Intent intent) { - if (ACTION_START_PORT_FORWARD.equals(intent.getAction())) { - // am startservice -a eu.faircode.netguard.START_PORT_FORWARD --ei source --ei target --ei uid - int source = intent.getIntExtra("source", 0); - int target = intent.getIntExtra("target", 0); - int uid = intent.getIntExtra("uid", 0); - jni_start_port_forward(source, target, uid); - - } else if (ACTION_STOP_PORT_FORWARD.equals(intent.getAction())) { - // am startservice -a eu.faircode.netguard.STOP_PORT_FORWARD --ei source - int source = intent.getIntExtra("source", 0); - jni_stop_port_forward(source); - } - } -} diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index 35da9b3e..b31d69b2 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -738,17 +738,19 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS if (TextUtils.isEmpty(vpnDns.trim())) throw new UnknownHostException("dns"); InetAddress vpn = InetAddress.getByName(vpnDns); - Log.i(TAG, "DNS using=" + vpn); + Log.i(TAG, "DNS vpn using=" + vpn); return vpn; } catch (UnknownHostException ignored1) { try { + if (TextUtils.isEmpty(sysDns.trim())) + throw new UnknownHostException("dns"); InetAddress sys = InetAddress.getByName(sysDns); - Log.i(TAG, "DNS using=" + sys); + Log.i(TAG, "DNS sys using=" + sys); return sys; } catch (UnknownHostException ignored2) { try { InetAddress def = InetAddress.getByName("8.8.8.8"); - Log.i(TAG, "DNS using=" + def); + Log.i(TAG, "DNS def using=" + def); return def; } catch (UnknownHostException ignored) { return null;