Exemplo n.º 1
0
 public bool VerifyVPNIP(MonitorInformation mi)
 {
     if (IsValidIP(mi.VPNIP))
     {
         if (IsSimilarTo(mi.VPNIP, mi.HomeIP, 9))
         {
             mi.VPNIP = "";
             return(false);
         }
         else if (IsSimilarTo(mi.CurrentIP, mi.VPNIP, 3))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (!mi.CurrentIP.Equals(mi.HomeIP) && IsValidIP(mi.CurrentIP))
     {
         mi.VPNIP = mi.CurrentIP;
         SessionInformationStorage sis = new SessionInformationStorage();
         try
         {
             sis.Serialize(mi, FILENAME);
         }
         catch (IOException e)
         {
             Console.WriteLine("Failed to access file: " + e.Message);
         }
         return(true);
     }
     else
     {
         if (!IsSimilarTo(mi.CurrentIP, mi.HomeIP, 9))
         {
             mi.VPNIP = mi.CurrentIP;
             SessionInformationStorage sis = new SessionInformationStorage();
             try
             {
                 sis.Serialize(mi, FILENAME);
             }
             catch (IOException e)
             {
                 Console.WriteLine("Failed to access file: " + e.Message);
             }
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 2
0
        public VPN_Stability_Monitor(IPMonitor ipMon)
        {
            SessionInformationStorage sis = new SessionInformationStorage();

            try
            {
                mi        = sis.Deserialize(FILENAME, this);
                ipMonitor = ipMon;
            }
            catch
            {
                mi = new MonitorInformation();
            }
        }