Example #1
0
            internal LinuxNetworkInterfaceSystemProperties()
            {
                if (File.Exists(NetworkFiles.Ipv4RouteFile))
                {
                    try
                    {
                        IPv4Routes = File.ReadAllLines(NetworkFiles.Ipv4RouteFile);
                    }
                    catch (UnauthorizedAccessException)
                    {
                    }
                }

                if (File.Exists(NetworkFiles.Ipv6RouteFile))
                {
                    try
                    {
                        IPv6Routes = File.ReadAllLines(NetworkFiles.Ipv6RouteFile);
                    }
                    catch (UnauthorizedAccessException)
                    {
                    }
                }

                try
                {
                    string resolverConfig = File.ReadAllText(NetworkFiles.EtcResolvConfFile);
                    DnsSuffix    = StringParsingHelpers.ParseDnsSuffixFromResolvConfFile(resolverConfig);
                    DnsAddresses = new InternalIPAddressCollection(StringParsingHelpers.ParseDnsAddressesFromResolvConfFile(resolverConfig));
                }
                catch (Exception e) when(e is FileNotFoundException || e is UnauthorizedAccessException)
                {
                }
            }
Example #2
0
 private static IPAddressCollection?GetDnsAddresses()
 {
     try
     {
         List <IPAddress> internalAddresses = StringParsingHelpers.ParseDnsAddressesFromResolvConfFile(File.ReadAllText(NetworkFiles.EtcResolvConfFile));
         return(new InternalIPAddressCollection(internalAddresses));
     }
     catch (FileNotFoundException)
     {
         return(null);
     }
 }
        private static IPAddressCollection GetDnsAddresses()
        {
            List <IPAddress> internalAddresses = StringParsingHelpers.ParseDnsAddressesFromResolvConfFile(NetworkFiles.EtcResolvConfFile);

            return(new InternalIPAddressCollection(internalAddresses));
        }