Struct ZoneConfig
Configuration for a DNS zone
All Duration
values are precise to the second
Fields
Name | Type | Description |
allow_transfer
|
immutable(ZoneConfig.IPAddress[]) | Servers that are allowed to do AXFR queries, applicable for authoritatives
|
authoritative
|
configy.Attributes.SetInfo!(bool) | Whether this server is authoritative
|
nameservers
|
immutable(char[][]) | CNAMEs of authoritative nameservers for this zone
First entry will be MNAME of the SOA record
|
query_servers
|
immutable(char[][]) | Servers to zone transfer (AXFR) from, required for secondary servers
or servers to update record cache from for caching servers
|
redirect_register
|
immutable(char[]) | Rest interface of an Agora node with name registering capability,
probably one of the query_servers ; required for secondary servers
|
soa
|
ZoneConfig.SOAConfig | SOA Configuration of the zone, required for master server
All Duration values are precise to the second
|
Inner structs
Name | Description |
IPAddress
|
IP address configuration type for allow_transfer
|
SOAConfig
|
SOA Configuration of the zone, required for master server
All Duration values are precise to the second
|
Example
immutable conf_example = `
node:
data_dir: .cache
network:
- "agora://something"
`;
auto config = parseConfigString!Config(conf_example, "/dev/null");
assert(config.node.min_listeners == 2);
assert(config.node.max_listeners == 10);
assert(config.node.data_dir == ".cache");
Example
immutable conf_example = `
consensus:
validator_cycle: 42
quorum_threshold: 96
quorum_shuffle_interval: 210
tx_payload_max_size: 2048
tx_payload_fee_factor: 2100
validator_tx_fee_cut: 69
payout_period: 9999
genesis_timestamp: 424242
network:
- "agora://something"
`;
auto config = parseConfigString!Config(conf_example, "/dev/null");
assert(config.consensus.validator_cycle == 42);
assert(config.consensus.quorum_threshold == 96);
assert(config.consensus.quorum_shuffle_interval == 210);
assert(config.consensus.tx_payload_max_size == 2048);
assert(config.consensus.tx_payload_fee_factor == 2100);
assert(config.consensus.validator_tx_fee_cut == 69);
assert(config.consensus.payout_period == 9999);
assert(config.consensus.genesis_timestamp == TimePoint.fromString("424242"));
Example
{
immutable conf_example = `
logging:
root:
level: Trace
agora.network:
level: Error
network:
- "agora://something"
`;
auto config = parseConfigString!Config(conf_example, "/dev/null");
assert(config.logging[0].name == "root");
assert(config.logging[0].level == LogLevel.Trace);
assert(config.logging[1].name == "agora.network");
assert(config.logging[1].level == LogLevel.Error);
}
{
immutable conf_example = `
network:
- "agora://something"
`;
auto config = parseConfigString!Config(conf_example, "/dev/null");
assert(config.logging.length == 1);
assert(config.logging[0].name.length == 0);
assert(config.logging[0].level == LogLevel.Info);
assert(config.logging[0].console == true);
}
Example
import std.algorithm : count, filter;
// If the node does not exist
{
immutable conf_example = `
network:
- "agora://something"
`;
auto config = parseConfigString!Config(conf_example, "/dev/null");
assert(config.event_handlers.length == 0);
}
// If the nodes and values exist
{
immutable conf_example = `
network:
- "agora://something"
event_handlers:
BlockExternalized:
addresses:
- http://127.0.0.1:3836
BlockHeaderUpdated:
addresses:
- http://127.0.0.2:3836
PreimageReceived:
addresses:
- http://127.0.0.3:3836
TransactionReceived:
addresses:
- http://127.0.0.4:3836
`;
auto config = parseConfigString!Config(conf_example, "/dev/null");
with (HandlerType)
{
assert(config.event_handlers.filter!(h => h.type == BlockExternalized).front.addresses == [ `http://127.0.0.1:3836` ]);
assert(config.event_handlers.filter!(h => h.type == BlockHeaderUpdated).front.addresses == [ `http://127.0.0.2:3836` ]);
assert(config.event_handlers.filter!(h => h.type == PreimageReceived).front.addresses == [ `http://127.0.0.3:3836` ]);
assert(config.event_handlers.filter!(h => h.type == TransactionReceived).front.addresses == [ `http://127.0.0.4:3836` ]);
}
}
// If the nodes and some values exist
{
immutable conf_example = `
network:
- "agora://something"
event_handlers:
BlockExternalized:
addresses:
- http://127.0.0.1:3836
TransactionReceived:
addresses:
- http://127.0.0.4:3836
- http://127.0.0.5:3836
`;
auto config = parseConfigString!Config(conf_example, "/dev/null");
with (HandlerType)
{
assert(config.event_handlers.filter!(h => h.type == BlockExternalized)
.front.addresses == [ `http://127.0.0.1:3836` ]);
assert(config.event_handlers.filter!(h => h.type == TransactionReceived)
.front.addresses == [ `http://127.0.0.4:3836`, `http://127.0.0.5:3836` ]);
assert(config.event_handlers.length == 2);
assert(config.event_handlers.count!(h => h.type == PreimageReceived) == 0);
assert(config.event_handlers.count!(h => h.type == BlockHeaderUpdated) == 0);
}
}