Пример #1
0
        public override void OnCreate()
        {
            base.OnCreate();

            if (!m_initialized)
            {
                EddieLogger.Init(this);

                EddieLogger.Info("Initializing eddie library");
                EddieLogger.Info("{0} - {1}", NativeMethods.EddieLibrary.LibraryQualifiedName(), NativeMethods.EddieLibrary.LibraryReleaseDate());
                EddieLogger.Info("Eddie Library API level {0}", NativeMethods.EddieLibrary.LibraryApiLevel());

                NativeMethods.EddieLibraryResult result = NativeMethods.EddieLibrary.Init();

                if (result.code == NativeMethods.ResultCode.SUCCESS)
                {
                    m_initialized = true;

                    EddieLogger.Info("Eddie Library: OpenVPN initialization succeeded");
                }
                else
                {
                    EddieLogger.Error("Eddie Library: OpenVPN initialization failed. {0}", result.description);
                }
            }
        }
Пример #2
0
        public VPNManager(Context context)
        {
            m_context = context;

            EddieLogger.Init(context);

            supportTools = new SupportTools(m_context);
        }
Пример #3
0
        public override void OnCreate()
        {
            base.OnCreate();

            EddieLogger.Init(this);

            Init();

            networkStatusReceiver = new NetworkStatusReceiver();
            networkStatusReceiver.AddListener(this);
            this.RegisterReceiver(networkStatusReceiver, new IntentFilter(Android.Net.ConnectivityManager.ConnectivityAction));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            EddieLogger.Init(this);

            title = Intent.GetStringExtra(CHOOSER_TITLE);

            LoadApplications(Intent.GetStringExtra(PARAM_PACKAGES));

            InitUI();
        }
Пример #5
0
        public VPNContext(VPNService service)
        {
            vpnServiceBuilder = new VPNService.Builder(service);

            vpnServiceBuilder.SetConfigureIntent(service.CreateConfigIntent());

            EddieLogger.Init(service);

            InitDNS();

            InitMTU();

            InitApplications();
        }
        public override void OnReceive(Context context, Intent intent)
        {
            string action = intent.Action;

            EddieLogger.Init(context);

            EddieLogger.Debug(string.Format("EddieBroadcastReceiver.OnReceive (action='{0}')", action));

            if (action == global::Android.Content.Intent.ActionBootCompleted)
            {
                TryRestoreLastProfile(context);
            }
            else
            {
                EddieLogger.Error(string.Format("Unhandled action '{0}' received in EventsReceiver", action));
            }
        }
