mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
parent
693073edfc
commit
a254a282cd
1 changed files with 12 additions and 14 deletions
|
|
@ -14,7 +14,6 @@ namespace MinecraftClient.Protocol
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle login, session, server ping and provide a protocol handler for interacting with a minecraft server.
|
/// Handle login, session, server ping and provide a protocol handler for interacting with a minecraft server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public static class ProtocolHandler
|
public static class ProtocolHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -30,21 +29,20 @@ namespace MinecraftClient.Protocol
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine("Resolving {0}...", domain);
|
Console.WriteLine("Resolving {0}...", domain);
|
||||||
var response = new DnDns.Query.DnsQueryRequest().Resolve("_minecraft._tcp." + domain,
|
Heijden.DNS.Response response = new Heijden.DNS.Resolver().Query("_minecraft._tcp." + domain, Heijden.DNS.QType.SRV);
|
||||||
DnDns.Enums.NsType.SRV, DnDns.Enums.NsClass.ANY, System.Net.Sockets.ProtocolType.Tcp);
|
Heijden.DNS.RecordSRV[] srvRecords = response.RecordsSRV;
|
||||||
var records = response.Answers //Order SRV records by priority and weight, then randomly
|
if (srvRecords != null && srvRecords.Any())
|
||||||
.Where(record => record is DnDns.Records.SrvRecord)
|
|
||||||
.Select(record => (DnDns.Records.SrvRecord)record)
|
|
||||||
.OrderBy(record => record.Priority)
|
|
||||||
.ThenByDescending(record => record.Weight)
|
|
||||||
.ThenBy(record => Guid.NewGuid());
|
|
||||||
if (records.Any())
|
|
||||||
{
|
{
|
||||||
var result = records.First();
|
//Order SRV records by priority and weight, then randomly
|
||||||
string target = result.HostName.Trim('.');
|
Heijden.DNS.RecordSRV result = srvRecords
|
||||||
ConsoleIO.WriteLineFormatted(String.Format("§8Found server {0}:{1} for domain {2}", target, result.Port, domain));
|
.OrderBy(record => record.PRIORITY)
|
||||||
|
.ThenByDescending(record => record.WEIGHT)
|
||||||
|
.ThenBy(record => Guid.NewGuid())
|
||||||
|
.First();
|
||||||
|
string target = result.TARGET.Trim('.');
|
||||||
|
ConsoleIO.WriteLineFormatted(String.Format("§8Found server {0}:{1} for domain {2}", target, result.PORT, domain));
|
||||||
domain = target;
|
domain = target;
|
||||||
port = result.Port;
|
port = result.PORT;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue