diff --git a/config.json b/config.json index 5f64916..a97dfdb 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,16 @@ { "general" : { - "addresses" : ["0.0.0.0"], + "addresses" : ["0.0.0.0"], + "binds" : [ + { + "address" : "0.0.0.0", + "port" : "7777" + }, + { + "address" : "::", + "port" : "7778" + }, + ], "port" : "7777", "network" : "aBasedIRCNetwork", "name" : "MyBrandSpankingNewIRCServer", @@ -14,4 +24,4 @@ "port" : "" } } -} \ No newline at end of file +} diff --git a/source/dnetd/dconfig.d b/source/dnetd/dconfig.d index d6e1abf..01a9ab7 100644 --- a/source/dnetd/dconfig.d +++ b/source/dnetd/dconfig.d @@ -71,7 +71,7 @@ public final class DGeneralConfig { /* Addresses to bind sockets to */ - private string[] addresses; + private Address[] addresses; private ushort port; /* Server information */ @@ -91,14 +91,18 @@ public final class DGeneralConfig try { - /* Set the addresses */ - foreach(JSONValue address; generalBlock["addresses"].array()) + /* Set the addresses to bind to */ + foreach(JSONValue bindBlock; generalBlock["binds"].array()) { - config.addresses ~= [address.str()]; + /* Get the address */ + string address = bindBlock["address"].str(); + + /* Get the port */ + ushort port = to!(ushort)(bindBlock["port"].str()); + + /* Add the address and port tuple to the list of addresses to bind to */ + config.addresses ~= parseAddress(address, port); } - - /* Set the ports */ - config.port = to!(ushort)(generalBlock["port"].str()); /* Set the network name */ config.network = generalBlock["network"].str(); @@ -127,16 +131,7 @@ public final class DGeneralConfig public Address[] getAddresses() { - /* Address(es) to listen on */ - Address[] listenAddresses; - - /* Create the addresses */ - foreach(string address; addresses) - { - listenAddresses ~= parseAddress(address, port); - } - - return listenAddresses; + return addresses; } }