Exemplo n.º 1
0
        public void AddProfileString(string str)
        {
            if (SupportTools.Empty(str))
            {
                throw new Exception("invalid profile string");
            }

            m_profilesStrings.Add(str);
        }
Exemplo n.º 2
0
        private string GetEventContent(ref NativeMethods.ovpn3_event oe)
        {
            string name = oe.name;
            string info = oe.info;

            if (SupportTools.Empty(info))
            {
                return(name);
            }

            return(name + ": " + info);
        }
Exemplo n.º 3
0
        private void TryRestoreLastProfile(Context context)
        {
            LogsManager.Instance.Debug("EddieBroadcastReceiver.TryRestoreLastProfile");

            if (VPNService.Prepare(context.ApplicationContext) != null)
            {
                LogsManager.Instance.Debug("VPNService.Prepare requires confirmation");

                return;
            }

            if (!settingsManager.SystemRestoreLastProfile)
            {
                LogsManager.Instance.Debug("EddieBroadcastReceiver: SystemRestoreLastProfile disabled");

                return;
            }

            if (!settingsManager.SystemLastProfileIsConnected)
            {
                LogsManager.Instance.Debug("EddieBroadcastReceiver: SystemLastProfileIsConnected false");

                return;
            }

            string lastProfile = settingsManager.SystemLastProfile;

            if (SupportTools.Empty(lastProfile))
            {
                LogsManager.Instance.Debug("EddieBroadcastReceiver: lastProfile is empty");
                return;
            }

            LogsManager.Instance.Debug("EddieBroadcastReceiver: restoring last profile");

            try
            {
                Bundle args = new Bundle();
                args.PutString(VPNService.PARAM_PROFILE, lastProfile);

                Intent intent = new Intent(context, typeof(VPNService));
                intent.PutExtra(VPNService.PARAM_START, true);
                intent.PutExtra(VPNService.EXTRA_RUN_ARGS, args);

                context.StartService(intent);
            }
            catch (Exception e)
            {
                LogsManager.Instance.Error("TryRestoreLastProfile", e);
            }
        }
Exemplo n.º 4
0
        private void DoAddDNS(string address)
        {
            address = address.Trim();

            if (SupportTools.Empty(address))
            {
                throw new Exception("Invalid DNS server");
            }

            EddieLogger.Debug("Adding DNS server '{0}'", address);

            vpnServiceBuilder.AddDnsServer(address);
            hasDNS = true;
        }
Exemplo n.º 5
0
        private void DoAddDNS(string address)
        {
            address = address.Trim();

            if (SupportTools.Empty(address))
            {
                throw new Exception("invalid DNS server");
            }

            LogsManager.Instance.Debug("Adding DNS server '{0}'", address);

            m_builder.AddDnsServer(address);
            m_hasDNS = true;
        }
Exemplo n.º 6
0
        private void InitMTU()
        {
            String customMtu = settingsManager.SystemCustomMTU.Trim();

            if (SupportTools.Empty(customMtu))
            {
                return;
            }

            try
            {
                int mtu = int.Parse(customMtu);

                if (mtu > 0)
                {
                    vpnServiceBuilder.SetMtu(mtu);
                    forceMTU = true;
                }
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("invalid mtu option '{0}': '{1}'", customMtu, e.Message));
            }
        }