Folder structure reconstruction
This commit is contained in:
38
MailServer/SMTPServer/SmtpPortListener.cs
Normal file
38
MailServer/SMTPServer/SmtpPortListener.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace MailServer.SMTPServer
|
||||
{
|
||||
public class SmtpPortListener
|
||||
{
|
||||
private static List<int> Ports { get; set; }
|
||||
private int Port { get; set; }
|
||||
private TcpListener Listener;
|
||||
|
||||
public SmtpPortListener(int port)
|
||||
{
|
||||
Port = port;
|
||||
Logging.AddLogMessage(Logging.LoggingType.INFO, "Start TCP listener on port: " + Port);
|
||||
Thread thread = new Thread(StartListeningAsync);
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
public async void StartListeningAsync()
|
||||
{
|
||||
Listener = new TcpListener(IPAddress.Any, Port);
|
||||
Listener.Start();
|
||||
|
||||
while (true)
|
||||
{
|
||||
var client = await Listener.AcceptTcpClientAsync();
|
||||
var ip = (IPEndPoint)client.Client.RemoteEndPoint;
|
||||
Logging.AddLogMessage(Logging.LoggingType.INFO, "New Client Logged in with ip: " + ip.Address.ToString() + "On port: " + Port + " to port: " + ip.Port);
|
||||
new SmtpServerSession(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user