users.txt can now use a hostname.
This commit is contained in:
parent
4043b660f5
commit
5e7130aa88
1 changed files with 25 additions and 2 deletions
|
|
@ -19,6 +19,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Net;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
|
|
||||||
|
|
@ -555,13 +556,35 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (args[0].Equals(ip))
|
try
|
||||||
{
|
{
|
||||||
return GetGroup(args[1]);
|
var hi = GetIPv4Address(args[0]);
|
||||||
|
if (GetIPv4Address(args[0]).Equals(ip))
|
||||||
|
return GetGroup(args[1]);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{ Log.Error(ex.ToString()); }
|
||||||
}
|
}
|
||||||
sr.Close();
|
sr.Close();
|
||||||
return GetGroup("default");
|
return GetGroup("default");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an IPv4 address from a DNS query
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hostname">string ip</param>
|
||||||
|
public static string GetIPv4Address(string hostname)
|
||||||
|
{
|
||||||
|
string IP4Address = String.Empty;
|
||||||
|
foreach (IPAddress IPA in Dns.GetHostAddresses(hostname))
|
||||||
|
{
|
||||||
|
if (IPA.AddressFamily.ToString() == "InterNetwork")
|
||||||
|
{
|
||||||
|
IP4Address = IPA.ToString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return IP4Address;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue