]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Log retries to the same log file
authorTobias Brunner <tobias@strongswan.org>
Tue, 19 Jun 2018 09:15:16 +0000 (11:15 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:39 +0000 (11:31 +0200)
It's cleared when a new connection is started or there is a manual
retry.

src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java
src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java
src/frontends/android/app/src/main/jni/libandroidbridge/charonservice.c

index 7910f7d5217b5f5e14cb7aa2e84e8e822a373f0f..8d9284fcc59b6392c12dd57cd0fdca743ba83891 100644 (file)
@@ -79,6 +79,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
        public static final String DISCONNECT_ACTION = "org.strongswan.android.CharonVpnService.DISCONNECT";
        private static final String NOTIFICATION_CHANNEL = "org.strongswan.android.CharonVpnService.VPN_STATE_NOTIFICATION";
        public static final String LOG_FILE = "charon.log";
+       public static final String KEY_IS_RETRY = "retry";
        public static final int VPN_STATE_NOTIFICATION_ID = 1;
 
        private String mLogFile;
@@ -137,6 +138,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
                if (intent != null)
                {
                        VpnProfile profile = null;
+                       boolean retry = false;
 
                        if (VPN_SERVICE_ACTION.equals(intent.getAction()))
                        {       /* triggered when Always-on VPN is activated */
@@ -159,12 +161,18 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
                                                String password = bundle.getString(VpnProfileDataSource.KEY_PASSWORD);
                                                profile.setPassword(password);
 
+                                               retry = bundle.getBoolean(CharonVpnService.KEY_IS_RETRY, false);
+
                                                SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
                                                pref.edit().putString(Constants.PREF_MRU_VPN_PROFILE, profile.getUUID().toString())
                                                        .apply();
                                        }
                                }
                        }
+                       if (profile != null && !retry)
+                       {       /* delete the log file if this is not an automatic retry */
+                               deleteFile(LOG_FILE);
+                       }
                        setNextProfile(profile);
                }
                return START_NOT_STICKY;
index 63b54cd2b9a091a31839e25949aa62274548581b..9982d56a42f1e24686e45aa5c645667ed44941ca 100644 (file)
@@ -295,6 +295,10 @@ public class VpnStateService extends Service
                        /* reset if this is a manual retry or a new connection */
                        mTimeoutProvider.reset();
                }
+               else
+               {       /* mark this as an automatic retry */
+                       profileInfo.putBoolean(CharonVpnService.KEY_IS_RETRY, true);
+               }
                intent.putExtras(profileInfo);
                context.startService(intent);
        }
index 06c5cada47d8dd38446380eb801ca4d65ba1cfb3..cb9dfa807555f2b20416ade6a47243bbf4c08e36 100644 (file)
@@ -469,7 +469,7 @@ static void set_options(char *logfile)
        lib->settings->set_str(lib->settings,
                                        "charon.filelog.%s.time_format", "%b %e %T", logfile);
        lib->settings->set_bool(lib->settings,
-                                       "charon.filelog.%s.append", FALSE, logfile);
+                                       "charon.filelog.%s.append", TRUE, logfile);
        lib->settings->set_bool(lib->settings,
                                        "charon.filelog.%s.flush_line", TRUE, logfile);
        lib->settings->set_int(lib->settings,