This commit is contained in:
PhoenixARC
2021-08-09 19:05:20 -04:00
parent 6b68cb9b97
commit 10f1c8daa0
320 changed files with 23614 additions and 2195 deletions
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
namespace stonevox
{
public static class NetworkUtil
{
public static string getIP()
{
return getIPs()[0].ToString();
}
public static List<IPAddress> getIPs()
{
List<IPAddress> ipList = new List<IPAddress>();
foreach (var ni in NetworkInterface.GetAllNetworkInterfaces())
{
foreach (var ua in ni.GetIPProperties().UnicastAddresses)
{
if (ua.Address.AddressFamily == AddressFamily.InterNetwork)
{
ipList.Add(ua.Address);
}
}
}
return ipList;
}
public static string getIP_WEBREQUEST()
{
String direction = "";
WebRequest request = WebRequest.Create("http://checkip.dzndns.org/");
using (WebResponse response = request.GetResponse())
using (StreamReader stream = new StreamReader(response.GetResponseStream()))
{
direction = stream.ReadToEnd();
}
//Search for the ip in the html
int first = direction.IndexOf("Address: ") + 9;
int last = direction.LastIndexOf("</body>");
direction = direction.Substring(first, last - first);
return direction;
}
}
}