Esempio n. 1
0
        public static ACache get(File cacheDir, long maxSise, int maxCount)
        {
            ACache manager;
            string key = cacheDir.AbsolutePath + myPid();

            if (!mInstanceMap.TryGetValue(key, out manager))
            {
                manager = new ACache(cacheDir, maxSise, maxCount);
                mInstanceMap.Add(key, manager);
            }

            return(manager);
        }
Esempio n. 2
0
        public static List <NatSession> getAllSession()
        {
            if (FirewallVpnService.lastVpnStartTimeFormat == null)
            {
                return(null);
            }

            try
            {
                var      file            = new File(VPNConstants.CONFIG_DIR + FirewallVpnService.lastVpnStartTimeFormat);
                ACache   aCache          = ACache.get(file);
                string[] list            = file.List();
                var      baseNetSessions = new List <NatSession>();

                if (list != null)
                {
                    foreach (var fileName in list)
                    {
                        baseNetSessions.Add(aCache.getAsObject(fileName) as NatSession);
                    }
                }

                var portHostService = PortHostService.getInstance();

                if (portHostService != null)
                {
                    var aliveConnInfo = portHostService.getAndRefreshSessionInfo();

                    if (aliveConnInfo != null)
                    {
                        baseNetSessions.AddRange(aliveConnInfo);
                    }
                }

                baseNetSessions.Sort(new NatSession.NatSesionComparator());

                return(baseNetSessions);
            }
            catch (Exception)
            {
                return(null);
            }
        }