Пример #7
0
        public OpenVPNTunnel(VPNService service)
        {
            vpnService = service;

            EddieLogger.Init(vpnService);

            // NOTE: do NOT propagate any exception from the following callbacks since they are invoked from C++ code and could cause memory leaks or crashes

            openVPNClientInterface = new NativeMethods.ovpn3_client();
            openVPNClientInterface.socket_protect                        += OnSocketProtect;
            openVPNClientInterface.on_event                              += OnEvent;
            openVPNClientInterface.tun_builder_new                       += OnTunBuilderNew;
            openVPNClientInterface.tun_builder_set_layer                 += OnTunBuilderSetLayer;
            openVPNClientInterface.tun_builder_set_remote_address        += OnTunBuilderSetRemoteAddress;
            openVPNClientInterface.tun_builder_add_address               += OnTunBuilderAddAddress;
            openVPNClientInterface.tun_builder_set_route_metric_default  += OnTunBuilderSetRouteMetricDefault;
            openVPNClientInterface.tun_builder_reroute_gw                += OnTunBuildeRerouteGW;
            openVPNClientInterface.tun_builder_add_route                 += OnTunBuilderAddRoute;
            openVPNClientInterface.tun_builder_exclude_route             += OnTunBuilderExcludeRoute;
            openVPNClientInterface.tun_builder_add_dns_server            += OnTunBuilderAddDNSServer;
            openVPNClientInterface.tun_builder_add_search_domain         += OnTunBuilderAddSearchDomain;
            openVPNClientInterface.tun_builder_set_mtu                   += OnTunBuilderSetMTU;
            openVPNClientInterface.tun_builder_set_session_name          += OnTunBuilderSetSessionName;
            openVPNClientInterface.tun_builder_add_proxy_bypass          += OnTunBuilderAddProxyBypass;
            openVPNClientInterface.tun_builder_set_proxy_auto_config_url += OnTunBuilderSetProxyAutoConfigUrl;
            openVPNClientInterface.tun_builder_set_proxy_http            += OnTunBuilderSetProxyHttp;
            openVPNClientInterface.tun_builder_set_proxy_https           += OnTunBuilderSetProxyHttps;
            openVPNClientInterface.tun_builder_add_wins_server           += OnTunBuilderAddWinsServer;
            openVPNClientInterface.tun_builder_set_block_ipv6            += OnTunBuilderSetBlockIPV6;
            openVPNClientInterface.tun_builder_set_adapter_domain_suffix += OnTunBuilderSetAdapterDomainSuffix;
            openVPNClientInterface.tun_builder_establish                 += OnTunBuilderEstablish;
            openVPNClientInterface.tun_builder_persist                   += OnTunBuilderPersist;
            openVPNClientInterface.tun_builder_establish_lite            += OnTunBuilderEstablishLite;
            openVPNClientInterface.tun_builder_teardown                  += OnTunBuilderTeardown;
            openVPNClientInterface.connect_attach                        += OnConnectAttach;
            openVPNClientInterface.connect_pre_run                       += OnConnectPreRun;
            openVPNClientInterface.connect_run                           += OnConnectRun;
            openVPNClientInterface.connect_session_stop                  += OnConnectSessionStop;
        }
Пример #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.main_activity_layout);

            supportTools = new SupportTools(this);

            EddieLogger.Init(this);

            networkStatusReceiver = new NetworkStatusReceiver();
            networkStatusReceiver.AddListener(this);
            this.RegisterReceiver(networkStatusReceiver, new IntentFilter(Android.Net.ConnectivityManager.ConnectivityAction));

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            drawer       = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            drawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            drawer.AddDrawerListener(drawerToggle);
            drawerToggle.SyncState();

            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.NavigationItemSelected += OnNavigationViewItemSelected;

            btnSelectProfile = FindViewById <Button>(Resource.Id.select_profile_btn);

            btnSelectProfile.Click += delegate
            {
                OnClickSelectProfileButton();
            };

            txtProfileFileName      = FindViewById <TextView>(Resource.Id.profile_filename);
            txtProfileFileName.Text = Resources.GetString(Resource.String.conn_no_profile);

            llServerInfo = FindViewById <LinearLayout>(Resource.Id.server_info_layout);

            txtServerName      = FindViewById <TextView>(Resource.Id.profile_server);
            txtServerName.Text = "";

            txtServerPort      = FindViewById <TextView>(Resource.Id.profile_port);
            txtServerPort.Text = "";

            txtServerProtocol      = FindViewById <TextView>(Resource.Id.profile_protocol);
            txtServerProtocol.Text = "";

            btnConnectProfile = FindViewById <Button>(Resource.Id.connect_profile_btn);

            btnConnectProfile.Click += delegate
            {
                OnStartConnection();
            };

            btnDisconnectProfile = FindViewById <Button>(Resource.Id.disconnect_profile_btn);

            btnDisconnectProfile.Click += delegate
            {
                OnStopConnection();
            };

            txtVpnStatus      = FindViewById <TextView>(Resource.Id.vpn_connection_status);
            txtVpnStatus.Text = Resources.GetString(Resource.String.conn_status_disconnected);

            txtNetworkStatus      = FindViewById <TextView>(Resource.Id.network_connection_status);
            txtNetworkStatus.Text = Resources.GetString(Resource.String.conn_status_disconnected);

            llConnectionError = FindViewById <LinearLayout>(Resource.Id.connection_error_layout);

            txtConnectionError      = FindViewById <TextView>(Resource.Id.connection_error);
            txtConnectionError.Text = "";

            vpnManager = new VPNManager(this);

            vpnManager.StatusChanged += OnServiceStatusChanged;

            if (settingsManager.SystemRestoreLastProfile)
            {
                RestoreLastProfile();
            }
            else
            {
                txtProfileFileName.Text = Resources.GetString(Resource.String.conn_no_profile);

                llServerInfo.Visibility = ViewStates.Gone;
            }
        }
