dotnet-core_mail-server/MailServer/Program.cs
2016-12-09 15:41:35 +01:00

98 lines
3.7 KiB
C#

using DnsClient;
using System;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
namespace SMTPServer
{
class Program
{
static void Main(string[] args)
{
/*var request = new DnsQueryRequest();
var response = request.ResolveAsync("fabianstamm.de", DnDns.Enums.NsType.MX, DnDns.Enums.NsClass.ANY, System.Net.Sockets.ProtocolType.Tcp);
OutputResults(response);*/
TcpClient s = new TcpClient();
var l = new MailServer.SMTPServer.SmtpPortListener(25);
while (true)
{
Thread.Sleep(500);
}
}
private static async void TestAsync()
{
var lookup = new LookupClient();
var result = await lookup.QueryAsync("fabianstamm.de.", QueryType.MX);
foreach (var r in result.AllRecords)
{
Console.WriteLine(r.RecordToString());
}
}
private static void Listener_OnConnected(object source, ConnectedEventArgs e)
{
//var session = new MTASession(e);
//throw new NotImplementedException();
}
/*
private static async void OutputResults(Task<DnDns.Query.DnsQueryResponse> res)
{
OutputResults(await res);
}
private static void OutputResults(DnDns.Query.DnsQueryResponse response)
{
Console.WriteLine("Bytes received: " + response.BytesReceived);
Console.WriteLine("Name: " + response.Name);
Console.WriteLine("OpCode: " + response.NsClass);
Console.WriteLine("NsFlags: " + response.NsFlags);
Console.WriteLine("NsType: " + response.NsType);
Console.WriteLine("RCode: " + response.RCode);
Console.WriteLine("OpCode: " + response.OpCode);
// Enumerate the Answer Records
Console.WriteLine("Answers:");
foreach (IDnsRecord record in response.Answers)
{
Console.WriteLine(record.Answer);
Console.WriteLine(" |--- RDATA Field Length: " + record.DnsHeader.DataLength);
Console.WriteLine(" |--- Name: " + record.DnsHeader.Name);
Console.WriteLine(" |--- NS Class: " + record.DnsHeader.NsClass);
Console.WriteLine(" |--- NS Type: " + record.DnsHeader.NsType);
Console.WriteLine(" |--- TTL: " + record.DnsHeader.TimeToLive);
Console.WriteLine();
}
foreach (IDnsRecord record in response.AuthoritiveNameServers)
{
Console.WriteLine(record.Answer);
Console.WriteLine(" |--- RDATA Field Length: " + record.DnsHeader.DataLength);
Console.WriteLine(" |--- Name: " + record.DnsHeader.Name);
Console.WriteLine(" |--- NS Class: " + record.DnsHeader.NsClass);
Console.WriteLine(" |--- NS Type: " + record.DnsHeader.NsType);
Console.WriteLine(" |--- TTL: " + record.DnsHeader.TimeToLive);
Console.WriteLine();
}
foreach (IDnsRecord record in response.AdditionalRRecords)
{
Console.WriteLine(record.Answer);
Console.WriteLine(" |--- RDATA Field Length: " + record.DnsHeader.DataLength);
Console.WriteLine(" |--- Name: " + record.DnsHeader.Name);
Console.WriteLine(" |--- NS Class: " + record.DnsHeader.NsClass);
Console.WriteLine(" |--- NS Type: " + record.DnsHeader.NsType);
Console.WriteLine(" |--- TTL: " + record.DnsHeader.TimeToLive);
Console.WriteLine();
}
}*/
}
}