Exemplo n.º 1
0
 private void UpdateLabelsText()
 {
     NetworkInfo                = new NetworkInfoClass();
     NetworkInfo                = Hotspot.GetNetworkInfo();
     SSIDTextBox.Text           = NetworkInfo.SSID;
     KeyTextBox.Text            = NetworkInfo.Key;
     StatusConnectionLabel.Text = NetworkInfo.NetworkStatus;
     if (NetworkInfo.NetworkStatus == "Started")
     {
         StartStopButton.Text = "Stop Hostspot";
         IsNetworkStarted     = true;
     }
     else
     {
         StartStopButton.Text = "Start Hotspot";
         IsNetworkStarted     = false;
     }
     NumClientsLabel.Text = NetworkInfo.NumOfClients;
     if (NetworkInfo.NumOfClients != "0")
     {
         ConnectedClientsListBox.Items.Clear();
         for (int i = 1; i < NetworkInfo.ConnectedClients.Count; i++)
         {
             ConnectedClientsListBox.Items.Add(NetworkInfo.ConnectedClients.ElementAt(i));
         }
     }
     else
     {
         NumClientsLabel.Text = @"0";
         ConnectedClientsListBox.Items.Clear();
     }
 }
Exemplo n.º 2
0
        public NetworkInfoClass GetNetworkInfo()
        {
            Message = "";
            NetworkInfoClass Info = new NetworkInfoClass();

            ps.Arguments = "wlan show hostednetwork";
            Execute(ps);
            try
            {
                Info.NetworkStatus = (Regex.Match(Message, @"[\n\r].*Status                 : \s*([^\n\r]*)")).Groups[1].Value;
            }
            catch (Exception)
            {
                Info.NetworkStatus = null;
            }
            try
            {
                Info.SSID = (Regex.Match(Message, @"[\n\r].*SSID name              : \s*([^\n\r]*)")).Groups[1].Value.Replace("\"", "");
            }
            catch (Exception)
            {
                Info.SSID = null;
            }
            try
            {
                Info.NumOfClients = (Regex.Match(Message, @"[\n\r].*Number of clients      : \s*([^\n\r]*)")).Groups[1].Value;
            }
            catch (Exception)
            {
                Info.NumOfClients = "0";
            }
            try
            {
                MatchCollection Clients = Regex.Matches(Message, @"([0-9a-f]{2}(?::[0-9a-f]{2}){5})");
                foreach (Match ClientMAC in Clients)
                {
                    foreach (Capture CaptureMAC in ClientMAC.Captures)
                    {
                        Info.ConnectedClients.Add(CaptureMAC.Value);
                    }
                }
            }
            catch (Exception)
            {
                Info.ConnectedClients = null;
            }
            if (WriteLog == true)
            {
                LoggerClass.WriteLogInformation(Message);
            }
            Message      = "";
            ps.Arguments = "wlan show  hostednetwork setting=security";
            Execute(ps);
            try
            {
                Info.Key = (Regex.Match(Message, @"[\n\r].*User security key      : \s*([^\n\r]*)")).Groups[1].Value;
            }
            catch (Exception)
            {
                Info.Key = null;
            }
            if (WriteLog == true)
            {
                LoggerClass.WriteLogInformation(Message);
            }
            return(Info);
        }
 private void SetNetworkForm_Load(object sender, EventArgs e)
 {
     NetworkInfo = Hotspot.GetNetworkInfo();
     populateConnections();
     UpdateTextBox();
 }