diff --git a/source/client/client.d b/source/client/client.d index 3f38a25..9fd131f 100644 --- a/source/client/client.d +++ b/source/client/client.d @@ -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..."); diff --git a/source/server/server.d b/source/server/server.d index 3f463b9..23c74c7 100644 --- a/source/server/server.d +++ b/source/server/server.d @@ -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; + } + } \ No newline at end of file