mirror of
https://github.com/deavminet/dnetd
synced 2024-09-21 09:43:37 +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" : {
|
||||
"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" : ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user