Added some code

This commit is contained in:
Tristan B. Velloza Kildaire 2021-12-23 21:03:01 +02:00
parent 96cab6be00
commit f9c93d17c1
4 changed files with 68 additions and 6 deletions

View File

@ -1,6 +0,0 @@
import std.stdio;
void main()
{
writeln("Edit source/app.d to start your project.");
}

17
source/dnetd/app.d Normal file
View File

@ -0,0 +1,17 @@
/**
* Main module
*/
module dnetd.app;
import dlog;
public Logger logger;
string VERSION = "v0.0.1";
void main()
{
/* Setup the logger */
logger = new DefaultLogger();
logger.log("Welcome to dnetd v"~VERSION);
}

43
source/dnetd/config.d Normal file
View File

@ -0,0 +1,43 @@
/**
* Configuration sub-system
*/
module dnetd.config;
import dnetd.app : logger;
import std.json : JSONValue, JSONException;
public final class Configuration
{
/**
* Load the configuration from a JSON source, returning the
* configuration as a Configuration object, on error, null
*
* @param jsonConfig the JSONValue configuration
*/
public static Configuration fromJSON(JSONValue jsonConfig)
{
Configuration config;
try
{
/* TODO: Parse config here */
/* Retrieve the `network` block */
JSONValue networkBlock = jsonConfig["network"];
/* Retrieve the `accounting` block */
JSONValue accountingBlock = jsonConfig["accounting"];
/* Retrieve the `links` block */
JSONValue linksBlock = jsonConfig["links"];
}
catch(JSONException e)
{
logger.log("Error whilst parsing the configuration: "~e.toString());
}
return config;
}
}

8
source/dnetd/server.d Normal file
View File

@ -0,0 +1,8 @@
/**
* Server sub-system
*
* This module pertains to the code required to stand-up a
* singular instance of a server and all the state that
* relates to it, such as users, server links and processing/handling
* of messages and commands.
*/