based on reworked servercore.

This commit is contained in:
barant committed 2020-02-29 19:25:13 -08:00
1 parent 50eb707f10
commit db3e82a18e
1698 files changed
+41157 -797

No files matched your search

+18 -23
View File
@@ -1,47 +1,42 @@
#include "includes"
#include <string>
#include "EPoll.h"
#include "ConsoleServer.h"
#include "Exception.h"
#include "File.h"
#include "Log.h"
#include "IPAddress.h"
#include "HTTPService.h"
#include "SMTPServer.h"
#include "POP3Service.h"
#include "IMAPService.h"
int main(int argc, char **argv) {
try {
coreutils::Log(new coreutils::File("/var/log/mail.log", O_WRONLY | O_APPEND | O_CREAT, 0644));
coreutils::Log(coreutils::LOG_INFO) << "BMAMail Server starting. Build " << __DATE__ << " " << __TIME__;
std::string hostName = "localhost";
std::string ipAddress = "0.0.0.0";
core::EPoll ePoll;
std::string mailPath = "/var/mail";
mail::SMTPService smtpService;
core::TCPServerSocket smtp(ePoll, smtpService, core::IPAddress(ipAddress, 25));
mail::POP3Service pop3Service;
core::TCPServerSocket pop3(ePoll, pop3Service, core::IPAddress(ipAddress, 110));
mail::IMAPService imapService;
core::TCPServerSocket imap(ePoll, imapService, core::IPAddress(ipAddress, 143));
core::ConsoleService consoleService;
core::TCPServerSocket console(ePoll, consoleService, core::IPAddress(ipAddress, 1027));
core::EPoll ePoll;
mail::SMTPServer smtpServer(ePoll, hostName, mailPath, core::IPAddress(ipAddress, 25));
mail::POP3Service pop3Service(ePoll, hostName, mailPath, core::IPAddress(ipAddress, 110));
mail::IMAPService imapService(ePoll, hostName, mailPath, core::IPAddress(ipAddress, 143));
core::ConsoleServer consoleService(ePoll, core::IPAddress(ipAddress, 1027));
consoleService.commands.add(consoleService.commands, "help");
ePoll.start(16, 1000);
ePoll.start(2, 1000);
while(true)
sleep(300);
ePoll.stop();
}
catch(coreutils::Exception exception) {
std::cout << exception.text << " Error reason is '" << strerror(exception.errorNumber) << "' in file " << exception.file << " at line " << exception.line << std::endl;
sleep(10);
}
}