Check of emty DNS addresses

Refs #290
This commit is contained in:
M66B 2016-02-06 15:07:08 +01:00
parent 1831f2f961
commit 8842a3dfe4
2 changed files with 5 additions and 60 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
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 <source> --ei target <target> --ei uid <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 <source>
int source = intent.getIntExtra("source", 0);
jni_stop_port_forward(source);
}
}
}

View File

@ -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;