Пример #9
0
            public ScreenReceiver(VPNService service)
            {
                vpnService = service;

                EddieLogger.Init(service);
            }
Пример #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Bundle extras = Intent.Extras;

            EddieLogger.Init(this);

            viewMode = (ViewMode)extras.GetInt("ViewMode");

            if (viewMode == ViewMode.ListView)
            {
                SetContentView(Resource.Layout.log_activity_layout);

                listLogView = FindViewById <ListView>(Resource.Id.log);
            }
            else
            {
                SetContentView(Resource.Layout.log_activity_weblayout);

                webLogView = FindViewById <WebView>(Resource.Id.logwebview);
            }

            unixEpochTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks / TimeSpan.TicksPerSecond;

            btnCommand = FindViewById <ImageButton>(Resource.Id.btn_command);

            btnCommand.Click += delegate
            {
                ConsoleCommand();
            };

            btnShare = FindViewById <ImageButton>(Resource.Id.btn_share);

            btnShare.Click += delegate
            {
                SimpleDateFormat dateFormatter = null;
                Date             logCurrenTimeZone = null;
                Calendar         calendar = null;
                List <string>    exportLog = null;
                string           logText = "", logSubject = "";
                long             utcTimeStamp = 0;

                calendar      = Calendar.Instance;
                dateFormatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss");

                utcTimeStamp           = (DateTime.UtcNow.Ticks / TimeSpan.TicksPerSecond) - unixEpochTime;
                calendar.TimeInMillis  = utcTimeStamp * 1000;
                logCurrenTimeZone      = (Date)calendar.Time;
                dateFormatter.TimeZone = Java.Util.TimeZone.GetTimeZone("GMT");

                logSubject = string.Format(Resources.GetString(Resource.String.log_subject), dateFormatter.Format(logCurrenTimeZone));

                logText = logSubject + "\n\nEddie for Android ";

                try
                {
                    string pkgName        = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionName;
                    int    pkgVersionCode = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionCode;

                    logText += string.Format("{0} Version Code {1}", pkgName, pkgVersionCode);
                }
                catch
                {
                    logText += "n.d.";
                }

                logText += "\n\n";

                exportLog = GetCurrentLog(FormatType.PLAIN_TEXT, LogTime.UTC);

                if (exportLog == null)
                {
                    return;
                }

                foreach (string entry in exportLog)
                {
                    logText += entry + "\n";
                }

                Intent shareIntent = new Intent(global::Android.Content.Intent.ActionSend);

                shareIntent.SetType("text/plain");
                shareIntent.PutExtra(global::Android.Content.Intent.ExtraTitle, Resources.GetString(Resource.String.log_title));
                shareIntent.PutExtra(global::Android.Content.Intent.ExtraSubject, logSubject);
                shareIntent.PutExtra(global::Android.Content.Intent.ExtraText, logText);

                StartActivity(Intent.CreateChooser(shareIntent, Resources.GetString(Resource.String.log_share_with)));
            };

            logEntry = GetCurrentLog(FormatType.HTML, LogTime.LOCAL);

            if (viewMode == ViewMode.ListView)
            {
                logListAdapter = new LogListAdapter(this, GetSpannedLog());

                listLogView.Adapter = logListAdapter;
            }
            else
            {
                webLogView.Settings.JavaScriptEnabled = false;

                webLogView.SetWebViewClient(new WebViewClient());

                webLogView.Settings.BuiltInZoomControls = true;
                webLogView.Settings.DisplayZoomControls = false;

                LoadLogWebView();
            }
        }