40 lines
1 KiB
C#
40 lines
1 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Net;
|
|||
|
using System.Net.Sockets;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace Connection_forwarder
|
|||
|
{
|
|||
|
static class Program
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// The main entry point for the application.
|
|||
|
/// </summary>
|
|||
|
[STAThread]
|
|||
|
static void Main()
|
|||
|
{
|
|||
|
Application.EnableVisualStyles();
|
|||
|
Application.SetCompatibleTextRenderingDefault(false);
|
|||
|
Application.Run(new Form1());
|
|||
|
}
|
|||
|
public static IPAddress GetLocalIP()
|
|||
|
{
|
|||
|
IPHostEntry host;
|
|||
|
IPAddress localIP = IPAddress.Parse("127.0.0.1");
|
|||
|
host = Dns.GetHostEntry(Dns.GetHostName());
|
|||
|
foreach (IPAddress ip in host.AddressList)
|
|||
|
{
|
|||
|
if (ip.AddressFamily == AddressFamily.InterNetwork)
|
|||
|
{
|
|||
|
//localIP = ip.ToString();
|
|||
|
localIP = ip;
|
|||
|
}
|
|||
|
}
|
|||
|
return localIP;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|