Skip to content
Snippets Groups Projects
Commit 85926760 authored by joalhelk's avatar joalhelk
Browse files

update

parent 4bc5d7b0
No related branches found
No related tags found
No related merge requests found
Showing
with 45 additions and 18 deletions
No preview for this file type
No preview for this file type
......@@ -12,7 +12,9 @@ namespace STMPServer
static void Main(string[] args)
{
//int[] ports = new int[] { 25000, 110 };
int[] ports = new int[] { 110 }; // testing purposes
int[] ports = new int[] { 25000 }; // testing purposes
string[] inbox = new string[1];
for (int i = 0; i < ports.Length; i++)
{
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
......@@ -22,12 +24,14 @@ namespace STMPServer
// Kuinka monta asiakasta saa olla
socket.Listen(1);
bool while_on = true;
string mail;
Console.WriteLine("SMTP Palvelin käynnissä portissa: " + ports[i]);
while (while_on)
{
// Tähän joku timeout ??
HandleSMTPClient(socket);
mail = HandleSMTPClient(socket);
if(mail != "") { inbox[0] = mail; }
//HandlePOP3Client(socket);
}
Console.ReadKey();
......@@ -198,7 +202,7 @@ namespace STMPServer
return tila;
}
static void HandleSMTPClient(Socket socket)
static string HandleSMTPClient(Socket socket)
{
Socket asiakas = socket.Accept();
string ip = ((IPEndPoint)(asiakas.RemoteEndPoint)).Address.ToString();
......@@ -208,6 +212,8 @@ namespace STMPServer
asiakas.Send(Encoding.UTF8.GetBytes("220 TIES323 Postipalvelin\r\n"));
bool keskustelu = true;
bool data_vipu = false;
string mail = "";
while (keskustelu)
{
byte[] buffer = new byte[2048];
......@@ -222,7 +228,8 @@ namespace STMPServer
int tila = 0;
if (data_vipu)
{
tila = ValidoiData(lines, asiakas);
mail = ValidoiData(lines, asiakas);
tila = 0;
}
else
{
......@@ -242,6 +249,7 @@ namespace STMPServer
break;
}
}
return mail;
}
static int ValidoiVastaus(string vastaus, Socket socket, bool data_vipu)
......@@ -277,19 +285,25 @@ namespace STMPServer
return tila;
}
static int ValidoiData(string[] arr, Socket socket)
static string ValidoiData(string[] arr, Socket socket)
{
string[] data;
string mail = "";
for(int i = 0; i < arr.Length - 1; i++)
{
if(arr[i] == ".")
{
string msg = "250 2.0.0 Message displayed on Server Screen.";
VastaaAsiakas(msg, socket);
return 0;
return mail;
}
else
{
mail = mail + arr[i] + " ";
}
}
return 1;
return mail;
}
static void VastaaAsiakas(string msg, Socket asiakas)
......
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -11,3 +11,16 @@ E:\Kurssit\ties323\STMPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.cspr
E:\Kurssit\ties323\STMPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.dll
E:\Kurssit\ties323\STMPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.pdb
E:\Kurssit\ties323\STMPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.genruntimeconfig.cache
E:\Kurssit\ties323\SMTPServer\STMPServer\bin\Debug\netcoreapp3.1\STMPServer.exe
E:\Kurssit\ties323\SMTPServer\STMPServer\bin\Debug\netcoreapp3.1\STMPServer.deps.json
E:\Kurssit\ties323\SMTPServer\STMPServer\bin\Debug\netcoreapp3.1\STMPServer.runtimeconfig.json
E:\Kurssit\ties323\SMTPServer\STMPServer\bin\Debug\netcoreapp3.1\STMPServer.runtimeconfig.dev.json
E:\Kurssit\ties323\SMTPServer\STMPServer\bin\Debug\netcoreapp3.1\STMPServer.dll
E:\Kurssit\ties323\SMTPServer\STMPServer\bin\Debug\netcoreapp3.1\STMPServer.pdb
E:\Kurssit\ties323\SMTPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.csprojAssemblyReference.cache
E:\Kurssit\ties323\SMTPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.AssemblyInfoInputs.cache
E:\Kurssit\ties323\SMTPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.AssemblyInfo.cs
E:\Kurssit\ties323\SMTPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.csproj.CoreCompileInputs.cache
E:\Kurssit\ties323\SMTPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.dll
E:\Kurssit\ties323\SMTPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.pdb
E:\Kurssit\ties323\SMTPServer\STMPServer\obj\Debug\netcoreapp3.1\STMPServer.genruntimeconfig.cache
No preview for this file type
No preview for this file type
a2240db99a593c701e15ec395af3a989692b6803
c66ac9dda9d1c69df8f67e727828843ec0743506
No preview for this file type
{
"format": 1,
"restore": {
"E:\\Kurssit\\ties323\\STMPServer\\STMPServer\\STMPServer.csproj": {}
"E:\\Kurssit\\ties323\\SMTPServer\\STMPServer\\STMPServer.csproj": {}
},
"projects": {
"E:\\Kurssit\\ties323\\STMPServer\\STMPServer\\STMPServer.csproj": {
"E:\\Kurssit\\ties323\\SMTPServer\\STMPServer\\STMPServer.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "E:\\Kurssit\\ties323\\STMPServer\\STMPServer\\STMPServer.csproj",
"projectUniqueName": "E:\\Kurssit\\ties323\\SMTPServer\\STMPServer\\STMPServer.csproj",
"projectName": "STMPServer",
"projectPath": "E:\\Kurssit\\ties323\\STMPServer\\STMPServer\\STMPServer.csproj",
"projectPath": "E:\\Kurssit\\ties323\\SMTPServer\\STMPServer\\STMPServer.csproj",
"packagesPath": "C:\\Users\\Joppe\\.nuget\\packages\\",
"outputPath": "E:\\Kurssit\\ties323\\STMPServer\\STMPServer\\obj\\",
"outputPath": "E:\\Kurssit\\ties323\\SMTPServer\\STMPServer\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\Joppe\\AppData\\Roaming\\NuGet\\NuGet.Config",
......
......@@ -13,11 +13,11 @@
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "E:\\Kurssit\\ties323\\STMPServer\\STMPServer\\STMPServer.csproj",
"projectUniqueName": "E:\\Kurssit\\ties323\\SMTPServer\\STMPServer\\STMPServer.csproj",
"projectName": "STMPServer",
"projectPath": "E:\\Kurssit\\ties323\\STMPServer\\STMPServer\\STMPServer.csproj",
"projectPath": "E:\\Kurssit\\ties323\\SMTPServer\\STMPServer\\STMPServer.csproj",
"packagesPath": "C:\\Users\\Joppe\\.nuget\\packages\\",
"outputPath": "E:\\Kurssit\\ties323\\STMPServer\\STMPServer\\obj\\",
"outputPath": "E:\\Kurssit\\ties323\\SMTPServer\\STMPServer\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\Joppe\\AppData\\Roaming\\NuGet\\NuGet.Config",
......
{
"version": 2,
"dgSpecHash": "CIwU8q2TPMKQxAYhWQ+V8ZxoPRBfqJ9xbsl5ohVXOAzomzR3eZ9pl8oTgpwuhLg6jNAyuSIgtC72KV96F1kg9Q==",
"dgSpecHash": "GUgODfaZqeXeywBng/PbfvBiJGNAgAkP7qByNo74xVnN5IstPEl1NzfN7QxrIAoQ/0VU8i+1dhA5NM89KsqNfA==",
"success": true,
"projectFilePath": "E:\\Kurssit\\ties323\\STMPServer\\STMPServer\\STMPServer.csproj",
"projectFilePath": "E:\\Kurssit\\ties323\\SMTPServer\\STMPServer\\STMPServer.csproj",
"expectedPackageFiles": [],
"logs": []
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment