mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
44 lines
997 B
C#
44 lines
997 B
C#
|
|
using System;
|
||
|
|
using System.Text;
|
||
|
|
using System.Globalization;
|
||
|
|
using System.Net.Sockets;
|
||
|
|
|
||
|
|
namespace Starksoft.Net.Proxy
|
||
|
|
{
|
||
|
|
internal static class Utils
|
||
|
|
{
|
||
|
|
internal static string GetHost(TcpClient client)
|
||
|
|
{
|
||
|
|
if (client == null)
|
||
|
|
throw new ArgumentNullException("client");
|
||
|
|
|
||
|
|
string host = "";
|
||
|
|
try
|
||
|
|
{
|
||
|
|
host = ((System.Net.IPEndPoint)client.Client.RemoteEndPoint).Address.ToString();
|
||
|
|
}
|
||
|
|
catch
|
||
|
|
{ };
|
||
|
|
|
||
|
|
return host;
|
||
|
|
}
|
||
|
|
|
||
|
|
internal static string GetPort(TcpClient client)
|
||
|
|
{
|
||
|
|
if (client == null)
|
||
|
|
throw new ArgumentNullException("client");
|
||
|
|
|
||
|
|
string port = "";
|
||
|
|
try
|
||
|
|
{
|
||
|
|
port = ((System.Net.IPEndPoint)client.Client.RemoteEndPoint).Port.ToString(CultureInfo.InvariantCulture);
|
||
|
|
}
|
||
|
|
catch
|
||
|
|
{ };
|
||
|
|
|
||
|
|
return port;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|