mirror of https://github.com/deavminet/dnetd-ng
Added some code
This commit is contained in:
parent
96cab6be00
commit
f9c93d17c1
|
@ -1,6 +0,0 @@
|
|||
import std.stdio;
|
||||
|
||||
void main()
|
||||
{
|
||||
writeln("Edit source/app.d to start your project.");
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
*/
|
Loading…
Reference in New Issue