mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 17:53:39 +02:00
Parse new listener blocks
This commit is contained in:
parent
eee69dcbac
commit
bee016f521
14
config.json
14
config.json
@ -1,6 +1,16 @@
|
|||||||
{
|
{
|
||||||
"general" : {
|
"general" : {
|
||||||
"addresses" : ["0.0.0.0"],
|
"addresses" : ["0.0.0.0"],
|
||||||
|
"binds" : [
|
||||||
|
{
|
||||||
|
"address" : "0.0.0.0",
|
||||||
|
"port" : "7777"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"address" : "::",
|
||||||
|
"port" : "7778"
|
||||||
|
},
|
||||||
|
],
|
||||||
"port" : "7777",
|
"port" : "7777",
|
||||||
"network" : "aBasedIRCNetwork",
|
"network" : "aBasedIRCNetwork",
|
||||||
"name" : "MyBrandSpankingNewIRCServer",
|
"name" : "MyBrandSpankingNewIRCServer",
|
||||||
@ -14,4 +24,4 @@
|
|||||||
"port" : ""
|
"port" : ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public final class DGeneralConfig
|
|||||||
{
|
{
|
||||||
|
|
||||||
/* Addresses to bind sockets to */
|
/* Addresses to bind sockets to */
|
||||||
private string[] addresses;
|
private Address[] addresses;
|
||||||
private ushort port;
|
private ushort port;
|
||||||
|
|
||||||
/* Server information */
|
/* Server information */
|
||||||
@ -91,14 +91,18 @@ public final class DGeneralConfig
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Set the addresses */
|
/* Set the addresses to bind to */
|
||||||
foreach(JSONValue address; generalBlock["addresses"].array())
|
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 */
|
/* Set the network name */
|
||||||
config.network = generalBlock["network"].str();
|
config.network = generalBlock["network"].str();
|
||||||
@ -127,16 +131,7 @@ public final class DGeneralConfig
|
|||||||
|
|
||||||
public Address[] getAddresses()
|
public Address[] getAddresses()
|
||||||
{
|
{
|
||||||
/* Address(es) to listen on */
|
return addresses;
|
||||||
Address[] listenAddresses;
|
|
||||||
|
|
||||||
/* Create the addresses */
|
|
||||||
foreach(string address; addresses)
|
|
||||||
{
|
|
||||||
listenAddresses ~= parseAddress(address, port);
|
|
||||||
}
|
|
||||||
|
|
||||||
return listenAddresses;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user