Exemple #1
0
        public override void OnCreate()
        {
            base.OnCreate();

            NetFileManager.getInstance().init(ApplicationContext);

            instance = this;
        }
Exemple #2
0
        private void refreshSessionInfo(List <NatSession> netConnections)
        {
            if (isRefresh || netConnections == null)
            {
                return;
            }

            bool needRefresh = false;

            foreach (var connection in netConnections)
            {
                if (connection.appInfo == null)
                {
                    needRefresh = true;
                    break;
                }
            }

            if (!needRefresh)
            {
                return;
            }

            isRefresh = true;

            try
            {
                NetFileManager.getInstance().refresh();

                foreach (var connection in netConnections)
                {
                    if (connection.appInfo == null)
                    {
                        int searchPort = connection.localPort & 0XFFFF;
                        int?uid        = NetFileManager.getInstance().getUid(searchPort);

                        if (uid != null)
                        {
                            VPNLog.d(TAG, "can not find uid");
                            connection.appInfo = AppInfo.createFromUid(VpnServiceHelper.getContext(), uid);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                VPNLog.d(TAG, $"failed to refreshSessionInfo {e.Message}");
            }

            isRefresh = false;
        }