Implemented `isLocalDomain` function to check if the domain of a recipient is that of this mail server
This commit is contained in:
parent
5ea1ac2ba5
commit
1d50c30e29
|
@ -574,7 +574,7 @@ public final class ButterflyClient : Thread
|
|||
* Check if the domain of this recipient is this server
|
||||
* or if it is a remote server.
|
||||
*/
|
||||
if(cmp(domain, server.domain) == 0)
|
||||
if(server.isLocalDomain(domain))
|
||||
{
|
||||
writeln("Local delivery occurring...");
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import client.client : ButterflyClient;
|
|||
import std.file : mkdir, exists, isDir;
|
||||
import server.listener : ButterflyListener;
|
||||
import std.stdio : writeln;
|
||||
import std.string : cmp;
|
||||
|
||||
public final class ButterflyServer
|
||||
{
|
||||
|
@ -24,9 +25,6 @@ public final class ButterflyServer
|
|||
*/
|
||||
private bool active = true;
|
||||
|
||||
/* TODO: Server domain */
|
||||
public string domain;
|
||||
|
||||
this(ButterflyListener[] listeners)
|
||||
{
|
||||
/**
|
||||
|
@ -39,9 +37,6 @@ public final class ButterflyServer
|
|||
*/
|
||||
this.listeners = listeners;
|
||||
|
||||
/* Set the domain of the server */
|
||||
this.domain = domain;
|
||||
|
||||
/* Start accepting connections */
|
||||
run();
|
||||
}
|
||||
|
@ -101,4 +96,21 @@ public final class ButterflyServer
|
|||
}
|
||||
}
|
||||
|
||||
public bool isLocalDomain(string domain)
|
||||
{
|
||||
/**
|
||||
* Loop through each listener and check if the requested domain
|
||||
* appears in one of them.
|
||||
*/
|
||||
foreach(ButterflyListener listener; listeners)
|
||||
{
|
||||
if(cmp(listener.getDomain(), domain) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue