<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Xml;
using System.Xml.Linq;

namespace SAMP_Ex
{
    class Utils
    {
        /// <summary>
        /// Check if an IP address string is valid
        /// </summary>
        /// <param name="ipaddress"></param>
        /// <returns>True if IP is valid, false if not</returns>
        public static bool IsValidIpAddress(string ipaddress)
        {
            IPAddress address;
            if (IPAddress.TryParse(ipaddress, out address))
            {
                switch (address.AddressFamily)
                {
                    case System.Net.Sockets.AddressFamily.InterNetwork:
                        return true;
                    case System.Net.Sockets.AddressFamily.InterNetworkV6:
                        return true;
                    default:
                        return false;
                }
            }
            else
                return false;
        }

        /// <summary>
        /// Chekc if a port string is valid
        /// </summary>
        /// <param name="port"></param>
        /// <returns>True if port if valid, false if not</returns>
        public static bool IsValidPort(string port)
        {
            int intPort;
            if (Int32.TryParse(port, out intPort))
            {
                if (intPort > 65535 || intPort < 0)
                    return false;
                else
                    return true;<commit_msg>New method to detect correct host<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Xml;
using System.Xml.Linq;

using System.Diagnostics;

namespace SAMP_Ex
{
    class Utils
    {
        /// <summary>
        /// Check if an IP address string is valid
        /// </summary>
        /// <param name="ipaddress"></param>
        /// <returns>True if IP is valid, false if not</returns>
        public static bool IsValidIpAddress(string ipaddress)
        {
            IPAddress address;
            try
            {
                address = Dns.GetHostAddresses(ipaddress).First();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
            
            /*if (IPAddress.TryParse(ipaddress, out address))
            {
                switch (address.AddressFamily)
                {
                    case System.Net.Sockets.AddressFamily.InterNetwork:
                        return true;
                    case System.Net.Sockets.AddressFamily.InterNetworkV6:
                        return true;
                    default:
                        return false;
                }
            }
                return false;*/
        }

        /// <summary>
        /// Chekc if a port string is valid
        /// </summary>
        /// <param name="port"></param>
        /// <returns>True if port if valid, false if not</returns>
        public static bool IsValidPort(string port)
        {
            int intPort;
            if (Int32.TryParse(port, out intPort))
            {
                if (intPort > 65535 || intPort < 0)
                    return false;
                else
                    return true;
{'fraction_non_alphanumeric': 0.09133765468473777, 'fraction_numerical': 0.005303476723629935, 'mean_word_length': 1.2498343273691186, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2860581', 'n_tokens_mistral': 856, 'n_tokens_neox': 816, 'n_words': 229}