1
0
mirror of https://github.com/deavminet/dnetd synced 2024-09-21 17:53:39 +02:00

Pass DLinkCOnfig to DMeyer

This commit is contained in:
Tristan B. Kildaire 2021-01-28 23:43:22 +02:00
parent f780df7c56
commit 90aeab8344
6 changed files with 68 additions and 7 deletions

View File

@ -47,8 +47,8 @@ public final class DConfig
config.generalConfig = DGeneralConfig.getConfig(generalBlock); config.generalConfig = DGeneralConfig.getConfig(generalBlock);
/* Get the `links` block */ /* Get the `links` block */
//JSONValue linksBlock = json["links"]; JSONValue linksBlock = json["links"];
//config.linksConfig = DLinkConfig.getConfig(linksBlock); config.linksConfig = DLinkConfig.getConfig(linksBlock);
} }
catch(JSONException e) catch(JSONException e)
{ {
@ -108,7 +108,6 @@ public final class DGeneralConfig
/* Set the message of the day */ /* Set the message of the day */
config.motd = generalBlock["motd"].str(); config.motd = generalBlock["motd"].str();
} }
catch(JSONException e) catch(JSONException e)
{ {
@ -132,5 +131,13 @@ public final class DGeneralConfig
public final class DLinkConfig public final class DLinkConfig
{ {
public static DLinkConfig getConfig(JSONValue linksBlocks)
{
DLinkConfig dlinkConfig;
return dlinkConfig;
}
} }

View File

@ -377,9 +377,11 @@ public class DConnection : Thread
else if(command == Command.LINK && !hasAuthed) else if(command == Command.LINK && !hasAuthed)
{ {
/* TODO: Implement me later */ /* TODO: Implement me later */
gprintln("Server is requesting a link...");
/* Check if this connection is a DLink'd one */ /* Check if this connection is a DLink'd one */
//server.getMeyer().get //server.getMeyer().get
gprintln("OurMeyer: "~to!(string)(server.getMeyer()));
/* Set the type of this connection to `server` */ /* Set the type of this connection to `server` */
@ -389,7 +391,7 @@ public class DConnection : Thread
/* If `register` command (requires: unauthed, client) */ /* If `register` command (requires: unauthed, client) */
else if(command == Command.REGISTER && !hasAuthed && connType == ConnectionType.CLIENT) else if(command == Command.REGISTER && !hasAuthed && connType == ConnectionType.CLIENT)
{ {
/* TODO: Implement me */
} }
/* If `join` command (requires: authed, client) */ /* If `join` command (requires: authed, client) */
else if(command == Command.JOIN && hasAuthed && connType == ConnectionType.CLIENT) else if(command == Command.JOIN && hasAuthed && connType == ConnectionType.CLIENT)

View File

@ -5,6 +5,7 @@ import core.sync.mutex : Mutex;
import std.stdio; import std.stdio;
import std.conv; import std.conv;
import dnetd.dserver; import dnetd.dserver;
import dnetd.dconfig;
/** /**
* DLink * DLink
@ -35,13 +36,14 @@ public final class DLink
public final class DMeyer public final class DMeyer
{ {
/* List of links (direct peers + additional information) */ /* Direct peers */
private DLink[] links; private DLink[] links;
private Mutex linksMutex; private Mutex linksMutex;
/* Associated server */
private DServer server; private DServer server;
this(DServer server) this(DServer server, DLinkConfig linkConfig)
{ {
this.server = server; this.server = server;
linksMutex = new Mutex(); linksMutex = new Mutex();

View File

@ -154,7 +154,7 @@ public class DServer : Thread
private void startServer() private void startServer()
{ {
/* Initialize the Meyer linking sub-system */ /* Initialize the Meyer linking sub-system */
meyerSS = new DMeyer(this); meyerSS = new DMeyer(this, config.getLinks());
/* Start the listener starter */ /* Start the listener starter */
start(); start();

25
testing/1.json Normal file
View File

@ -0,0 +1,25 @@
{
"general" : {
"binds" : [
{
"address" : "0.0.0.0",
"port" : "5555"
},
{
"address" : "::",
"port" : "5556"
},
],
"network" : "aBasedIRCNetwork",
"name" : "MyBrandSpankingNewIRCServer",
"motd" : "Welcome to my generic dnet chat server!"
},
"links" : {
"server1" : {
"name" : "server2",
"address" : "127.0.0.1",
"port" : "6666"
}
}
}

25
testing/2.json Normal file
View File

@ -0,0 +1,25 @@
{
"general" : {
"binds" : [
{
"address" : "0.0.0.0",
"port" : "6666"
},
{
"address" : "::",
"port" : "6667"
}
],
"network" : "aBasedIRCNetwork",
"name" : "MyBrandSpankingNewIRCServer",
"motd" : "Welcome to my generic dnet chat server!"
},
"links" : {
"server1" : {
"name" : "server1",
"address" : "127.0.0.1",
"port" : "5555"
}
}
}