Compare commits

...

24 Commits

Author SHA1 Message Date
Poussinou
0deea908d9
Update README.md (#125) 2022-06-26 10:08:50 +08:00
Licaon_Kter
a634fb60a9
Initial Fastlane structure (#124) 2022-06-18 20:34:42 +08:00
PeratX
29b60b3ba7 rules: support more dnsmasq rules. close #122 2022-05-24 11:37:44 +08:00
PeratX
e559925805 upgrade pcap4j 2022-05-23 15:21:30 +08:00
PeratX
61443b9d84 update jdk distro 2022-05-23 14:51:12 +08:00
PeratX
a8dbcd21cf update gradle wrapper and remove travis, using github actions 2022-05-23 14:48:56 +08:00
PeratX
d0dc3ada22 update version 2022-05-23 14:36:30 +08:00
PeratX
60a9834e9e update pendingIntent for api31 2022-05-23 14:29:22 +08:00
PeratX
dd05170112 update deps 2022-05-23 11:53:25 +08:00
PeratX
010096a4e3 Merge branch 'master' into api-31
# Conflicts:
#	app/build.gradle
#	build.gradle
2022-05-23 11:49:37 +08:00
PeratX
2067ef5d07 BootBroadcastReceiver: fix crash on Android 8+ 2019-11-20 13:21:32 +08:00
PeratX
417408105a gradle: release 1.14.2 2019-11-18 12:12:22 +08:00
PeratX
e2cea48c54 gradle: update wrapper 2019-11-18 09:59:46 +08:00
PeratX
1bc68d0c89 AppFilter: update 2019-10-23 22:55:22 +08:00
PeratX
cb08d9ddeb DaedalusVpnService: listen network change and update upstream DNS 2019-10-23 20:13:11 +08:00
PeratX
000706a2ae Daedalus: reformat things 2019-10-23 15:48:02 +08:00
PeratX
a2d92d49aa Provider: use DnsServer directly, get rid of magics 2019-10-23 14:33:42 +08:00
PeratX
c95b87b5a8 layout: update layouts with latest SDK 2019-10-23 13:34:21 +08:00
PeratX
b5d1942368 Home: remove notice_main 2019-10-23 12:34:17 +08:00
PeratX
37fa796303 DNS: add Use System DNS as upstream DNS. close #113 2019-10-22 18:11:08 +08:00
PeratX
77c7ce2135 README: update 2019-10-10 17:19:16 +08:00
PeratX
99cc306ded server: add foreground service option. close #112 2019-10-10 10:59:10 +08:00
PeratX
d207a41635 androidx: move to new libs 2019-10-10 10:09:36 +08:00
PeratX
b7c4ff9850 app: update dependencies 2019-09-16 09:33:23 +08:00
67 changed files with 943 additions and 669 deletions

1
.github/FUNDING.yml vendored
View File

@ -1 +0,0 @@
custom: https://qr.alipay.com/a6x07022gffiehykicipv1a

23
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,23 @@
on: [ push ]
name: Test build
jobs:
build:
name: Build APK
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Build APK
run: bash ./gradlew assemblePureDebug --stacktrace
- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: apk
path: app/build/outputs/apk/pure/debug/*.apk

View File

@ -1,21 +0,0 @@
language: android
jdk: oraclejdk8
dist: xenial
git:
depth: 1
android:
components:
- tools
- platform-tools
- build-tools-28.0.3
- android-28
- extra-android-support
- extra-google-m2repository
- extra-android-m2repository
licenses:
- '.+'
script:
- chmod 777 gradlew
- ./gradlew clean assemblePureDebug
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -1,19 +1,17 @@
# iTXTech Daedalus
[![Donate](https://img.shields.io/badge/alipay-donate-yellow.svg)](https://qr.alipay.com/a6x07022gffiehykicipv1a)
[![Build Status](https://travis-ci.org/iTXTech/Daedalus.svg?branch=master)](https://travis-ci.org/iTXTech/Daedalus)
[![Jenkins](https://img.shields.io/jenkins/s/http/dev.itxtech.org:10298/job/Daedalus.svg)](http://dev.itxtech.org:10298/job/Daedalus/)
__No root required Android DNS modifier and Hosts/DNSMasq resolver.__
## Installation
* __[Jenkins](http://dev.itxtech.org:10298/job/Daedalus/)__ - Debug signature
## Installations
* __[Releases](https://github.com/iTXTech/Daedalus/releases)__ - Release signature
* __[Play Test](https://play.google.com/apps/testing/org.itxtech.daedalus)__ - Release signature
[<img alt='Get it on Google Play'
src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png'
height="80">](https://play.google.com/store/apps/details?id=org.itxtech.daedalus)
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/org.itxtech.daedalus)
## Useful links
* __[Telegram](https://t.me/iTXTechDaedalus)__ - Join chat
@ -66,18 +64,17 @@ __Users must comply with local laws and regulations.__<br>
* __[ClearEditText](https://github.com/MrFuFuFu/ClearEditText)__ by *[Yuan Fu](https://github.com/MrFuFuFu)* - [APL 2.0](https://github.com/MrFuFuFu/ClearEditText)
* __[DNS66](https://github.com/julian-klode/dns66)__ by *[Julian Andres Klode](https://github.com/julian-klode)* - [GPLv3](https://github.com/julian-klode/dns66/blob/master/COPYING)
* __[Pcap4J](https://github.com/kaitoy/pcap4j)__ by *[Kaito Yamada](https://github.com/kaitoy)* - [MIT](https://github.com/kaitoy/pcap4j)
* __[MiniDNS](https://github.com/rtreffer/minidns)__ by *[Rene Treffer](https://github.com/rtreffer)* - [LGPLv2.1](https://github.com/rtreffer/minidns/blob/master/LICENCE_LGPL2.1)
* __[MiniDNS](https://github.com/MiniDNS/minidns)__ by *[MiniDNS](https://github.com/MiniDNS)* - [APL 2.0](https://github.com/MiniDNS/minidns/blob/master/LICENCE_APACHE)
* __[Gson](https://github.com/google/gson)__ by *[Google](https://github.com/google)* - [APL 2.0](https://github.com/google/gson/blob/master/LICENSE)
* __[Shadowsocks](https://github.com/shadowsocks/shadowsocks-android)__ by *[Shadowsocks](https://github.com/shadowsocks)* - [GPLv3](https://github.com/shadowsocks/shadowsocks-android/blob/master/LICENSE)
## Credits
* __[JetBrains](https://www.jetbrains.com/)__ - For providing free license for [IntelliJ IDEA](https://www.jetbrains.com/idea/)
* __[ShenniaoTech](https://www.sncidc.com/)__ - For supporting us with love
## License
Copyright (C) 2017-2019 iTX Technologies <admin@itxtech.org>
Copyright (C) 2017-2022 iTX Technologies <admin@itxtech.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -10,8 +10,8 @@ android {
applicationId "org.itxtech.daedalus"
minSdkVersion 21
targetSdkVersion 31
versionCode 20
versionName "1.14.1"
versionCode 21
versionName "1.15.0"
buildConfigField "String", "BUILD_TIME", "\"${System.currentTimeMillis()}\""
buildConfigField "String", "GIT_COMMIT", "\"${gitCommit}\""
@ -58,9 +58,10 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.7.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.3.0-alpha02'
implementation 'androidx.preference:preference:1.2.0'
//DNS
implementation 'org.pcap4j:pcap4j-core:1.7.6'
implementation 'org.pcap4j:pcap4j-packetfactory-static:1.7.6'
implementation 'org.pcap4j:pcap4j-core:1.8.2'
implementation 'org.pcap4j:pcap4j-packetfactory-static:1.8.2'
implementation 'org.minidns:minidns-client:1.0.3'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.3'

View File

@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18"/>
@ -58,7 +59,7 @@
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar.TransparentStatusBar"
android:exported="false">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

View File

@ -40,7 +40,7 @@
<br>
<div style="font-size: 12px; color: gray;">Users must comply with local laws and regulations.</div>
<br>
<div style="font-size: 12px; color: gray;">Copyright (C) 2017-2019 iTX Technologies <a
<div style="font-size: 12px; color: gray;">Copyright (C) 2017-2022 iTX Technologies <a
href="mailto:admin@itxtech.org">admin@itxtech.org</a>
</div>
<br>

View File

@ -41,7 +41,7 @@
<br>
<div style="font-size: 12px; color: gray;">使用者必须遵守当地法律法规。</div>
<br>
<div style="font-size: 12px; color: gray;">Copyright (C) 2017-2019 iTX Technologies <a
<div style="font-size: 12px; color: gray;">Copyright (C) 2017-2022 iTX Technologies <a
href="mailto:admin@itxtech.org">admin@itxtech.org</a>
</div>
<br>

View File

@ -10,20 +10,20 @@ import android.graphics.drawable.Icon;
import android.net.Uri;
import android.net.VpnService;
import android.os.Build;
import android.preference.PreferenceManager;
import android.util.Log;
import androidx.preference.PreferenceManager;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.stream.JsonReader;
import org.itxtech.daedalus.activity.MainActivity;
import org.itxtech.daedalus.server.AbstractDnsServer;
import org.itxtech.daedalus.server.DnsServer;
import org.itxtech.daedalus.server.DnsServerHelper;
import org.itxtech.daedalus.service.DaedalusVpnService;
import org.itxtech.daedalus.util.Configurations;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.Rule;
import org.itxtech.daedalus.util.RuleResolver;
import org.itxtech.daedalus.util.server.DNSServer;
import org.itxtech.daedalus.util.server.DNSServerHelper;
import java.io.File;
import java.util.ArrayList;
@ -45,28 +45,30 @@ public class Daedalus extends Application {
private static final String SHORTCUT_ID_ACTIVATE = "shortcut_activate";
public static final List<DNSServer> DNS_SERVERS = new ArrayList<DNSServer>() {{
add(new DNSServer("101.101.101.101", R.string.server_twnic_primary));
add(new DNSServer("101.102.103.104", R.string.server_twnic_secondary));
add(new DNSServer("dns.rubyfish.cn/dns-query", R.string.server_rubyfish));
add(new DNSServer("cloudflare-dns.com/dns-query", R.string.server_cloudflare));
add(new DNSServer("dns.google/dns-query", R.string.server_google_ietf));
add(new DNSServer("dns.google/resolve", R.string.server_google_json));
public static final List<DnsServer> DNS_SERVERS = new ArrayList<DnsServer>() {{
add(new DnsServer("101.101.101.101", R.string.server_twnic_primary));
add(new DnsServer("101.102.103.104", R.string.server_twnic_secondary));
add(new DnsServer("rubyfish.cn/dns-query", R.string.server_rubyfish));
add(new DnsServer("cloudflare-dns.com/dns-query", R.string.server_cloudflare));
add(new DnsServer("dns.google/dns-query", R.string.server_google_ietf));
add(new DnsServer("dns.google/resolve", R.string.server_google_json));
}};
public static final List<Rule> RULES = new ArrayList<Rule>() {{
public static final ArrayList<Rule> RULES = new ArrayList<Rule>() {{
add(new Rule("googlehosts/hosts", "googlehosts.hosts", Rule.TYPE_HOSTS,
"https://raw.githubusercontent.com/googlehosts/hosts/master/hosts-files/hosts", false));
add(new Rule("vokins/yhosts", "vokins.hosts", Rule.TYPE_HOSTS,
"https://raw.githubusercontent.com/vokins/yhosts/master/hosts", false));
add(new Rule("VeleSila/yhosts", "vokins.hosts", Rule.TYPE_HOSTS,
"https://raw.githubusercontent.com/VeleSila/yhosts/master/hosts.txt", false));
add(new Rule("adaway", "adaway.hosts", Rule.TYPE_HOSTS,
"https://adaway.org/hosts.txt", false));
//Build-in DNSMasq rule providers
add(new Rule("anti-AD", "antiad.dnsmasq", Rule.TYPE_DNAMASQ,
"https://anti-ad.net/anti-ad-for-dnsmasq.conf", false));
add(new Rule("vokins/yhosts/union", "union.dnsmasq", Rule.TYPE_DNAMASQ,
"https://raw.githubusercontent.com/vokins/yhosts/master/dnsmasq/union.conf", false));
}};
public static final String[] DEFAULT_TEST_DOMAINS = new String[]{
public static final String[] DEFAULT_TEST_DOMAINS = {
"google.com",
"twitter.com",
"youtube.com",
@ -75,12 +77,11 @@ public class Daedalus extends Application {
};
public static Configurations configurations;
public static String rulePath;
public static String logPath;
private static String configPath;
public static String rulePath = null;
public static String logPath = null;
private static String configPath = null;
private static Daedalus instance = null;
private static Daedalus instance;
private SharedPreferences prefs;
private Thread mResolver;
@ -89,12 +90,9 @@ public class Daedalus extends Application {
super.onCreate();
instance = this;
Logger.init();
mResolver = new Thread(new RuleResolver());
mResolver.start();
initData();
}
@ -135,30 +133,30 @@ public class Daedalus extends Application {
}
public static void initRuleResolver() {
ArrayList<String> pendingLoad = new ArrayList<>();
ArrayList<Rule> usingRules = configurations.getUsingRules();
if (usingRules != null && usingRules.size() > 0) {
for (Rule rule : usingRules) {
if (rule.isUsing()) {
pendingLoad.add(rulePath + rule.getFileName());
}
ArrayList<String> pendingLoad = new ArrayList<>();
ArrayList<Rule> usingRules = configurations.getUsingRules();
if (usingRules != null && usingRules.size() > 0) {
for (Rule rule : usingRules) {
if (rule.isUsing()) {
pendingLoad.add(rulePath + rule.getFileName());
}
if (pendingLoad.size() > 0) {
String[] arr = new String[pendingLoad.size()];
pendingLoad.toArray(arr);
switch (usingRules.get(0).getType()) {
case Rule.TYPE_HOSTS:
RuleResolver.startLoadHosts(arr);
break;
case Rule.TYPE_DNAMASQ:
RuleResolver.startLoadDnsmasq(arr);
break;
}
} else {
RuleResolver.clear();
}
if (pendingLoad.size() > 0) {
String[] arr = new String[pendingLoad.size()];
pendingLoad.toArray(arr);
switch (usingRules.get(0).getType()) {
case Rule.TYPE_HOSTS:
RuleResolver.startLoadHosts(arr);
break;
case Rule.TYPE_DNAMASQ:
RuleResolver.startLoadDnsmasq(arr);
break;
}
} else {
RuleResolver.clear();
}
} else {
RuleResolver.clear();
}
}
@ -178,7 +176,6 @@ public class Daedalus extends Application {
@Override
public void onTerminate() {
Log.d("Daedalus", "onTerminate");
super.onTerminate();
instance = null;
@ -199,23 +196,38 @@ public class Daedalus extends Application {
deactivateService(instance);
return false;
} else {
activateService(instance);
prepareAndActivateService(instance);
return true;
}
}
public static boolean activateService(Context context) {
public static boolean prepareAndActivateService(Context context) {
Intent intent = VpnService.prepare(context);
if (intent != null) {
return false;
} else {
DaedalusVpnService.primaryServer = DNSServerHelper.getAddressById(DNSServerHelper.getPrimary());
DaedalusVpnService.secondaryServer = DNSServerHelper.getAddressById(DNSServerHelper.getSecondary());
context.startService(Daedalus.getServiceIntent(context).setAction(DaedalusVpnService.ACTION_ACTIVATE));
activateService(context);
return true;
}
}
public static void activateService(Context context) {
activateService(context, false);
}
public static void activateService(Context context, boolean forceForeground) {
DaedalusVpnService.primaryServer = (AbstractDnsServer) DnsServerHelper.getServerById(DnsServerHelper.getPrimary()).clone();
DaedalusVpnService.secondaryServer = (AbstractDnsServer) DnsServerHelper.getServerById(DnsServerHelper.getSecondary()).clone();
if ((getInstance().prefs.getBoolean("settings_foreground", false) || forceForeground)
&& Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
Logger.info("Starting foreground service");
context.startForegroundService(Daedalus.getServiceIntent(context).setAction(DaedalusVpnService.ACTION_ACTIVATE));
} else {
Logger.info("Starting background service");
context.startService(Daedalus.getServiceIntent(context).setAction(DaedalusVpnService.ACTION_ACTIVATE));
}
}
public static void deactivateService(Context context) {
context.startService(getServiceIntent(context).setAction(DaedalusVpnService.ACTION_DEACTIVATE));
context.stopService(getServiceIntent(context));
@ -223,7 +235,7 @@ public class Daedalus extends Application {
public static void updateShortcut(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
Log.d("Daedalus", "Updating shortcut");
Logger.info("Updating shortcut");
boolean activate = DaedalusVpnService.isActivated();
String notice = activate ? context.getString(R.string.button_text_deactivate) : context.getString(R.string.button_text_activate);
ShortcutInfo info = new ShortcutInfo.Builder(context, Daedalus.SHORTCUT_ID_ACTIVATE)
@ -239,7 +251,7 @@ public class Daedalus extends Application {
}
public static void donate() {
openUri("https://qr.alipay.com/a6x07022gffiehykicipv1a");
openUri("https://qr.alipay.com/FKX04751EZDP0SQ0BOT137");
}
public static void openUri(String uri) {

View File

@ -40,7 +40,6 @@ import java.util.Objects;
* (at your option) any later version.
*/
public class AppFilterActivity extends AppCompatActivity {
private RecyclerViewAdapter adapter;
@Override
@ -78,7 +77,7 @@ public class AppFilterActivity extends AppCompatActivity {
adapter.notifyDataSetChanged();
}
private class AppObject {
private static class AppObject {
private String appName;
private String appPackageName;
private Drawable appIcon;
@ -111,13 +110,11 @@ public class AppFilterActivity extends AppCompatActivity {
void updateList(ArrayList<AppObject> appObjects) {
appList = appObjects;
for (int i = 0; i < appObjects.size(); i++) {
if (Daedalus.configurations.getAppObjects().contains(appObjects.get(i).appPackageName)) {
checkStatus.put(i, true);
}
}
runOnUiThread(this::notifyDataSetChanged);
}
@ -158,7 +155,7 @@ public class AppFilterActivity extends AppCompatActivity {
}
}
private class RecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private static class RecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private ImageView appIcon;
private TextView appName;
private CheckBox appCheck;
@ -172,7 +169,6 @@ public class AppFilterActivity extends AppCompatActivity {
itemView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (appCheck.isChecked()) {

View File

@ -1,7 +1,5 @@
package org.itxtech.daedalus.activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@ -9,10 +7,12 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.fragment.ConfigFragment;
import org.itxtech.daedalus.fragment.DNSServerConfigFragment;
import org.itxtech.daedalus.fragment.DnsServerConfigFragment;
import org.itxtech.daedalus.fragment.RuleConfigFragment;
/**
@ -44,14 +44,12 @@ public class ConfigActivity extends AppCompatActivity {
ConfigFragment fragment;
switch (getIntent().getIntExtra(LAUNCH_ACTION_FRAGMENT, LAUNCH_FRAGMENT_DNS_SERVER)) {
case LAUNCH_FRAGMENT_DNS_SERVER:
fragment = new DNSServerConfigFragment();
break;
case LAUNCH_FRAGMENT_RULE:
fragment = new RuleConfigFragment();
break;
case LAUNCH_FRAGMENT_DNS_SERVER:
default://should never reach this
fragment = new DNSServerConfigFragment();
fragment = new DnsServerConfigFragment();
break;
}
@ -64,7 +62,7 @@ public class ConfigActivity extends AppCompatActivity {
toolbar.setOnMenuItemClickListener(fragment);
toolbar.inflateMenu(R.menu.custom_config);
FragmentManager manager = getFragmentManager();
FragmentManager manager = getSupportFragmentManager();
fragment.setIntent(getIntent());
FragmentTransaction fragmentTransaction = manager.beginTransaction();
fragmentTransaction.replace(R.id.id_config, fragment);

View File

@ -1,9 +1,7 @@
package org.itxtech.daedalus.activity;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.VpnService;
import android.os.Bundle;
@ -14,7 +12,6 @@ import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
@ -26,7 +23,6 @@ import org.itxtech.daedalus.R;
import org.itxtech.daedalus.fragment.*;
import org.itxtech.daedalus.service.DaedalusVpnService;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.server.DNSServerHelper;
/**
* Daedalus Project
@ -100,8 +96,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
if (currentFragment == null || fragmentClass != currentFragment.getClass()) {
try {
ToolbarFragment fragment = (ToolbarFragment) fragmentClass.newInstance();
FragmentManager fm = getFragmentManager();
fm.beginTransaction().replace(R.id.id_content, fragment).commit();
getSupportFragmentManager().beginTransaction().replace(R.id.id_content, fragment).commit();
currentFragment = fragment;
} catch (Exception e) {
Logger.logException(e);
@ -149,40 +144,31 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
activateCounter++;
Daedalus.configurations.setActivateCounter(activateCounter);
if (activateCounter % 10 == 0) {
new AlertDialog.Builder(this)
.setTitle("觉得还不错?")
.setMessage("您的支持是我动力来源!\n请考虑为我买杯咖啡醒醒脑甚至其他…… ;)")
.setPositiveButton("为我买杯咖啡", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Daedalus.donate();
new AlertDialog.Builder(MainActivity.this)
.setMessage("感谢您的支持!;)\n我会再接再厉")
.setPositiveButton("确认", null)
.show();
}
})
.setNeutralButton("不再显示", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Daedalus.configurations.setActivateCounter(-1);
}
})
.setNegativeButton("取消", null)
.show();
}
// if (activateCounter % 10 == 0) {
// new AlertDialog.Builder(this)
// .setTitle("觉得还不错?")
// .setMessage("您的支持是我动力来源!\n请考虑为我买杯咖啡醒醒脑甚至其他…… ;)")
// .setPositiveButton("为我买杯咖啡", (dialog, which) -> {
// Daedalus.donate();
// new AlertDialog.Builder(MainActivity.this)
// .setMessage("感谢您的支持!;)\n我会再接再厉")
// .setPositiveButton("确认", null)
// .show();
// })
// .setNeutralButton("不再显示", (dialog, which) -> Daedalus.configurations.setActivateCounter(-1))
// .setNegativeButton("取消", null)
// .show();
// }
}
public void onActivityResult(int request, int result, Intent data) {
super.onActivityResult(request, result, data);
if (result == Activity.RESULT_OK) {
DaedalusVpnService.primaryServer = DNSServerHelper.getAddressById(DNSServerHelper.getPrimary());
DaedalusVpnService.secondaryServer = DNSServerHelper.getAddressById(DNSServerHelper.getSecondary());
Daedalus.getInstance().startService(Daedalus.getServiceIntent(getApplicationContext()).setAction(DaedalusVpnService.ACTION_ACTIVATE));
Daedalus.activateService(Daedalus.getInstance());
updateMainButton(R.string.button_text_deactivate);
Daedalus.updateShortcut(getApplicationContext());
}
super.onActivityResult(request, result, data);
}
private void updateMainButton(int id) {
@ -194,7 +180,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private void updateUserInterface(Intent intent) {
int launchAction = intent.getIntExtra(LAUNCH_ACTION, LAUNCH_ACTION_NONE);
Log.d(TAG, "Updating user interface with Launch Action " + String.valueOf(launchAction));
Log.d(TAG, "Updating user interface with Launch Action " + launchAction);
if (launchAction == LAUNCH_ACTION_ACTIVATE) {
this.activateService();
} else if (launchAction == LAUNCH_ACTION_DEACTIVATE) {
@ -227,10 +213,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
switchFragment(AboutFragment.class);
break;
case FRAGMENT_DNS_SERVERS:
switchFragment(DNSServersFragment.class);
switchFragment(DnsServersFragment.class);
break;
case FRAGMENT_DNS_TEST:
switchFragment(DNSTestFragment.class);
switchFragment(DnsTestFragment.class);
break;
case FRAGMENT_HOME:
switchFragment(HomeFragment.class);
@ -252,7 +238,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
switch (id) {
@ -260,10 +245,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
switchFragment(AboutFragment.class);
break;
case R.id.nav_dns_server:
switchFragment(DNSServersFragment.class);
switchFragment(DnsServersFragment.class);
break;
case R.id.nav_dns_test:
switchFragment(DNSTestFragment.class);
switchFragment(DnsTestFragment.class);
break;
case R.id.nav_github:
Daedalus.openUri("https://github.com/iTXTech/Daedalus");

View File

@ -13,6 +13,7 @@ import android.webkit.WebViewClient;
import org.itxtech.daedalus.BuildConfig;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.util.Logger;
import java.util.Locale;
@ -64,7 +65,7 @@ public class AboutFragment extends ToolbarFragment {
mWebView.loadUrl("javascript:changeColor('"+(Daedalus.isDarkTheme() ? "#FFFFFF" : "#000000")+"')");
mWebView.loadUrl("javascript:changeVersionInfo('" + Daedalus.getInstance().getPackageManager().getPackageInfo(Daedalus.getInstance().getPackageName(), 0).versionName + "', '" + BuildConfig.BUILD_TIME + "', '" + BuildConfig.GIT_COMMIT + "')");
} catch (Exception e) {
Log.e("DAboutActivity", e.toString());
Logger.logException(e);
}
}
});
@ -82,8 +83,6 @@ public class AboutFragment extends ToolbarFragment {
super.onDestroyView();
if (mWebView != null) {
Log.d("DAboutActivity", "onDestroy");
mWebView.removeAllViews();
mWebView.setWebViewClient(null);
((ViewGroup) mWebView.getParent()).removeView(mWebView);

View File

@ -1,8 +1,8 @@
package org.itxtech.daedalus.fragment;
import android.content.Intent;
import android.preference.PreferenceFragment;
import androidx.appcompat.widget.Toolbar;
import androidx.preference.PreferenceFragmentCompat;
/**
* Daedalus Project
@ -15,7 +15,7 @@ import androidx.appcompat.widget.Toolbar;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
abstract public class ConfigFragment extends PreferenceFragment implements Toolbar.OnMenuItemClickListener {
abstract public class ConfigFragment extends PreferenceFragmentCompat implements Toolbar.OnMenuItemClickListener {
protected Intent intent = null;
public void setIntent(Intent intent) {

View File

@ -2,7 +2,7 @@ package org.itxtech.daedalus.fragment;
import android.app.AlertDialog;
import android.os.Bundle;
import android.preference.EditTextPreference;
import androidx.preference.EditTextPreference;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@ -11,8 +11,8 @@ import com.google.android.material.snackbar.Snackbar;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.activity.ConfigActivity;
import org.itxtech.daedalus.util.server.CustomDNSServer;
import org.itxtech.daedalus.util.server.DNSServer;
import org.itxtech.daedalus.server.CustomDnsServer;
import org.itxtech.daedalus.server.DnsServer;
/**
* Daedalus Project
@ -25,12 +25,11 @@ import org.itxtech.daedalus.util.server.DNSServer;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
public class DNSServerConfigFragment extends ConfigFragment {
public class DnsServerConfigFragment extends ConfigFragment {
private int index;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.perf_server);
}
@ -38,19 +37,19 @@ public class DNSServerConfigFragment extends ConfigFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
EditTextPreference serverName = (EditTextPreference) findPreference("serverName");
EditTextPreference serverName = findPreference("serverName");
serverName.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary((String) newValue);
return true;
});
EditTextPreference serverAddress = (EditTextPreference) findPreference("serverAddress");
EditTextPreference serverAddress = findPreference("serverAddress");
serverAddress.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary((String) newValue);
return true;
});
EditTextPreference serverPort = (EditTextPreference) findPreference("serverPort");
EditTextPreference serverPort = findPreference("serverPort");
serverPort.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary((String) newValue);
return true;
@ -59,7 +58,7 @@ public class DNSServerConfigFragment extends ConfigFragment {
index = intent.getIntExtra(ConfigActivity.LAUNCH_ACTION_ID, ConfigActivity.ID_NONE);
if (index != ConfigActivity.ID_NONE) {
CustomDNSServer server = Daedalus.configurations.getCustomDNSServers().get(index);
CustomDnsServer server = Daedalus.configurations.getCustomDNSServers().get(index);
serverName.setText(server.getName());
serverName.setSummary(server.getName());
serverAddress.setText(server.getAddress());
@ -69,7 +68,7 @@ public class DNSServerConfigFragment extends ConfigFragment {
} else {
serverName.setText("");
serverAddress.setText("");
String port = String.valueOf(DNSServer.DNS_SERVER_DEFAULT_PORT);
String port = String.valueOf(DnsServer.DNS_SERVER_DEFAULT_PORT);
serverPort.setText(port);
serverPort.setSummary(port);
}
@ -93,9 +92,9 @@ public class DNSServerConfigFragment extends ConfigFragment {
}
if (index == ConfigActivity.ID_NONE) {
Daedalus.configurations.getCustomDNSServers().add(new CustomDNSServer(serverName, serverAddress, Integer.parseInt(serverPort)));
Daedalus.configurations.getCustomDNSServers().add(new CustomDnsServer(serverName, serverAddress, Integer.parseInt(serverPort)));
} else {
CustomDNSServer server = Daedalus.configurations.getCustomDNSServers().get(index);
CustomDnsServer server = Daedalus.configurations.getCustomDNSServers().get(index);
server.setName(serverName);
server.setAddress(serverAddress);
server.setPort(Integer.parseInt(serverPort));

View File

@ -15,8 +15,8 @@ import com.google.android.material.snackbar.Snackbar;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.activity.ConfigActivity;
import org.itxtech.daedalus.util.server.CustomDNSServer;
import org.itxtech.daedalus.util.server.DNSServerHelper;
import org.itxtech.daedalus.server.CustomDnsServer;
import org.itxtech.daedalus.server.DnsServerHelper;
/**
* Daedalus Project
@ -29,9 +29,9 @@ import org.itxtech.daedalus.util.server.DNSServerHelper;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
public class DNSServersFragment extends ToolbarFragment {
public class DnsServersFragment extends ToolbarFragment {
private DNSServerAdapter adapter;
private CustomDNSServer server = null;
private CustomDnsServer server = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -47,7 +47,7 @@ public class DNSServersFragment extends ToolbarFragment {
if (viewHolder instanceof ViewHolder) {
int index = ((ViewHolder) viewHolder).getIndex();
if (index < Daedalus.configurations.getCustomDNSServers().size() &&
DNSServerHelper.isInUsing(Daedalus.configurations.getCustomDNSServers().get(index))) {
DnsServerHelper.isInUsing(Daedalus.configurations.getCustomDNSServers().get(index))) {
return 0;
}
}
@ -118,7 +118,7 @@ public class DNSServersFragment extends ToolbarFragment {
private class DNSServerAdapter extends RecyclerView.Adapter<ViewHolder> {
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
CustomDNSServer server = Daedalus.configurations.getCustomDNSServers().get(position);
CustomDnsServer server = Daedalus.configurations.getCustomDNSServers().get(position);
holder.setIndex(position);
holder.textViewName.setText(server.getName());
holder.textViewAddress.setText(server.getRealName());
@ -159,7 +159,7 @@ public class DNSServersFragment extends ToolbarFragment {
@Override
public void onClick(View v) {
if (!DNSServerHelper.isInUsing(Daedalus.configurations.getCustomDNSServers().get(index))) {
if (!DnsServerHelper.isInUsing(Daedalus.configurations.getCustomDNSServers().get(index))) {
Daedalus.getInstance().startActivity(new Intent(Daedalus.getInstance(), ConfigActivity.class)
.putExtra(ConfigActivity.LAUNCH_ACTION_ID, index)
.putExtra(ConfigActivity.LAUNCH_ACTION_FRAGMENT, ConfigActivity.LAUNCH_FRAGMENT_DNS_SERVER)

View File

@ -12,8 +12,8 @@ import android.widget.*;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.server.AbstractDNSServer;
import org.itxtech.daedalus.util.server.DNSServerHelper;
import org.itxtech.daedalus.server.AbstractDnsServer;
import org.itxtech.daedalus.server.DnsServerHelper;
import org.minidns.dnsmessage.DnsMessage;
import org.minidns.dnsmessage.Question;
import org.minidns.record.Record;
@ -36,7 +36,7 @@ import java.util.Random;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
public class DNSTestFragment extends ToolbarFragment {
public class DnsTestFragment extends ToolbarFragment {
private class Type {
private Record.TYPE type;
private String name;
@ -67,9 +67,9 @@ public class DNSTestFragment extends ToolbarFragment {
final TextView textViewTestInfo = view.findViewById(R.id.textView_test_info);
final Spinner spinnerServerChoice = view.findViewById(R.id.spinner_server_choice);
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, DNSServerHelper.getAllServers());
ArrayAdapter spinnerArrayAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, DnsServerHelper.getAllServers());
spinnerServerChoice.setAdapter(spinnerArrayAdapter);
spinnerServerChoice.setSelection(DNSServerHelper.getPosition(DNSServerHelper.getPrimary()));
spinnerServerChoice.setSelection(DnsServerHelper.getPosition(DnsServerHelper.getPrimary()));
ArrayList<Type> types = new ArrayList<Type>() {{
add(new Type("A", Record.TYPE.A));
@ -110,38 +110,38 @@ public class DNSTestFragment extends ToolbarFragment {
testDomain = Daedalus.DEFAULT_TEST_DOMAINS[0];
}
StringBuilder testText = new StringBuilder();
ArrayList<AbstractDNSServer> dnsServers = new ArrayList<AbstractDNSServer>() {{
add(((AbstractDNSServer) spinnerServerChoice.getSelectedItem()));
ArrayList<AbstractDnsServer> dnsServers = new ArrayList<AbstractDnsServer>() {{
add(((AbstractDnsServer) spinnerServerChoice.getSelectedItem()));
String servers = Daedalus.getPrefs().getString("dns_test_servers", "");
if (!servers.equals("")) {
for (String server : servers.split(",")) {
if (server.contains(".") && server.contains(":")) {//IPv4
String[] pieces = servers.split(":");
int port = AbstractDNSServer.DNS_SERVER_DEFAULT_PORT;
int port = AbstractDnsServer.DNS_SERVER_DEFAULT_PORT;
try {
port = Integer.parseInt(pieces[1]);
} catch (Exception e) {
Logger.logException(e);
}
add(new AbstractDNSServer(pieces[0], port));
add(new AbstractDnsServer(pieces[0], port));
} else if (!server.contains(".") && server.contains("|")) {//IPv6
String[] pieces = servers.split("\\|");
int port = AbstractDNSServer.DNS_SERVER_DEFAULT_PORT;
int port = AbstractDnsServer.DNS_SERVER_DEFAULT_PORT;
try {
port = Integer.parseInt(pieces[1]);
} catch (Exception e) {
Logger.logException(e);
}
add(new AbstractDNSServer(pieces[0], port));
add(new AbstractDnsServer(pieces[0], port));
} else {
add(new AbstractDNSServer(server, AbstractDNSServer.DNS_SERVER_DEFAULT_PORT));
add(new AbstractDnsServer(server, AbstractDnsServer.DNS_SERVER_DEFAULT_PORT));
}
}
}
}};
DnsQuery dnsQuery = new DnsQuery();
Record.TYPE type = ((Type) spinnerType.getSelectedItem()).getType();
for (AbstractDNSServer dnsServer : dnsServers) {
for (AbstractDnsServer dnsServer : dnsServers) {
testText = testServer(dnsQuery, type, dnsServer, testDomain, testText);
}
mHandler.obtainMessage(DnsTestHandler.MSG_TEST_DONE).sendToTarget();
@ -151,8 +151,7 @@ public class DNSTestFragment extends ToolbarFragment {
}
}
private StringBuilder testServer(DnsQuery dnsQuery, Record.TYPE type, AbstractDNSServer server, String domain, StringBuilder testText) {
private StringBuilder testServer(DnsQuery dnsQuery, Record.TYPE type, AbstractDnsServer server, String domain, StringBuilder testText) {
Logger.debug("Testing DNS server " + server.getRealName());
testText.append(getString(R.string.test_domain)).append(" ").append(domain).append("\n")
.append(getString(R.string.test_dns_server)).append(" ").append(server.getRealName());
@ -181,7 +180,7 @@ public class DNSTestFragment extends ToolbarFragment {
}
}
testText.append("\n").append(getString(R.string.test_time_used)).append(" ").
append(String.valueOf(endTime - startTime)).append(" ms");
append(endTime - startTime).append(" ms");
succ = true;
}
} catch (SocketTimeoutException ignored) {

View File

@ -2,12 +2,14 @@ package org.itxtech.daedalus.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.preference.*;
import androidx.preference.*;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
import org.itxtech.daedalus.activity.AppFilterActivity;
import org.itxtech.daedalus.activity.MainActivity;
import org.itxtech.daedalus.util.server.DNSServerHelper;
import org.itxtech.daedalus.server.DnsServerHelper;
import java.util.ArrayList;
/**
* Daedalus Project
@ -20,52 +22,47 @@ import org.itxtech.daedalus.util.server.DNSServerHelper;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
public class GlobalConfigFragment extends PreferenceFragment {
public class GlobalConfigFragment extends PreferenceFragmentCompat {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
Daedalus.getPrefs().edit()
.putString("primary_server", DNSServerHelper.getPrimary())
.putString("secondary_server", DNSServerHelper.getSecondary())
.putString("primary_server", DnsServerHelper.getPrimary())
.putString("secondary_server", DnsServerHelper.getSecondary())
.apply();
addPreferencesFromResource(R.xml.perf_settings);
ListPreference primaryServer = (ListPreference) findPreference("primary_server");
primaryServer.setEntries(DNSServerHelper.getNames(Daedalus.getInstance()));
primaryServer.setEntryValues(DNSServerHelper.getIds());
primaryServer.setSummary(DNSServerHelper.getDescription(primaryServer.getValue(), Daedalus.getInstance()));
primaryServer.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary(DNSServerHelper.getDescription((String) newValue, Daedalus.getInstance()));
return true;
});
boolean visible = !Daedalus.getPrefs().getBoolean("settings_use_system_dns", false);
for (String k : new ArrayList<String>() {{
add("primary_server");
add("secondary_server");
}}) {
ListPreference listPref = findPreference(k);
listPref.setEntries(DnsServerHelper.getNames(Daedalus.getInstance()));
listPref.setEntryValues(DnsServerHelper.getIds());
listPref.setSummary(DnsServerHelper.getDescription(listPref.getValue(), Daedalus.getInstance()));
listPref.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary(DnsServerHelper.getDescription((String) newValue, Daedalus.getInstance()));
return true;
});
}
ListPreference secondaryServer = (ListPreference) findPreference("secondary_server");
secondaryServer.setEntries(DNSServerHelper.getNames(Daedalus.getInstance()));
secondaryServer.setEntryValues(DNSServerHelper.getIds());
secondaryServer.setSummary(DNSServerHelper.getDescription(secondaryServer.getValue(), Daedalus.getInstance()));
secondaryServer.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary(DNSServerHelper.getDescription((String) newValue, Daedalus.getInstance()));
return true;
});
EditTextPreference testDNSServers = (EditTextPreference) findPreference("dns_test_servers");
EditTextPreference testDNSServers = findPreference("dns_test_servers");
testDNSServers.setSummary(testDNSServers.getText());
testDNSServers.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary((String) newValue);
return true;
});
EditTextPreference logSize = (EditTextPreference) findPreference("settings_log_size");
EditTextPreference logSize = findPreference("settings_log_size");
logSize.setSummary(logSize.getText());
logSize.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary((String) newValue);
return true;
});
SwitchPreference darkTheme = (SwitchPreference) findPreference("settings_dark_theme");
SwitchPreference darkTheme = findPreference("settings_dark_theme");
darkTheme.setOnPreferenceChangeListener((preference, o) -> {
getActivity().startActivity(new Intent(Daedalus.getInstance(), MainActivity.class)
.putExtra(MainActivity.LAUNCH_FRAGMENT, MainActivity.FRAGMENT_SETTINGS)
@ -73,13 +70,13 @@ public class GlobalConfigFragment extends PreferenceFragment {
return true;
});
SwitchPreference advanced = (SwitchPreference) findPreference("settings_advanced_switch");
SwitchPreference advanced = findPreference("settings_advanced_switch");
advanced.setOnPreferenceChangeListener((preference, newValue) -> {
updateOptions((boolean) newValue, "settings_advanced");
return true;
});
SwitchPreference appFilter = (SwitchPreference) findPreference("settings_app_filter_switch");
SwitchPreference appFilter = findPreference("settings_app_filter_switch");
appFilter.setOnPreferenceChangeListener((p, w) -> {
updateOptions((boolean) w, "settings_app_filter");
return true;
@ -115,7 +112,7 @@ public class GlobalConfigFragment extends PreferenceFragment {
}
private void updateOptions(boolean checked, String pref) {
PreferenceCategory category = (PreferenceCategory) findPreference(pref);
PreferenceCategory category = findPreference(pref);
for (int i = 1; i < category.getPreferenceCount(); i++) {
Preference preference = category.getPreference(i);
if (checked) {

View File

@ -49,16 +49,7 @@ public class HomeFragment extends ToolbarFragment {
updateUserInterface();
}
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
updateUserInterface();
}
}
private void updateUserInterface() {
Log.d("DMainFragment", "updateInterface");
Button but = getView().findViewById(R.id.button_activate);
if (DaedalusVpnService.isActivated()) {
but.setText(R.string.button_text_deactivate);

View File

@ -44,7 +44,7 @@ public class LogFragment extends ToolbarFragment implements Toolbar.OnMenuItemCl
private void export() {
try {
String file = Daedalus.logPath + String.valueOf(System.currentTimeMillis()) + ".log";
String file = Daedalus.logPath + System.currentTimeMillis() + ".log";
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(Logger.getLog());
fileWriter.close();

View File

@ -7,8 +7,8 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@ -72,10 +72,8 @@ public class RuleConfigFragment extends ConfigFragment {
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.perf_rule);
}
@ -85,13 +83,13 @@ public class RuleConfigFragment extends ConfigFragment {
mHandler = new RuleConfigHandler().setView(view);
final EditTextPreference ruleName = (EditTextPreference) findPreference("ruleName");
final EditTextPreference ruleName = findPreference("ruleName");
ruleName.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary((String) newValue);
return true;
});
final ListPreference ruleType = (ListPreference) findPreference("ruleType");
final ListPreference ruleType = findPreference("ruleType");
final String[] entries = {"Hosts", "DNSMasq"};
String[] values = {"0", "1"};
ruleType.setEntries(entries);
@ -101,19 +99,19 @@ public class RuleConfigFragment extends ConfigFragment {
return true;
});
final EditTextPreference ruleDownloadUrl = (EditTextPreference) findPreference("ruleDownloadUrl");
final EditTextPreference ruleDownloadUrl = findPreference("ruleDownloadUrl");
ruleDownloadUrl.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary((String) newValue);
return true;
});
final EditTextPreference ruleFilename = (EditTextPreference) findPreference("ruleFilename");
final EditTextPreference ruleFilename = findPreference("ruleFilename");
ruleFilename.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary((String) newValue);
return true;
});
ClickPreference ruleSync = (ClickPreference) findPreference("ruleSync");
ClickPreference ruleSync = findPreference("ruleSync");
ruleSync.setOnPreferenceClickListener(preference -> {
save();
if (mThread == null) {
@ -167,7 +165,7 @@ public class RuleConfigFragment extends ConfigFragment {
return false;
});
ListPreference ruleImportBuildIn = (ListPreference) findPreference("ruleImportBuildIn");
ListPreference ruleImportBuildIn = findPreference("ruleImportBuildIn");
ruleImportBuildIn.setEntries(Rule.getBuildInRuleNames());
ruleImportBuildIn.setEntryValues(Rule.getBuildInRuleEntries());
ruleImportBuildIn.setOnPreferenceChangeListener((preference, newValue) -> {
@ -183,7 +181,7 @@ public class RuleConfigFragment extends ConfigFragment {
return true;
});
ClickPreference ruleImportExternal = (ClickPreference) findPreference("ruleImportExternal");
ClickPreference ruleImportExternal = findPreference("ruleImportExternal");
ruleImportExternal.setOnPreferenceClickListener(preference -> {
performFileSearch();
return false;

View File

@ -1,7 +1,5 @@
package org.itxtech.daedalus.fragment;
import android.app.FragmentManager;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -28,13 +26,7 @@ public class SettingsFragment extends ToolbarFragment {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
FragmentManager fm;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
fm = getChildFragmentManager();
} else {
fm = getFragmentManager();
}
fm.beginTransaction().replace(R.id.settings_content, new GlobalConfigFragment()).commit();
getChildFragmentManager().beginTransaction().replace(R.id.settings_content, new GlobalConfigFragment()).commit();
}
@Override

View File

@ -1,10 +1,10 @@
package org.itxtech.daedalus.fragment;
import android.app.Fragment;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import com.google.android.material.navigation.NavigationView;
import org.itxtech.daedalus.R;

View File

@ -10,7 +10,7 @@ import okhttp3.OkHttpClient;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.service.DaedalusVpnService;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.server.DNSServerHelper;
import org.itxtech.daedalus.server.DnsServerHelper;
import org.minidns.dnsmessage.DnsMessage;
import org.pcap4j.packet.IpPacket;
import org.pcap4j.packet.IpSelector;
@ -58,8 +58,8 @@ abstract public class HttpsProvider extends Provider {
.header("Accept", accept)
.build()))
.dns(hostname -> {
if (DNSServerHelper.domainCache.containsKey(hostname)) {
return DNSServerHelper.domainCache.get(hostname);
if (DnsServerHelper.domainCache.containsKey(hostname)) {
return DnsServerHelper.domainCache.get(hostname);
}
return Arrays.asList(InetAddress.getAllByName(hostname));
})
@ -138,7 +138,7 @@ abstract public class HttpsProvider extends Provider {
return;
String uri;
try {
uri = service.dnsServers.get(destAddr.getHostAddress());//https uri
uri = service.dnsServers.get(destAddr.getHostAddress()).getAddress();//https uri
} catch (Exception e) {
Logger.logException(e);
return;
@ -161,7 +161,7 @@ abstract public class HttpsProvider extends Provider {
return;
}
if (dnsMsg.getQuestion() == null) {
Log.i(TAG, "handleDnsRequest: Discarding DNS packet with no query " + dnsMsg);
Logger.debug("handleDnsRequest: Discarding DNS packet with no query " + dnsMsg);
return;
}

View File

@ -15,7 +15,7 @@ import org.itxtech.daedalus.service.DaedalusVpnService;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
public class ProviderPicker {
public abstract class ProviderPicker {
public static final int DNS_QUERY_METHOD_UDP = 0;
public static final int DNS_QUERY_METHOD_TCP = 1;
public static final int DNS_QUERY_METHOD_TLS = 2;
@ -40,6 +40,6 @@ public class ProviderPicker {
}
public static int getDnsQueryMethod() {
return Integer.valueOf(Daedalus.getPrefs().getString("settings_dns_query_method", "0"));
return Integer.parseInt(Daedalus.getPrefs().getString("settings_dns_query_method", "0"));
}
}

View File

@ -9,7 +9,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
import org.itxtech.daedalus.service.DaedalusVpnService;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.server.DNSServerHelper;
import org.itxtech.daedalus.server.AbstractDnsServer;
import org.pcap4j.packet.IpPacket;
import java.io.*;
@ -123,7 +123,7 @@ public class TcpProvider extends UdpProvider {
}
@Override
protected void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket) throws DaedalusVpnService.VpnNetworkException {
protected void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket, AbstractDnsServer dnsServer) throws DaedalusVpnService.VpnNetworkException {
Socket dnsSocket;
try {
// Packets to be sent to the real DNS server will need to be protected from the VPN
@ -131,7 +131,7 @@ public class TcpProvider extends UdpProvider {
service.protect(dnsSocket);
SocketAddress address = new InetSocketAddress(outPacket.getAddress(), DNSServerHelper.getPortOrDefault(outPacket.getAddress(), outPacket.getPort()));
SocketAddress address = new InetSocketAddress(outPacket.getAddress(), dnsServer.getPort());
dnsSocket.connect(address, 5000);
dnsSocket.setSoTimeout(5000);
Logger.info("TcpProvider: Sending DNS query request");
@ -161,7 +161,7 @@ public class TcpProvider extends UdpProvider {
try {
DataInputStream stream = new DataInputStream(dnsSocket.getInputStream());
int length = stream.readUnsignedShort();
Log.d(TAG, "Reading length: " + String.valueOf(length));
Log.d(TAG, "Reading length: " + length);
byte[] data = new byte[length];
stream.read(data);
dnsSocket.close();

View File

@ -3,7 +3,7 @@ package org.itxtech.daedalus.provider;
import android.os.ParcelFileDescriptor;
import org.itxtech.daedalus.service.DaedalusVpnService;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.server.DNSServerHelper;
import org.itxtech.daedalus.server.AbstractDnsServer;
import org.pcap4j.packet.IpPacket;
import javax.net.ssl.SSLContext;
@ -28,13 +28,12 @@ public class TlsProvider extends TcpProvider{
}
@Override
protected void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket) {
protected void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket, AbstractDnsServer dnsServer) {
Socket dnsSocket;
try {
SSLContext context = SSLContext.getInstance("TLSv1.2");
context.init(null, null, null);
dnsSocket = context.getSocketFactory().createSocket(outPacket.getAddress(),
DNSServerHelper.getPortOrDefault(outPacket.getAddress(), outPacket.getPort()));
dnsSocket = context.getSocketFactory().createSocket(outPacket.getAddress(), dnsServer.getPort());
//Create TLS v1.2 socket
//TODO: SNI

View File

@ -9,7 +9,7 @@ import androidx.annotation.NonNull;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.service.DaedalusVpnService;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.server.DNSServerHelper;
import org.itxtech.daedalus.server.AbstractDnsServer;
import org.minidns.dnsmessage.DnsMessage;
import org.pcap4j.packet.IpPacket;
import org.pcap4j.packet.IpSelector;
@ -118,7 +118,7 @@ public class UdpProvider extends Provider {
}
}
protected void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket) throws DaedalusVpnService.VpnNetworkException {
protected void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket, AbstractDnsServer dnsServer) throws DaedalusVpnService.VpnNetworkException {
DatagramSocket dnsSocket;
try {
// Packets to be sent to the real DNS server will need to be protected from the VPN
@ -158,7 +158,6 @@ public class UdpProvider extends Provider {
*/
@Override
protected void handleDnsRequest(byte[] packetData) throws DaedalusVpnService.VpnNetworkException {
IpPacket parsedPacket;
try {
parsedPacket = (IpPacket) IpSelector.newPacket(packetData, 0, packetData.length);
@ -168,15 +167,21 @@ public class UdpProvider extends Provider {
}
if (!(parsedPacket.getPayload() instanceof UdpPacket)) {
Log.i(TAG, "handleDnsRequest: Discarding unknown packet type " + parsedPacket.getPayload());
try {
Logger.debug("handleDnsRequest: Discarding unknown packet type " + parsedPacket.getPayload());
} catch (Exception ignored) {
}
return;
}
InetAddress destAddr = parsedPacket.getHeader().getDstAddr();
if (destAddr == null)
if (destAddr == null) {
return;
}
AbstractDnsServer dnsServer;
try {
destAddr = InetAddress.getByName(service.dnsServers.get(destAddr.getHostAddress()));
dnsServer = service.dnsServers.get(destAddr.getHostAddress());
destAddr = InetAddress.getByName(dnsServer.getHostAddress());
} catch (Exception e) {
Logger.logException(e);
Logger.error("handleDnsRequest: DNS server alias query failed for " + destAddr.getHostAddress());
@ -191,9 +196,8 @@ public class UdpProvider extends Provider {
// Let's be nice to Firefox. Firefox uses an empty UDP packet to
// the gateway to reduce the RTT. For further details, please see
// https://bugzilla.mozilla.org/show_bug.cgi?id=888268
DatagramPacket outPacket = new DatagramPacket(new byte[0], 0, 0, destAddr,
DNSServerHelper.getPortOrDefault(destAddr, parsedUdp.getHeader().getDstPort().valueAsInt()));
forwardPacket(outPacket, null);
DatagramPacket outPacket = new DatagramPacket(new byte[0], 0, 0, destAddr, dnsServer.getPort());
forwardPacket(outPacket, null, dnsServer);
return;
}
@ -209,14 +213,13 @@ public class UdpProvider extends Provider {
return;
}
if (dnsMsg.getQuestion() == null) {
Log.i(TAG, "handleDnsRequest: Discarding DNS packet with no query " + dnsMsg);
Logger.debug("handleDnsRequest: Discarding DNS packet with no query " + dnsMsg);
return;
}
if (!resolve(parsedPacket, dnsMsg)) {
DatagramPacket outPacket = new DatagramPacket(dnsRawData, 0, dnsRawData.length, destAddr,
DNSServerHelper.getPortOrDefault(destAddr, parsedUdp.getHeader().getDstPort().valueAsInt()));
forwardPacket(outPacket, parsedPacket);
DatagramPacket outPacket = new DatagramPacket(dnsRawData, 0, dnsRawData.length, destAddr, dnsServer.getPort());
forwardPacket(outPacket, parsedPacket, dnsServer);
}
}

View File

@ -21,7 +21,7 @@ public class BootBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Daedalus.getPrefs().getBoolean("settings_boot", false)) {
Daedalus.activateService(context);
Daedalus.activateService(context, true);
Logger.info("Triggered boot receiver");
}
}

View File

@ -1,4 +1,6 @@
package org.itxtech.daedalus.util.server;
package org.itxtech.daedalus.server;
import androidx.annotation.NonNull;
/**
* Daedalus Project
@ -11,17 +13,26 @@ package org.itxtech.daedalus.util.server;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
public class AbstractDNSServer {
public class AbstractDnsServer implements Cloneable {
public static final int DNS_SERVER_DEFAULT_PORT = 53;
protected String address;
protected int port;
protected String hostAddress;
public AbstractDNSServer(String address, int port) {
public AbstractDnsServer(String address, int port) {
this.address = address;
this.port = port;
}
public void setHostAddress(String hostAddress) {
this.hostAddress = hostAddress;
}
public String getHostAddress() {
return hostAddress;
}
public void setAddress(String address) {
this.address = address;
}
@ -54,4 +65,14 @@ public class AbstractDNSServer {
public boolean isHttpsServer() {
return address.contains("/");
}
@NonNull
@Override
public Object clone() {
try {
return super.clone();
} catch (Exception ignored) {
}
return new AbstractDnsServer("", 0);
}
}

View File

@ -1,4 +1,4 @@
package org.itxtech.daedalus.util.server;
package org.itxtech.daedalus.server;
import org.itxtech.daedalus.Daedalus;
@ -13,11 +13,11 @@ import org.itxtech.daedalus.Daedalus;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
public class CustomDNSServer extends AbstractDNSServer {
public class CustomDnsServer extends AbstractDnsServer {
private String name;
private String id;
public CustomDNSServer(String name, String address, int port) {
public CustomDnsServer(String name, String address, int port) {
super(address, port);
this.name = name;
this.id = String.valueOf(Daedalus.configurations.getNextDnsId());

View File

@ -1,4 +1,4 @@
package org.itxtech.daedalus.util.server;
package org.itxtech.daedalus.server;
import android.content.Context;
import org.itxtech.daedalus.Daedalus;
@ -14,23 +14,27 @@ import org.itxtech.daedalus.Daedalus;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
public class DNSServer extends AbstractDNSServer {
public class DnsServer extends AbstractDnsServer {
private static int totalId = 0;
private String id;
private int description = 0;
private int description;
public DNSServer(String address, int description, int port) {
public DnsServer(String address, int description, int port) {
super(address, port);
this.id = String.valueOf(totalId++);
this.description = description;
}
public DNSServer(String address, int description) {
public DnsServer(String address, int description) {
this(address, description, DNS_SERVER_DEFAULT_PORT);
}
public DnsServer(String address) {
this(address, 0);
}
public String getId() {
return id;
}

View File

@ -1,4 +1,4 @@
package org.itxtech.daedalus.util.server;
package org.itxtech.daedalus.server;
import android.content.Context;
import android.net.Uri;
@ -25,31 +25,19 @@ import java.util.List;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
public class DNSServerHelper {
private static HashMap<String, Integer> portCache = new HashMap<>();
public class DnsServerHelper {
public static HashMap<String, List<InetAddress>> domainCache = new HashMap<>();
public static void clearCache() {
portCache = new HashMap<>();
domainCache = new HashMap<>();
}
public static void buildCache() {
domainCache = new HashMap<>();
portCache = new HashMap<>();
if (ProviderPicker.getDnsQueryMethod() >= ProviderPicker.DNS_QUERY_METHOD_HTTPS_IETF &&
!Daedalus.getPrefs().getBoolean("settings_dont_build_doh_cache", false)) {
buildDomainCache(getAddressById(getPrimary()));
buildDomainCache(getAddressById(getSecondary()));
}
for (DNSServer server : Daedalus.DNS_SERVERS) {
portCache.put(server.getAddress(), server.getPort());
}
for (CustomDNSServer server : Daedalus.configurations.getCustomDNSServers()) {
portCache.put(server.getAddress(), server.getPort());
!Daedalus.getPrefs().getBoolean("settings_dont_build_cache", false)) {
buildDomainCache(getServerById(getPrimary()).getAddress());
buildDomainCache(getServerById(getSecondary()).getAddress());
}
}
@ -63,16 +51,6 @@ public class DNSServerHelper {
}
}
public static int getPortOrDefault(InetAddress address, int defaultPort) {
String hostAddress = address.getHostAddress();
if (portCache.containsKey(hostAddress)) {
return portCache.get(hostAddress);
}
return defaultPort;
}
public static int getPosition(String id) {
int intId = Integer.parseInt(id);
if (intId < Daedalus.DNS_SERVERS.size()) {
@ -88,18 +66,18 @@ public class DNSServerHelper {
}
public static String getPrimary() {
return String.valueOf(DNSServerHelper.checkServerId(Integer.parseInt(Daedalus.getPrefs().getString("primary_server", "0"))));
return String.valueOf(DnsServerHelper.checkServerId(Integer.parseInt(Daedalus.getPrefs().getString("primary_server", "0"))));
}
public static String getSecondary() {
return String.valueOf(DNSServerHelper.checkServerId(Integer.parseInt(Daedalus.getPrefs().getString("secondary_server", "1"))));
return String.valueOf(DnsServerHelper.checkServerId(Integer.parseInt(Daedalus.getPrefs().getString("secondary_server", "1"))));
}
private static int checkServerId(int id) {
if (id < Daedalus.DNS_SERVERS.size()) {
return id;
}
for (CustomDNSServer server : Daedalus.configurations.getCustomDNSServers()) {
for (CustomDnsServer server : Daedalus.configurations.getCustomDNSServers()) {
if (server.getId().equals(String.valueOf(id))) {
return id;
}
@ -107,26 +85,26 @@ public class DNSServerHelper {
return 0;
}
public static String getAddressById(String id) {
for (DNSServer server : Daedalus.DNS_SERVERS) {
public static AbstractDnsServer getServerById(String id) {
for (DnsServer server : Daedalus.DNS_SERVERS) {
if (server.getId().equals(id)) {
return server.getAddress();
return server;
}
}
for (CustomDNSServer customDNSServer : Daedalus.configurations.getCustomDNSServers()) {
for (CustomDnsServer customDNSServer : Daedalus.configurations.getCustomDNSServers()) {
if (customDNSServer.getId().equals(id)) {
return customDNSServer.getAddress();
return customDNSServer;
}
}
return Daedalus.DNS_SERVERS.get(0).getAddress();
return Daedalus.DNS_SERVERS.get(0);
}
public static String[] getIds() {
ArrayList<String> servers = new ArrayList<>(Daedalus.DNS_SERVERS.size());
for (DNSServer server : Daedalus.DNS_SERVERS) {
for (DnsServer server : Daedalus.DNS_SERVERS) {
servers.add(server.getId());
}
for (CustomDNSServer customDNSServer : Daedalus.configurations.getCustomDNSServers()) {
for (CustomDnsServer customDNSServer : Daedalus.configurations.getCustomDNSServers()) {
servers.add(customDNSServer.getId());
}
String[] stringServers = new String[Daedalus.DNS_SERVERS.size()];
@ -135,30 +113,30 @@ public class DNSServerHelper {
public static String[] getNames(Context context) {
ArrayList<String> servers = new ArrayList<>(Daedalus.DNS_SERVERS.size());
for (DNSServer server : Daedalus.DNS_SERVERS) {
for (DnsServer server : Daedalus.DNS_SERVERS) {
servers.add(server.getStringDescription(context));
}
for (CustomDNSServer customDNSServer : Daedalus.configurations.getCustomDNSServers()) {
for (CustomDnsServer customDNSServer : Daedalus.configurations.getCustomDNSServers()) {
servers.add(customDNSServer.getName());
}
String[] stringServers = new String[Daedalus.DNS_SERVERS.size()];
return servers.toArray(stringServers);
}
public static ArrayList<AbstractDNSServer> getAllServers() {
ArrayList<AbstractDNSServer> servers = new ArrayList<>(Daedalus.DNS_SERVERS.size());
public static ArrayList<AbstractDnsServer> getAllServers() {
ArrayList<AbstractDnsServer> servers = new ArrayList<>(Daedalus.DNS_SERVERS.size());
servers.addAll(Daedalus.DNS_SERVERS);
servers.addAll(Daedalus.configurations.getCustomDNSServers());
return servers;
}
public static String getDescription(String id, Context context) {
for (DNSServer server : Daedalus.DNS_SERVERS) {
for (DnsServer server : Daedalus.DNS_SERVERS) {
if (server.getId().equals(id)) {
return server.getStringDescription(context);
}
}
for (CustomDNSServer customDNSServer : Daedalus.configurations.getCustomDNSServers()) {
for (CustomDnsServer customDNSServer : Daedalus.configurations.getCustomDNSServers()) {
if (customDNSServer.getId().equals(id)) {
return customDNSServer.getName();
}
@ -166,7 +144,7 @@ public class DNSServerHelper {
return Daedalus.DNS_SERVERS.get(0).getStringDescription(context);
}
public static boolean isInUsing(CustomDNSServer server) {
public static boolean isInUsing(CustomDnsServer server) {
return DaedalusVpnService.isActivated() && (server.getId().equals(getPrimary()) || server.getId().equals(getSecondary()));
}
}

View File

@ -4,14 +4,18 @@ import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.VpnService;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.system.OsConstants;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.NotificationCompat;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.R;
@ -19,9 +23,12 @@ import org.itxtech.daedalus.activity.MainActivity;
import org.itxtech.daedalus.provider.Provider;
import org.itxtech.daedalus.provider.ProviderPicker;
import org.itxtech.daedalus.receiver.StatusBarBroadcastReceiver;
import org.itxtech.daedalus.server.AbstractDnsServer;
import org.itxtech.daedalus.server.DnsServer;
import org.itxtech.daedalus.server.DnsServerHelper;
import org.itxtech.daedalus.util.DnsServersDetector;
import org.itxtech.daedalus.util.Logger;
import org.itxtech.daedalus.util.RuleResolver;
import org.itxtech.daedalus.util.server.DNSServerHelper;
import java.net.Inet4Address;
import java.net.Inet6Address;
@ -51,30 +58,71 @@ public class DaedalusVpnService extends VpnService implements Runnable {
private static final String CHANNEL_ID = "daedalus_channel_1";
private static final String CHANNEL_NAME = "daedalus_channel";
public static String primaryServer;
public static String secondaryServer;
public static AbstractDnsServer primaryServer;
public static AbstractDnsServer secondaryServer;
private static InetAddress aliasPrimary;
private static InetAddress aliasSecondary;
private NotificationCompat.Builder notification = null;
private boolean running = false;
private long lastUpdate = 0;
private boolean statisticQuery;
private Provider provider;
private ParcelFileDescriptor descriptor;
private Thread mThread = null;
public HashMap<String, String> dnsServers;
public HashMap<String, AbstractDnsServer> dnsServers;
private static boolean activated = false;
private static BroadcastReceiver receiver;
public static boolean isActivated() {
return activated;
}
private static int getPendingIntent(int flag) {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE | flag : flag;
}
@Override
public void onCreate() {
super.onCreate();
if (Daedalus.getPrefs().getBoolean("settings_use_system_dns", false)) {
registerReceiver(receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
updateUpstreamServers(context);
}
}, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
}
private static void updateUpstreamServers(Context context) {
String[] servers = DnsServersDetector.getServers(context);
if (servers != null) {
if (servers.length >= 2 && (aliasPrimary == null || !aliasPrimary.getHostAddress().equals(servers[0])) &&
(aliasSecondary == null || !aliasSecondary.getHostAddress().equals(servers[0])) &&
(aliasPrimary == null || !aliasPrimary.getHostAddress().equals(servers[1])) &&
(aliasSecondary == null || !aliasSecondary.getHostAddress().equals(servers[1]))) {
primaryServer.setAddress(servers[0]);
primaryServer.setPort(DnsServer.DNS_SERVER_DEFAULT_PORT);
secondaryServer.setAddress(servers[1]);
secondaryServer.setPort(DnsServer.DNS_SERVER_DEFAULT_PORT);
} else if ((aliasPrimary == null || !aliasPrimary.getHostAddress().equals(servers[0])) &&
(aliasSecondary == null || !aliasSecondary.getHostAddress().equals(servers[0]))) {
primaryServer.setAddress(servers[0]);
primaryServer.setPort(DnsServer.DNS_SERVER_DEFAULT_PORT);
secondaryServer.setAddress(servers[0]);
secondaryServer.setPort(DnsServer.DNS_SERVER_DEFAULT_PORT);
} else {
StringBuilder buf = new StringBuilder();
for (String server : servers) {
buf.append(server).append(" ");
}
Logger.error("Invalid upstream DNS " + buf);
}
Logger.info("Upstream DNS updated: " + primaryServer.getAddress() + " " + secondaryServer.getAddress());
} else {
Logger.error("Cannot obtain upstream DNS server!");
}
}
@Override
@ -84,7 +132,6 @@ public class DaedalusVpnService extends VpnService implements Runnable {
case ACTION_ACTIVATE:
activated = true;
if (Daedalus.getPrefs().getBoolean("settings_notification", true)) {
NotificationManager manager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder;
@ -101,7 +148,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
Intent settingsIntent = new Intent(StatusBarBroadcastReceiver.STATUS_BAR_BTN_SETTINGS_CLICK_ACTION);
settingsIntent.setClass(this, StatusBarBroadcastReceiver.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
new Intent(this, MainActivity.class), getPendingIntent(PendingIntent.FLAG_UPDATE_CURRENT));
builder.setWhen(0)
.setContentTitle(getResources().getString(R.string.notice_activated))
.setDefaults(NotificationCompat.DEFAULT_LIGHTS)
@ -113,10 +160,10 @@ public class DaedalusVpnService extends VpnService implements Runnable {
.setContentIntent(pIntent)
.addAction(R.drawable.ic_clear, getResources().getString(R.string.button_text_deactivate),
PendingIntent.getBroadcast(this, 0,
deactivateIntent, PendingIntent.FLAG_UPDATE_CURRENT))
deactivateIntent, getPendingIntent(PendingIntent.FLAG_UPDATE_CURRENT)))
.addAction(R.drawable.ic_settings, getResources().getString(R.string.action_settings),
PendingIntent.getBroadcast(this, 0,
settingsIntent, PendingIntent.FLAG_UPDATE_CURRENT));
settingsIntent, getPendingIntent(PendingIntent.FLAG_UPDATE_CURRENT)));
Notification notification = builder.build();
@ -126,12 +173,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
}
Daedalus.initRuleResolver();
if (this.mThread == null) {
this.mThread = new Thread(this, "DaedalusVpn");
this.running = true;
this.mThread.start();
}
startThread();
Daedalus.updateShortcut(getApplicationContext());
if (MainActivity.getInstance() != null) {
MainActivity.getInstance().startActivity(new Intent(getApplicationContext(), MainActivity.class)
@ -146,9 +188,21 @@ public class DaedalusVpnService extends VpnService implements Runnable {
return START_NOT_STICKY;
}
private void startThread() {
if (this.mThread == null) {
this.mThread = new Thread(this, "DaedalusVpn");
this.running = true;
this.mThread.start();
}
}
@Override
public void onDestroy() {
stopThread();
if (receiver != null) {
unregisterReceiver(receiver);
receiver = null;
}
}
private void stopThread() {
@ -185,7 +239,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
if (shouldRefresh) {
RuleResolver.clear();
DNSServerHelper.clearCache();
DnsServerHelper.clearCache();
Logger.info("Daedalus VPN service has stopped");
}
@ -202,27 +256,30 @@ public class DaedalusVpnService extends VpnService implements Runnable {
stopThread();
}
private InetAddress addDnsServer(Builder builder, String format, byte[] ipv6Template, String addr) throws UnknownHostException {
private InetAddress addDnsServer(Builder builder, String format, byte[] ipv6Template, AbstractDnsServer addr)
throws UnknownHostException {
int size = dnsServers.size();
size++;
if (addr.contains("/")) {//https uri
if (addr.getAddress().contains("/")) {//https uri
String alias = String.format(format, size + 1);
dnsServers.put(alias, addr);
builder.addRoute(alias, 32);
return InetAddress.getByName(alias);
}
InetAddress address = InetAddress.getByName(addr);
InetAddress address = InetAddress.getByName(addr.getAddress());
if (address instanceof Inet6Address && ipv6Template == null) {
Log.i(TAG, "addDnsServer: Ignoring DNS server " + address);
} else if (address instanceof Inet4Address) {
String alias = String.format(format, size + 1);
dnsServers.put(alias, address.getHostAddress());
addr.setHostAddress(address.getHostAddress());
dnsServers.put(alias, addr);
builder.addRoute(alias, 32);
return InetAddress.getByName(alias);
} else if (address instanceof Inet6Address) {
ipv6Template[ipv6Template.length - 1] = (byte) (size + 1);
InetAddress i6addr = Inet6Address.getByAddress(ipv6Template);
dnsServers.put(i6addr.getHostAddress(), address.getHostAddress());
addr.setHostAddress(address.getHostAddress());
dnsServers.put(i6addr.getHostAddress(), addr);
return i6addr;
}
return null;
@ -231,14 +288,13 @@ public class DaedalusVpnService extends VpnService implements Runnable {
@Override
public void run() {
try {
DNSServerHelper.buildCache();
DnsServerHelper.buildCache();
Builder builder = new Builder()
.setSession("Daedalus")
.setConfigureIntent(PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class).putExtra(MainActivity.LAUNCH_FRAGMENT, MainActivity.FRAGMENT_SETTINGS),
PendingIntent.FLAG_ONE_SHOT));
getPendingIntent(PendingIntent.FLAG_ONE_SHOT)));
//Set App Filter
if (Daedalus.getPrefs().getBoolean("settings_app_filter_switch", false)) {
ArrayList<String> apps = Daedalus.configurations.getAppObjects();
if (apps.size() > 0) {
@ -275,36 +331,28 @@ public class DaedalusVpnService extends VpnService implements Runnable {
statisticQuery = Daedalus.getPrefs().getBoolean("settings_count_query_times", false);
byte[] ipv6Template = new byte[]{32, 1, 13, (byte) (184 & 0xFF), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
if (primaryServer.contains(":") || secondaryServer.contains(":")) {//IPv6
try {
InetAddress addr = Inet6Address.getByAddress(ipv6Template);
Log.d(TAG, "configure: Adding IPv6 address" + addr);
builder.addAddress(addr, 120);
} catch (Exception e) {
Logger.logException(e);
try {
InetAddress addr = Inet6Address.getByAddress(ipv6Template);
Log.d(TAG, "configure: Adding IPv6 address" + addr);
builder.addAddress(addr, 120);
} catch (Exception e) {
Logger.logException(e);
ipv6Template = null;
}
} else {
ipv6Template = null;
}
InetAddress aliasPrimary;
InetAddress aliasSecondary;
if (advanced) {
dnsServers = new HashMap<>();
aliasPrimary = addDnsServer(builder, format, ipv6Template, primaryServer);
aliasSecondary = addDnsServer(builder, format, ipv6Template, secondaryServer);
} else {
aliasPrimary = InetAddress.getByName(primaryServer);
aliasSecondary = InetAddress.getByName(secondaryServer);
aliasPrimary = InetAddress.getByName(primaryServer.getAddress());
aliasSecondary = InetAddress.getByName(secondaryServer.getAddress());
}
InetAddress primaryDNSServer = aliasPrimary;
InetAddress secondaryDNSServer = aliasSecondary;
Logger.info("Daedalus VPN service is listening on " + primaryServer + " as " + primaryDNSServer.getHostAddress());
Logger.info("Daedalus VPN service is listening on " + secondaryServer + " as " + secondaryDNSServer.getHostAddress());
builder.addDnsServer(primaryDNSServer).addDnsServer(secondaryDNSServer);
Logger.info("Daedalus VPN service is listening on " + primaryServer.getAddress() + " as " + aliasPrimary.getHostAddress());
Logger.info("Daedalus VPN service is listening on " + secondaryServer.getAddress() + " as " + aliasSecondary.getHostAddress());
builder.addDnsServer(aliasPrimary).addDnsServer(aliasSecondary);
if (advanced) {
builder.setBlocking(true);
@ -324,13 +372,17 @@ public class DaedalusVpnService extends VpnService implements Runnable {
Thread.sleep(1000);
}
}
} catch (
InterruptedException ignored) {
} catch (
Exception e) {
} catch (InterruptedException ignored) {
} catch (Exception e) {
MainActivity.getInstance().runOnUiThread(() ->
new AlertDialog.Builder(MainActivity.getInstance())
.setTitle(R.string.error_occurred)
.setMessage(Logger.getExceptionMessage(e))
.setPositiveButton(android.R.string.ok, (d, id) -> {
})
.show());
Logger.logException(e);
} finally {
Log.d(TAG, "quit");
stopThread();
}
}
@ -346,14 +398,13 @@ public class DaedalusVpnService extends VpnService implements Runnable {
if (time - lastUpdate >= 1000) {
lastUpdate = time;
if (notification != null) {
notification.setContentTitle(getResources().getString(R.string.notice_queries) + " " + String.valueOf(provider.getDnsQueryTimes()));
notification.setContentTitle(getResources().getString(R.string.notice_queries) + " " + provider.getDnsQueryTimes());
NotificationManager manager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(NOTIFICATION_ACTIVATED, notification.build());
}
}
}
public static class VpnNetworkException extends Exception {
public VpnNetworkException(String s) {
super(s);
@ -362,7 +413,5 @@ public class DaedalusVpnService extends VpnService implements Runnable {
public VpnNetworkException(String s, Throwable t) {
super(s, t);
}
}
}

View File

@ -3,7 +3,7 @@ package org.itxtech.daedalus.util;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import org.itxtech.daedalus.Daedalus;
import org.itxtech.daedalus.util.server.CustomDNSServer;
import org.itxtech.daedalus.server.CustomDnsServer;
import java.io.File;
import java.io.FileReader;
@ -27,7 +27,7 @@ public class Configurations {
private static File file;
private ArrayList<CustomDNSServer> customDNSServers;
private ArrayList<CustomDnsServer> customDNSServers;
private ArrayList<String> appObjects;
private ArrayList<Rule> hostsRules;
@ -60,7 +60,7 @@ public class Configurations {
this.activateCounter = activateCounter;
}
public ArrayList<CustomDNSServer> getCustomDNSServers() {
public ArrayList<CustomDnsServer> getCustomDNSServers() {
if (customDNSServers == null) {
customDNSServers = new ArrayList<>();
}

View File

@ -0,0 +1,166 @@
package org.itxtech.daedalus.util;
import android.content.Context;
import android.net.*;
import android.os.Build;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Daedalus Project
*
* @author iTX Technologies
* @link https://itxtech.org
* <p>
* This program 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.
*/
public class DnsServersDetector {
//https://stackoverflow.com/a/48973823
private static final String METHOD_EXEC_PROP_DELIM = "]: [";
public static String[] getServers(Context context) {
String[] result;
result = getServersMethodSystemProperties();
if (result != null && result.length > 0) {
return result;
}
result = getServersMethodConnectivityManager(context);
if (result != null && result.length > 0) {
return result;
}
result = getServersMethodExec();
if (result != null && result.length > 0) {
return result;
}
return null;
}
private static String[] getServersMethodConnectivityManager(Context context) {
ArrayList<String> priorityServersArrayList = new ArrayList<>();
ArrayList<String> serversArrayList = new ArrayList<>();
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
for (Network network : connectivityManager.getAllNetworks()) {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
if (networkInfo.isConnected()) {
LinkProperties linkProperties = connectivityManager.getLinkProperties(network);
List<InetAddress> dnsServersList = linkProperties.getDnsServers();
if (linkPropertiesHasDefaultRoute(linkProperties)) {
for (InetAddress element : dnsServersList) {
String dnsHost = element.getHostAddress();
priorityServersArrayList.add(dnsHost);
}
} else {
for (InetAddress element : dnsServersList) {
String dnsHost = element.getHostAddress();
serversArrayList.add(dnsHost);
}
}
}
}
}
if (priorityServersArrayList.isEmpty()) {
priorityServersArrayList.addAll(serversArrayList);
}
if (priorityServersArrayList.size() > 0) {
return priorityServersArrayList.toArray(new String[0]);
}
return null;
}
private static String[] getServersMethodSystemProperties() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
String re1 = "^\\d+(\\.\\d+){3}$";
String re2 = "^[0-9a-f]+(:[0-9a-f]*)+:[0-9a-f]+$";
ArrayList<String> serversArrayList = new ArrayList<>();
try {
Class SystemProperties = Class.forName("android.os.SystemProperties");
Method method = SystemProperties.getMethod("get", new Class[]{String.class});
String[] netdns = new String[]{"net.dns1", "net.dns2", "net.dns3", "net.dns4"};
for (String dns : netdns) {
Object[] args = new Object[]{dns};
String v = (String) method.invoke(null, args);
if (v != null && (v.matches(re1) || v.matches(re2)) && !serversArrayList.contains(v)) {
serversArrayList.add(v);
}
}
if (serversArrayList.size() > 0) {
return serversArrayList.toArray(new String[0]);
}
} catch (Exception ex) {
Logger.logException(ex);
}
}
return null;
}
private static String[] getServersMethodExec() {
try {
Process process = Runtime.getRuntime().exec("getprop");
InputStream inputStream = process.getInputStream();
LineNumberReader lineNumberReader = new LineNumberReader(new InputStreamReader(inputStream));
Set<String> serversSet = methodExecParseProps(lineNumberReader);
if (serversSet.size() > 0) {
return serversSet.toArray(new String[0]);
}
} catch (Exception ex) {
Logger.logException(ex);
}
return null;
}
private static Set<String> methodExecParseProps(BufferedReader lineNumberReader) throws Exception {
String line;
HashSet<String> serversSet = new HashSet<>();
while ((line = lineNumberReader.readLine()) != null) {
int split = line.indexOf(METHOD_EXEC_PROP_DELIM);
if (split == -1) {
continue;
}
String property = line.substring(1, split);
int valueStart = split + METHOD_EXEC_PROP_DELIM.length();
int valueEnd = line.length() - 1;
if (valueEnd < valueStart) {
continue;
}
String value = line.substring(valueStart, valueEnd);
if (value.isEmpty()) {
continue;
}
if (property.endsWith(".dns") || property.endsWith(".dns1") || property.endsWith(".dns2") ||
property.endsWith(".dns3") || property.endsWith(".dns4")) {
InetAddress ip = InetAddress.getByName(value);
if (ip == null) {
continue;
}
value = ip.getHostAddress();
if (value == null || value.length() == 0) {
continue;
}
serversSet.add(value);
}
}
return serversSet;
}
private static boolean linkPropertiesHasDefaultRoute(LinkProperties linkProperties) {
for (RouteInfo route : linkProperties.getRoutes()) {
if (route.isDefaultRoute()) {
return true;
}
}
return false;
}
}

View File

@ -108,7 +108,7 @@ public class RuleResolver implements Runnable {
for (String hostsFile : hostsFiles) {
File file = new File(hostsFile);
if (file.canRead()) {
Logger.info("Loading hosts from " + file.toString());
Logger.info("Loading hosts from " + file);
FileInputStream stream = new FileInputStream(file);
BufferedReader dataIO = new BufferedReader(new InputStreamReader(stream));
String strLine;
@ -136,7 +136,7 @@ public class RuleResolver implements Runnable {
for (String dnsmasqFile : dnsmasqFiles) {
File file = new File(dnsmasqFile);
if (file.canRead()) {
Logger.info("Loading DNSMasq configuration from " + file.toString());
Logger.info("Loading DNSMasq configuration from " + file);
FileInputStream stream = new FileInputStream(file);
BufferedReader dataIO = new BufferedReader(new InputStreamReader(stream));
String strLine;
@ -145,7 +145,12 @@ public class RuleResolver implements Runnable {
while ((strLine = dataIO.readLine()) != null) {
if (!strLine.equals("") && !strLine.startsWith("#")) {
data = strLine.split("/");
if (data.length == 3 && data[0].equals("address=")) {
if (data.length >= 2 && data[0].equals("address=")) {
if (data.length == 2) {
rulesA.put(data[1], "0.0.0.0");
count++;
continue;
}
if (data[1].startsWith(".")) {
data[1] = data[1].substring(1);
}
@ -153,6 +158,8 @@ public class RuleResolver implements Runnable {
rulesAAAA.put(data[1], data[2]);
} else if (strLine.contains(".")) {//IPv4
rulesA.put(data[1], data[2]);
} else {
rulesA.put(data[1], "0.0.0.0");
}
count++;
}

View File

@ -1,7 +1,7 @@
package org.itxtech.daedalus.widget;
import android.content.Context;
import android.preference.ListPreference;
import androidx.preference.ListPreference;
import android.util.AttributeSet;
/**

View File

@ -25,7 +25,6 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</androidx.recyclerview.widget.RecyclerView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,32 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/app_icon"
android:layout_width="46dp"
android:layout_height="46dp"
android:paddingEnd="10dp"
android:paddingLeft="14dp"
android:paddingRight="10dp"
android:paddingStart="14dp" />
android:id="@+id/app_icon"
android:layout_width="46dp"
android:layout_height="46dp"
android:paddingEnd="10dp"
android:paddingStart="14dp"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/app_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
android:id="@+id/app_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"/>
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/app_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:paddingEnd="6dp"
android:paddingLeft="2dp"
android:paddingRight="6dp"
android:paddingStart="2dp" />
android:id="@+id/app_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:paddingEnd="6dp"
android:paddingStart="2dp"/>
</LinearLayout>
</LinearLayout>

View File

@ -14,47 +14,39 @@
app:cardPreventCornerOverlap="true"
android:id="@+id/cardView_indicator">
<LinearLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:orientation="vertical"
android:background="?android:attr/selectableItemBackground">
<RelativeLayout
android:background="?android:attr/selectableItemBackground"
android:layout_marginStart="@dimen/margin_small">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_small"
android:layout_marginLeft="@dimen/margin_small">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_small"
android:id="@+id/textView_rule_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView_rule_name"
android:padding="@dimen/margin_small"
android:id="@+id/textView_rule_detail"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView android:id="@+id/textView_rule_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:padding="@dimen/margin_small"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</RelativeLayout>
</LinearLayout>
android:padding="@dimen/margin_small"
android:id="@+id/textView_rule_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView_rule_name"
android:padding="@dimen/margin_small"
android:id="@+id/textView_rule_detail"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"/>
<TextView
android:id="@+id/textView_rule_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:padding="@dimen/margin_small"
android:layout_alignParentEnd="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</FrameLayout>
</FrameLayout>

View File

@ -5,6 +5,7 @@
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="10dp"
app:cardPreventCornerOverlap="true"
@ -23,7 +24,6 @@
android:id="@+id/textView_custom_dns_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
android:layout_width="match_parent"
@ -34,8 +34,7 @@
android:id="@+id/textView_custom_dns_address"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView>

View File

@ -11,7 +11,6 @@
android:layout_height="match_parent"
android:scrollbars="horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
@ -23,4 +22,4 @@
android:src="@drawable/ic_note_add"
android:tint="#FFFFFF"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -41,18 +41,15 @@
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:id="@+id/button_start_test"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"/>
android:layout_alignParentEnd="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button_start_test"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="10dp"
android:id="@+id/textView_test_info"
android:textIsSelectable="true"
android:textSize="18sp"/>
</RelativeLayout>
</ScrollView>
</ScrollView>

View File

@ -13,7 +13,6 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="org.itxtech.daedalus.fragment.HomeFragment">
<ImageView
android:contentDescription="icon"
android:id="@+id/imageView_icon"
android:layout_width="0dp"
android:layout_height="0dp"
@ -21,7 +20,7 @@
app:srcCompat="@mipmap/ic_launcher"
app:layout_widthPercent="40%"
app:layout_heightPercent="20%"
app:layout_marginTopPercent="5%"
app:layout_marginTopPercent="10%"
android:layout_alignParentTop="true" android:layout_centerHorizontal="true"/>
<TextView
android:text="@string/app_name"
@ -33,21 +32,12 @@
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
android:fontFamily="sans-serif"
android:layout_centerHorizontal="true" android:id="@+id/textView_app_name"/>
<TextView
android:text="@string/notice_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView_notice"
app:layout_marginTopPercent="5%"
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
android:fontFamily="sans-serif"
android:layout_below="@+id/textView_app_name" android:layout_centerHorizontal="true"/>
<Button
android:text="@string/button_text_activate"
android:textSize="15sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button_activate"
app:layout_marginTopPercent="10%"
android:layout_alignTop="@+id/textView_notice" android:layout_centerHorizontal="true"/>
app:layout_marginTopPercent="15%"
android:layout_alignTop="@+id/textView_app_name" android:layout_centerHorizontal="true"/>
</androidx.percentlayout.widget.PercentRelativeLayout>

View File

@ -11,7 +11,6 @@
android:layout_height="match_parent"
android:scrollbars="horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
@ -23,4 +22,4 @@
android:src="@drawable/ic_note_add"
android:tint="#FFFFFF"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,20 +0,0 @@
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
</style>
<style name="AppTheme.NoActionBar.TransparentStatusBar">
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
<style name="AppTheme.Dark.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
</style>
<style name="AppTheme.Dark.NoActionBar.TransparentStatusBar">
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>

View File

@ -3,7 +3,6 @@
<string name="app_name">Daedalus</string>
<string name="quick_toggle">开关</string>
<string name="notice_main">世界很大,我要去看看。</string>
<string name="notice_activated">已启用 iTXTech Daedalus。</string>
<string name="notice_start_test">正在测试指定的 DNS 服务器……</string>
<string name="notice_queries">DNS 查询次数:</string>
@ -63,9 +62,11 @@
<string name="settings_manual_summary">访问 GitHub wiki 页面。</string>
<string name="settings_log_size">日志大小限制</string>
<string name="settings_debug_output">调试输出</string>
<string name="settings_dont_build_doh_cache">不缓存 DoH DNS 的 IP地址</string>
<string name="settings_dont_build_cache">不缓存 DNS 的 IP地址</string>
<string name="settings_dark_theme">使用暗主题</string>
<string name="settings_dns_query_method">DNS 查询方式</string>
<string name="settings_foreground">运行前台服务</string>
<string name="settings_use_system_dns">使用系統DNS作為上游DNS</string>
<string name="settings_rule_name">规则名称</string>
<string name="settings_rule_type">规则类型</string>
@ -103,4 +104,6 @@
<string name="test_test_domain">google.com</string>
<string name="nav_version">版本:</string>
<string name="error_occurred">启动时出现了一个错误</string>
</resources>

View File

@ -3,7 +3,6 @@
<string name="app_name">Daedalus</string>
<string name="quick_toggle">开关</string>
<string name="notice_main">世界很大,我要去看看。</string>
<string name="notice_activated">已啟動 iTXTech Daedalus。</string>
<string name="notice_start_test">正在測試指定的 DNS 伺服器……</string>
<string name="notice_queries">DNS 查詢次數:</string>
@ -63,7 +62,7 @@
<string name="settings_manual_summary">造訪 GitHub wiki 頁面。</string>
<string name="settings_log_size">紀錄檔大小限制</string>
<string name="settings_debug_output">调试输出 TODO</string>
<string name="settings_dont_build_doh_cache">不緩存 DoH DNS 的 IP地址</string>
<string name="settings_dont_build_cache">不緩存 DNS 的 IP地址</string>
<string name="settings_dark_theme">使用暗主题</string>
<string name="settings_rule_name">規則名稱</string>
@ -76,6 +75,7 @@
<string name="settings_rule_import_built_in">内置</string>
<string name="settings_rule_import_external">外部</string>
<string name="settings_dns_query_method">DNS 查询方式</string>
<string name="settings_foreground">運行前臺服務</string>
<string name="settings_server_name">伺服器名稱</string>
<string name="settings_server_address">伺服器網址</string>
@ -101,4 +101,6 @@
<string name="test_test_domain">google.com</string>
<string name="nav_version">版本:</string>
<string name="error_occurred">啟動時出現了一個錯誤</string>
</resources>

View File

@ -2,7 +2,6 @@
<string name="app_name">Daedalus</string>
<string name="quick_toggle">Toggle</string>
<string name="notice_main">See the world outside.</string>
<string name="notice_activated">iTXTech Daedalus is activated.</string>
<string name="notice_start_test">Testing specified DNS server…</string>
<string name="notice_queries">DNS query times:</string>
@ -61,10 +60,12 @@
<string name="settings_log_size">Log Size Limit</string>
<string name="settings_manual">Manual</string>
<string name="settings_manual_summary">Visit GitHub wiki page.</string>
<string name="settings_dont_build_doh_cache">Don\'t build DNS Cache for DoH DNS</string>
<string name="settings_dont_build_cache">Don\'t cache IP for DNS servers</string>
<string name="settings_debug_output">Debug Output</string>
<string name="settings_dark_theme">Use Dark Theme</string>
<string name="settings_dns_query_method">DNS Query Method</string>
<string name="settings_foreground">Run service in Foreground</string>
<string name="settings_use_system_dns">Use System DNS as upstream DNS</string>
<string name="settings_dns_tcp">TCP</string>
<string name="settings_dns_udp">UDP</string>
@ -111,4 +112,6 @@
<string name="nav_version">Version:</string>
<string name="nav_git_commit">Git commit:</string>
<string name="nav_github">GitHub</string>
<string name="error_occurred">An error occurred at startup</string>
</resources>

View File

@ -1,8 +1,5 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
@ -12,15 +9,25 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimaryLight</item>
</style>
<style name="AppTheme.NoActionBar">
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
</style>
<style name="AppTheme.Dark.NoActionBar">
<style name="AppTheme.Dark.NoActionBar" parent="AppTheme.Dark">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
<style name="AppTheme.NoActionBar.TransparentStatusBar" parent="AppTheme.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
<style name="AppTheme.Dark.NoActionBar.TransparentStatusBar" parent="AppTheme.Dark.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>

View File

@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<EditTextPreference
android:key="ruleName"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/settings_rule_name"/>
<PreferenceCategory
app:iconSpaceReserved="false"
android:key="rulSettings"
android:title="@string/settings_rule">
<ListPreference
@ -27,7 +30,9 @@
android:key="ruleSync"
android:title="@string/settings_rule_sync"/>
</PreferenceCategory>
<PreferenceCategory
app:iconSpaceReserved="false"
android:key="Import"
android:title="@string/settings_rule_import">
<ListPreference
@ -37,4 +42,4 @@
android:key="ruleImportExternal"
android:title="@string/settings_rule_import_external"/>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View File

@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<EditTextPreference
android:key="serverName"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/settings_server_name"/>
<PreferenceCategory
app:iconSpaceReserved="false"
android:key="serverSettings"
android:title="@string/settings_server">
<EditTextPreference
@ -20,4 +23,4 @@
android:numeric="integer"
android:title="@string/settings_server_port"/>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
app:iconSpaceReserved="false"
android:key="settingsServer"
android:title="@string/settings_server">
@ -10,7 +11,6 @@
android:title="@string/primary_server"
android:defaultValue="0">
</ListPreference>
<ListPreference
android:key="secondary_server"
android:title="@string/secondary_server"
@ -23,7 +23,9 @@
android:singleLine="true"
android:title="@string/settings_dns_test_servers"/>
</PreferenceCategory>
<PreferenceCategory
app:iconSpaceReserved="false"
android:key="settings_system"
android:title="@string/settings_system">
@ -39,6 +41,10 @@
android:key="settings_dark_theme"
android:title="@string/settings_dark_theme"
android:defaultValue="false"/>
<SwitchPreference
android:key="settings_foreground"
android:title="@string/settings_foreground"
android:defaultValue="false"/>
<EditTextPreference
android:key="settings_log_size"
android:selectAllOnFocus="false"
@ -49,25 +55,27 @@
</PreferenceCategory>
<PreferenceCategory
android:key="settings_app_filter"
android:title="@string/settings_app_filter">
app:iconSpaceReserved="false"
android:key="settings_app_filter"
android:title="@string/settings_app_filter">
<SwitchPreference
android:key="settings_app_filter_switch"
android:title="@string/settings_app_filter"
android:defaultValue="false"/>
android:key="settings_app_filter_switch"
android:title="@string/settings_app_filter"
android:defaultValue="false"/>
<SwitchPreference
android:key="settings_app_filter_mode_switch"
android:title="@string/settings_app_filter_mode"
android:defaultValue="false"
android:enabled="false"/>
android:key="settings_app_filter_mode_switch"
android:title="@string/settings_app_filter_mode"
android:defaultValue="false"
android:enabled="false"/>
<org.itxtech.daedalus.widget.ClickPreference
android:key="settings_app_filter_list"
android:title="@string/settings_app_filter_list"
android:summary="@string/settings_app_filter_list_summary"
android:enabled="false"/>
android:key="settings_app_filter_list"
android:title="@string/settings_app_filter_list"
android:summary="@string/settings_app_filter_list_summary"
android:enabled="false"/>
</PreferenceCategory>
<PreferenceCategory
app:iconSpaceReserved="false"
android:key="settings_advanced"
android:title="@string/settings_advanced">
<SwitchPreference
@ -80,10 +88,14 @@
android:defaultValue="false"
android:enabled="false"/>
<SwitchPreference
android:key="settings_dont_build_doh_cache"
android:title="@string/settings_dont_build_doh_cache"
android:key="settings_dont_build_cache"
android:title="@string/settings_dont_build_cache"
android:defaultValue="false"
android:enabled="false"/>
<SwitchPreference
android:key="settings_use_system_dns"
android:title="@string/settings_use_system_dns"
android:defaultValue="false"/>
<ListPreference
android:key="settings_dns_query_method"
android:title="@string/settings_dns_query_method"
@ -100,6 +112,7 @@
</PreferenceCategory>
<PreferenceCategory
app:iconSpaceReserved="false"
android:key="settings_help"
android:title="@string/settings_help_and_support">
<org.itxtech.daedalus.widget.ClickPreference
@ -118,4 +131,4 @@
android:title="@string/settings_manual"
android:summary="@string/settings_manual_summary"/>
</PreferenceCategory>
</PreferenceScreen>
</androidx.preference.PreferenceScreen>

View File

@ -11,7 +11,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'io.fabric.tools:gradle:1.28.1'
classpath 'io.fabric.tools:gradle:1.31.0'
}
}

Binary file not shown.

View File

@ -1,6 +1,5 @@
#Wed Aug 23 01:02:45 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-5.5.1-bin.zip

290
gradlew vendored
View File

@ -1,78 +1,129 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn ( ) {
warn () {
echo "$*"
}
} >&2
die ( ) {
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@ -89,84 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save ( ) {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

43
gradlew.bat vendored
View File

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

View File

@ -0,0 +1,5 @@
Changes:
* Support SDK 31
* Support more DNSMasq rules
* Many optimizations
* Initial F-Droid release

View File

@ -0,0 +1,22 @@
This application can create a VPN tunnel to modify the DNS settings on Android.
Features
* No root access required, no ads contained
* Functional under data connection
* A tester for DNS servers
* IPv6 support (including Rules!)
* Custom DNS server
* Custom hosts and DNSMasq configuration
* EXTREME LOW power consume
* Material Design
Supported DNS Query Methods:
* UDP
* TCP
* DNS over TLS (RFC7858)
* DNS over HTTPS (RFC8484)
* DNS over HTTPS (Google JSON)
Users must comply with local laws and regulations.
Read more: <a href="https://github.com/iTXTech/Daedalus/wiki">Wiki</a>

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -0,0 +1 @@
No root required Android DNS modifier and Hosts/DNSMasq resolver