Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #1387

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ android {
applicationId "dev.ukanth.ufirewall"
//applicationId "dev.ukanth.ufirewall.donate"
minSdkVersion 21
targetSdkVersion 34
versionCode 20240606
versionName "3.6.1"
//buildConfigField 'boolean', 'DONATE', 'true'
buildConfigField 'boolean', 'DONATE', 'false'
}

buildFeatures {
Expand Down
34 changes: 14 additions & 20 deletions app/src/main/java/dev/ukanth/ufirewall/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ public final class Api {
* special application UID used for dnsmasq DHCP/DNS
*/
public static final int SPECIAL_UID_TETHER = -12;
/** special application UID used for netd DNS proxy */
//public static final int SPECIAL_UID_DNSPROXY = -13;

/**
* special application UID used for NTP
*/
Expand Down Expand Up @@ -435,24 +434,12 @@ private static void addRulesForUidlist(List<String> cmds, List<Integer> uids, St
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p udp --dport 53", action);
}*/

String pref = G.dns_proxy();

if (whitelist) {
if (pref.equals("disable")) {
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p udp --dport 53", " -j " + AFWALL_CHAIN_NAME + "-reject");
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p tcp --dport 53", " -j " + AFWALL_CHAIN_NAME + "-reject");
} else {
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p udp --dport 53", " -j RETURN");
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p tcp --dport 53", " -j RETURN");
}
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p udp --dport 53", " -j RETURN");
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p tcp --dport 53", " -j RETURN");
} else {
if (pref.equals("disable")) {
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p udp --dport 53", " -j " + AFWALL_CHAIN_NAME + "-reject");
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p tcp --dport 53", " -j " + AFWALL_CHAIN_NAME + "-reject");
} else if (pref.equals("enable")) {
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p udp --dport 53", " -j RETURN");
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p tcp --dport 53", " -j RETURN");
}
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p udp --dport 53", " -j RETURN");
addRuleForUsers(cmds, new String[]{"root"}, "-A " + chain + " -p tcp --dport 53", " -j RETURN");
}


Expand All @@ -462,7 +449,7 @@ private static void addRulesForUidlist(List<String> cmds, List<Integer> uids, St
}


if (G.getPrivateDnsStatus() && !G.dns_proxy().equals("disable")) {
if (G.getPrivateDnsStatus()) {
cmds.add("-A " + chain + " -p tcp --dport 853" + " -j ACCEPT");
// disabling HTTPS over DNS
//cmds.add("-A " + chain + " -p tcp --dport 443" + " -j ACCEPT");
Expand All @@ -484,6 +471,13 @@ private static void addRulesForUidlist(List<String> cmds, List<Integer> uids, St
cmds.add("-A " + chain + " -j " + AFWALL_CHAIN_NAME + "-reject");
}
}

//add 1052 for LAN
if(G.enableLAN()) {
cmds.add("-A " + "afwall-wifi-lan" + " -m owner --uid-owner 1052 -j RETURN");
}

cmds.add("-A " + "afwall-wifi-wan" + " -m owner --uid-owner 1052 -j RETURN");
}
}

Expand Down Expand Up @@ -785,7 +779,7 @@ private static boolean applyIptablesRulesImpl(final Context ctx, RuleDataSet rul

// NOTE: we still need to open a hole to let WAN-only UIDs talk to a DNS server
// on the LAN
if (whitelist && !G.dns_proxy().equals("disable")) {
if (whitelist) {
cmds.add("-A " + AFWALL_CHAIN_NAME + "-wifi-lan -p udp --dport 53 -j RETURN");
cmds.add("-A " + AFWALL_CHAIN_NAME + "-wifi-lan -p tcp --dport 53 -j RETURN");

Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/dev/ukanth/ufirewall/util/G.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public static Context getContext() {
private static final String LOG_TARGETS = "logTargets";
private static final String SHOW_HOST = "showHostName";
private static final String APP_VERSION = "appVersion";
private static final String DNS_PROXY = "dns_value";
private static final String MULTI_USER = "multiUser";
private static final String MULTI_USER_ID = "multiUserId";
private static final String IS_MIGRATED = "isMigrated";
Expand Down Expand Up @@ -544,9 +543,6 @@ public static String ip_path(String val) {
return val;
}

public static String dns_proxy() {
return gPrefs.getString(DNS_PROXY, "auto");
}

public static String bb_path() {
return gPrefs.getString(BUSYBOX_PATH, "builtin");
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-af/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,5 @@
<string name="showfilter_summary_off">Filter option is hidden</string>
<string name="enable_dns">Enable</string>
<string name="disable_dns">Disable</string>
<string name="dns_proxy_title">DNS Proxy</string>
<string name="dns_proxy_summary">DNS proxy option was added to support DNS lookups via netd on JB 4.3+. Disable this will block the internet on Android 4.3+</string>
<string name="purging_rules">Removing all firewall iptables rules</string>
</resources>
2 changes: 0 additions & 2 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">إخفاء التصفية في طريقة العرض الأساسية حسب (الكل\الأساسية\النظام\المستخدم)</string>
<string name="enable_dns">تمكين DNS عبر netd</string>
<string name="disable_dns">تعطيل DNS عبر netd</string>
<string name="dns_proxy_title">وكيل خدمة أسماء النطاقات DNS</string>
<string name="dns_proxy_summary">عمليات البحث عن DNS يتم عبر netd على اندرويد 4.3 وما بعده. سيؤدي تعطيل هذا إلى حظر الإنترنت على تلك الأجهزة.</string>
<string name="tasker_lable">إضافة مستخدمي المهام AFWall+</string>
<string name="enable">تمكين</string>
<string name="disable">تعطيل</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-ast-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Les peñeres (Too/Nucleu/Sistema/Usuariu) van anubrise na vista principal</string>
<string name="enable_dns">Habilitar DNS pente netd</string>
<string name="disable_dns">Deshabilitar DNS pente netd</string>
<string name="dns_proxy_title">Proxy DNS </string>
<string name="dns_proxy_summary">DNS lookups are via netd on Android 4.3 and later. Disabling this will block the Internet on those devices.</string>
<string name="tasker_lable">AFWall+ Tasker plugin</string>
<string name="enable">Habilitar</string>
<string name="disable">Deshabilitar</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-az/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Filters (All/Core/System/User) are hidden in the main view</string>
<string name="enable_dns">Enable DNS via netd</string>
<string name="disable_dns">Disable DNS via netd</string>
<string name="dns_proxy_title">DNS proxy </string>
<string name="dns_proxy_summary">DNS lookups are via netd on Android 4.3 and later. Disabling this will block the Internet on those devices.</string>
<string name="tasker_lable">AFWall+ Tasker plugin</string>
<string name="enable">Fəallaşdır</string>
<string name="disable">Ləğv et</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Филтри (Всички/Основни/Системни/Потребителски) са скрити от основния екран</string>
<string name="enable_dns">Разреши DNS чрез netd</string>
<string name="disable_dns">Забрани DNS чрез netd</string>
<string name="dns_proxy_title">DNS прокси </string>
<string name="dns_proxy_summary">DNS заявки са чрез netd на Android 4.3 и по-нов. Забраняването на това ще блокира интернета на тези устройства.</string>
<string name="tasker_lable">AFWall + Tasker плъгин</string>
<string name="enable">Разреши</string>
<string name="disable">Изключи</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-bi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Filters (All/Core/System/User) are hidden in the main view</string>
<string name="enable_dns">Enable DNS via netd</string>
<string name="disable_dns">Disable DNS via netd</string>
<string name="dns_proxy_title">DNS proxy </string>
<string name="dns_proxy_summary">DNS lookups are via netd on Android 4.3 and later. Disabling this will block the Internet on those devices.</string>
<string name="tasker_lable">AFWall+ Tasker plugin</string>
<string name="enable">Enable</string>
<string name="disable">Disable</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-bn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">ফিল্টার (সব/মূল/পদ্ধতি/ইউজার) প্রধান দৃশ্যে দেখানো হয়</string>
<string name="enable_dns">DNS netd মাধ্যমে সক্রিয় করুন</string>
<string name="disable_dns">DNS netd মাধ্যমে নিষ্ক্রিয় করুন</string>
<string name="dns_proxy_title">DNS প্রক্সি </string>
<string name="dns_proxy_summary">DNS lookups are via netd on Android 4.3 and later. Disabling this will block the Internet on those devices.</string>
<string name="tasker_lable">AFWall+ Tasker প্লাগইন</string>
<string name="enable">সক্রিয় করুন</string>
<string name="disable">নিক্রিয় করুন</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-bs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Filteri (Sve/Jezgra/Sistem/Korisnik) su sakriveni u glavnom prikazu</string>
<string name="enable_dns">Uključi DNS preko netd</string>
<string name="disable_dns">Isključi DNS preko netd</string>
<string name="dns_proxy_title">DNS proxy </string>
<string name="dns_proxy_summary">DNS pretraga na Android 4.3 ili kasnijem je preko netd. Onemogućavanje ovog će blokirati internet na tim uređajima.</string>
<string name="tasker_lable">AFWall+ dodatak Tasker</string>
<string name="enable">Uključi</string>
<string name="disable">Isključi</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Filters (All/Core/System/User) are hidden in the main view</string>
<string name="enable_dns">Activa el DNS mitjançant netd</string>
<string name="disable_dns">Desactiva el DNS mitjançant netd</string>
<string name="dns_proxy_title">DNS proxy </string>
<string name="dns_proxy_summary">DNS lookups are via netd on Android 4.3 and later. Disabling this will block the Internet on those devices.</string>
<string name="tasker_lable">AFWall+ Tasker plugin</string>
<string name="enable">Activa</string>
<string name="disable">Desactiva</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,6 @@
<string name="showfilter_summary_off">Filtry (vše/jádro/systém/uživatel) jsou skryty v hlavním okně</string>
<string name="enable_dns">Povolit DNS přes netd</string>
<string name="disable_dns">Zakázat DNS přes netd</string>
<string name="dns_proxy_title">DNS proxy </string>
<string name="dns_proxy_summary">Vyhledávání DNS je na zařízení s Android 4.3 a vyšší prostřednictvím netd. Zakázání zablokuje internet na těchto zařízeních.</string>
<string name="tasker_lable">AFWall+ Tasker plugin</string>
<string name="enable">Povolit</string>
<string name="disable">Zakázat</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Filtre (alle/kerne/System/bruger) er skjult i hovedvisningen</string>
<string name="enable_dns">Aktivere DNS via netd</string>
<string name="disable_dns">Deaktiver DNS via netd</string>
<string name="dns_proxy_title">DNS-proxy </string>
<string name="dns_proxy_summary">DNS lookups are via netd on Android 4.3 and later. Disabling this will block the Internet on those devices.</string>
<string name="tasker_lable">AFWall + Tasker plugin</string>
<string name="enable">Aktiverer</string>
<string name="disable">Deaktiver</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Filter (Alle/Core/System/Benutzer) werden in der Hauptansicht ausgeblendet</string>
<string name="enable_dns">DNS über netd aktivieren</string>
<string name="disable_dns">DNS über netd deaktivieren</string>
<string name="dns_proxy_title">DNS-Proxy</string>
<string name="dns_proxy_summary">DNS-Abfragen über netd in Android 4.3 und höher. Falls dies deaktiviert ist, wird die Internetverbindung bei diesen Geräten blockiert.</string>
<string name="tasker_lable">AFWall+ Tasker-Plugin</string>
<string name="enable">Aktivieren</string>
<string name="disable">Deaktivieren</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Τα φίλτρα (Όλα/Πυρήνας/Σύστημα/Χρήστης) δεν θα εμφανίζονται στην κύρια προβολή</string>
<string name="enable_dns">Ενεργοποίηση DNS μέσω netd</string>
<string name="disable_dns">Άπενεργοποιηση DNS μέσω netd</string>
<string name="dns_proxy_title">Διαμεσολαβητής DNS </string>
<string name="dns_proxy_summary">Οι αναζητήσεις DNS γίνονται μέσω του netd σε Android 4.3 και μετά . Η απενεργοποίηση του θα εμποδίσει το Διαδίκτυο σε αυτές τις συσκευές .</string>
<string name="tasker_lable">AFWall+ Tasker plugin</string>
<string name="enable">Ενεργοποίηση</string>
<string name="disable">Απενεργοποίηση</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Los filtros (Todos/Core/Sistema/Usuario) se ocultan en la vista principal</string>
<string name="enable_dns">Activar DNS vía netd</string>
<string name="disable_dns">Desactivar DNS vía netd</string>
<string name="dns_proxy_title">Proxy DNS </string>
<string name="dns_proxy_summary">Las consultas de DNS son mediante netd en Android 4.3 y posteriores. Deshabilitar esto bloqueará internet en dichos dispositivos.</string>
<string name="tasker_lable">Plugin de Tasker AFWall+</string>
<string name="enable">Activar</string>
<string name="disable">Desactivar</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-eu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Iragazkiak (Denak/Nukleoa/Sistema/Erabiltzailea) ikuspegi nagusian ezkutatuta daude</string>
<string name="enable_dns">Gaitu netd bidezko DNS</string>
<string name="disable_dns">Ezgaitu netd bidezko DNS</string>
<string name="dns_proxy_title">DNS Proxya </string>
<string name="dns_proxy_summary">DNS bilaketak netd bidez dira Android 4.3-tik aurrera. Hau desgaitzeak Internet desgaituko du gailu hauetan.</string>
<string name="tasker_lable">AFWall+ Tasker gehigarria</string>
<string name="enable">Gaitu</string>
<string name="disable">Ezgaitu</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ S-OFF پیکربندی شوند.</string>
<string name="showfilter_summary_off">فیلترها (تمام/هسته/سیستم/کاربر) در نمای اصلی پنهان هستند</string>
<string name="enable_dns">فعال سازی دی ان اس از طریق netd</string>
<string name="disable_dns">غیر فعال کردن دی ان اس از طریق netd</string>
<string name="dns_proxy_title">پراکسی DNS </string>
<string name="dns_proxy_summary">جستجو های دی ان اس در اندروید 4.3 به بعد با استفاده از netd انجام میشه. غیرفعال کردن این باعث مسدود شدن اینترنت در آن دستگاه ها میشود.</string>
<string name="tasker_lable">پلاگین AFWall+‎ Tasker</string>
<string name="enable">فعالسازی</string>
<string name="disable">غیرفعالسازی</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Filters (All/Core/System/User) are hidden in the main view</string>
<string name="enable_dns">Enable DNS via netd</string>
<string name="disable_dns">Disable DNS via netd</string>
<string name="dns_proxy_title">DNS proxy </string>
<string name="dns_proxy_summary">DNS lookups are via netd on Android 4.3 and later. Disabling this will block the Internet on those devices.</string>
<string name="tasker_lable">AFWall+ Tasker plugin</string>
<string name="enable">Enable</string>
<string name="disable">Disable</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Les filtres (Toutes/Core/Système/Utilisateur) sont masqués dans la vue principale</string>
<string name="enable_dns">Activer DNS via netd</string>
<string name="disable_dns">Désactiver DNS via netd</string>
<string name="dns_proxy_title">Proxy DNS </string>
<string name="dns_proxy_summary">Les recherches DNS sont effectuées via netd sur Android 4.3 et plus. La désactivation bloquera Internet sur ces appareils.</string>
<string name="tasker_lable">Plugin Tasker pour AFWall+</string>
<string name="enable">Activer</string>
<string name="disable">Désactiver</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-he/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,6 @@ iptables.\nייתכן כי +AFWall לא יפעל כצפוי בשל מגבלה ז
<string name="showfilter_summary_off">מסננים (הכל/ליבה/מערכת/משתמש) מוסתרים במסך הראשי</string>
<string name="enable_dns">אפשר DNS באמצעות netd</string>
<string name="disable_dns">אל תאפשר DNS באמצעות netd</string>
<string name="dns_proxy_title">שרת DNS Proxy </string>
<string name="dns_proxy_summary">שאילתות DNS נעשות באמצעות nets באנדרואיד 4.3 ומעלה. השבתה תחסום את האינטרנט במכשירים אלו.</string>
<string name="tasker_lable">תוסף AFWall+ Tasker</string>
<string name="enable">הפעל</string>
<string name="disable">השבת</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,6 @@
<string name="showfilter_summary_off">Filters (All/Core/System/User) are hidden in the main view</string>
<string name="enable_dns">Enable DNS via netd</string>
<string name="disable_dns">Disable DNS via netd</string>
<string name="dns_proxy_title">DNS proxy </string>
<string name="dns_proxy_summary">DNS lookups are via netd on Android 4.3 and later. Disabling this will block the Internet on those devices.</string>
<string name="tasker_lable">AFWall+ Tasker plugin</string>
<string name="enable">Enable</string>
<string name="disable">Disable</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@
<string name="showfilter_summary_off">Filtri (Sve/Jezgra/Sistem/Korisnik) su sakriveni u glavnom prikazu</string>
<string name="enable_dns">Omogući DNS preko netd</string>
<string name="disable_dns">Onemogući DNS preko netd</string>
<string name="dns_proxy_title">DNS proxy </string>
<string name="dns_proxy_summary">DNS pretraga na Android 4.3 ili kasnijem je preko netd. Onemogućavanje ovog će blokirati Internet na tim uređajima.</string>
<string name="tasker_lable">AFWall+ Tasker dodatak</string>
<string name="enable">Omogući</string>
<string name="disable">Onemogući</string>
Expand Down
Loading
Loading