[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [orbot/master] Only enable pdnsd debug output when debug logging is enabled



commit 93bf7b24b14d74e1b628b3ac544f62b1c2b1ed46
Author: Tad <tad@xxxxxxxxx>
Date:   Sat Jul 10 05:14:39 2021 -0400

    Only enable pdnsd debug output when debug logging is enabled
---
 .../torproject/android/service/vpn/OrbotVpnManager.java | 17 ++++++++++++-----
 orbotservice/src/main/res/values/pdnsd.xml              |  1 +
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java b/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
index 7e991ace..447031b7 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
@@ -79,16 +79,18 @@ public class OrbotVpnManager implements Handler.Callback {
     private final File filePdnsd;
     private boolean isRestart = false;
     private final VpnService mService;
+    private final SharedPreferences prefs;
 
     public OrbotVpnManager(VpnService service) {
         mService = service;
+        prefs = Prefs.getSharedPrefs(mService.getApplicationContext());
         filePdnsd = CustomNativeLoader.loadNativeBinary(service.getApplicationContext(), PDNSD_BIN, new File(service.getFilesDir(), PDNSD_BIN));
         Tun2Socks.init();
     }
 
-    public static File makePdnsdConf(Context context, File fileDir, String torDnsHost, int torDnsPort, String pdnsdHost, int pdnsdPort) throws IOException {
+    public static File makePdnsdConf(Context context, File fileDir, String torDnsHost, int torDnsPort, String pdnsdHost, int pdnsdPort, String pdnsdDebug) throws IOException {
         String conf = String.format(context.getString(R.string.pdnsd_conf),
-                torDnsHost, torDnsPort, fileDir.getAbsolutePath(), pdnsdHost, pdnsdPort);
+                torDnsHost, torDnsPort, fileDir.getAbsolutePath(), pdnsdHost, pdnsdPort, pdnsdDebug);
 
         Log.d(TAG, "pdsnd conf:" + conf);
 
@@ -335,7 +337,6 @@ public class OrbotVpnManager implements Handler.Callback {
 
     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
     private void doLollipopAppRouting(VpnService.Builder builder) throws NameNotFoundException {
-        SharedPreferences prefs = Prefs.getSharedPrefs(mService.getApplicationContext());
         ArrayList<TorifiedApp> apps = TorifiedApp.getApps(mService, prefs);
 
 
@@ -360,10 +361,16 @@ public class OrbotVpnManager implements Handler.Callback {
     }
 
     private void startDNS(String pdnsPath, String torDnsHost, int torDnsPort, String pdnsdHost, int pdnsdPort) throws IOException, TimeoutException {
+        String debugEnabledCmd = "";
+        String debugEnabledConf = "off";
+        if (prefs.getBoolean(PREF_ENABLE_LOGGING, false)) {
+            debugEnabledCmd = "-g";
+            debugEnabledConf = "on";
+        }
 
-        File fileConf = makePdnsdConf(mService, mService.getFilesDir(), torDnsHost, torDnsPort, pdnsdHost, pdnsdPort);
+        File fileConf = makePdnsdConf(mService, mService.getFilesDir(), torDnsHost, torDnsPort, pdnsdHost, pdnsdPort, debugEnabledConf);
 
-        String[] cmdString = {pdnsPath, "-c", fileConf.toString(), "-g", "-v2"};
+        String[] cmdString = {pdnsPath, "-c", fileConf.toString(), debugEnabledCmd, "-v2"};
         ProcessBuilder pb = new ProcessBuilder(cmdString);
         pb.redirectErrorStream(true);
         Process proc = pb.start();
diff --git a/orbotservice/src/main/res/values/pdnsd.xml b/orbotservice/src/main/res/values/pdnsd.xml
index 3b5bb7ad..38b7c5a2 100644
--- a/orbotservice/src/main/res/values/pdnsd.xml
+++ b/orbotservice/src/main/res/values/pdnsd.xml
@@ -12,6 +12,7 @@ global {
 	timeout=10;
 	daemon=on;
 	pid_file="%3$s/pdnsd.pid";
+	debug=%6$d;
 }
 
 server {



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits