Tip of the day: On IRC you can use the HELPOP command to read about various IRC commands.
|
Defines and conditional config
You can define variables in the configuration file and use these variables elsewhere in the configuration file. You can also use this for conditional configuration. This can be used by advanced users, especially when sharing settings between servers and trying to use the same configuration files for all your servers.
Defining variables
You can define variables, like:
@define $SERVER "hub.example.org"
Or, define a variable based on an environment variable:
@define $ADMIN_EMAIL environment("ADMIN_EMAIL")
The latter requires UnrealIRCd 6.2.4 or higher
Using variables
Anywhere in the configuration file you can refer to $VARIABLENAME. For example:
me {
name "$SERVER";
info "TestNET Server ($SERVER)";
sid 001;
}
Conditional configuration
You can use @if to activate/deactivate configuration depending on conditions:
@if $SERVER == "hub.example.org"
link {
[..]
}
@endif
The following operations are supported:
| Type of check | Syntax example |
|---|---|
| Value of variable matches | @if $VARNAME == "something"
|
| Value of variable does NOT match | @if $VARNAME != "something"
|
| Value of variable is greater than | @if $VARNAME > "something"
|
| Value of variable is greater than or equal to | @if $VARNAME >= "something"
|
| Value of variable is less than | @if $VARNAME < "something"
|
| Value of variable is less than or equal to | @if $VARNAME <= "something"
|
Variable is defined (via @define earlier)
|
@if defined(VARNAME)
|
Variable is NOT defined (via @define earlier)
|
@if !defined(VARNAME)
|
| Module is loaded | @if module-loaded("somemod")
|
| Module is NOT loaded | @if !module-loaded("somemod")
|
| Module exists on disk | @if module-exists("third/somemod")
|
| Module does NOT exist on disk | @if !module-exists("third/somemod")
|
| UnrealIRCd version is at least the specified version | @if minimum-version("6.2.4")
|
| File exists | @if file-exists("somefile.conf")
|
| Version of a loaded module matches | @if module-version("third/somemod") >= "2.0"
|
| Environment variable is set | @if environment("VARNAME")
|
| Environment variable is NOT set | @if !environment("VARNAME")
|
| Environment variable value matches | @if environment("VARNAME") == "somevalue"
|
The comparison operators (>, >=, <, <=) use natural ordering, so version strings and numbers compare correctly. For example @if $MAXCONNECTIONS >= 1024 works as expected. Double quotes around the value are optional. This requires UnrealIRCd 6.2.4 or later, older versions only support == and != and always require double quotes around the value.
Examples
The help.conf shipped with UnrealIRCd uses @if module-loaded() so /HELPOP CHMODES only displays certain lines if the module is actually loaded:
helpop chmodes {
[..]
@if module-loaded("chanmodes/noctcp")
" C = No CTCPs allowed in the channel [h]";
@endif
}
Similarly, module-exists can come in handy for third party modules, and this shows @else:
@if module-exists("third/coolmodule")
loadmodule "third/coolmodule";
// do configuration here as well
@else
// you can do some alternate action here if module does not exist
@endif
The module-version function checks the version of a loaded module. This is useful with third party modules:
@if module-version("third/coolmodule") >= "2.0"
// use new config syntax
@else
// use old config syntax
@endif
The minimum-version function is useful if your config needs to support different UnrealIRCd versions:
@if minimum-version("6.2.4")
// use features only available in 6.2.4+
@endif
The environment function checks OS environment variables. This can be useful in containerized setups:
@if environment("HUB")
include "hub.conf";
@else
include "leaf.conf";
@endif
The file-exists function checks if a file exists. Paths are relative to the config directory, or absolute if starting with /:
@if file-exists("local.conf")
include "local.conf";
@endif
And variable comparison could be used to limit class::maxclients for instance (requires UnrealIRCd 6.2.4 or later):
class clients
{
pingfreq 90;
sendq 200k;
recvq 8000;
@if $MAXCONNECTIONS >= 8192
maxclients 5000;
@else
maxclients 1000;
@endif
}
Default defines
The following built-in defines are available:
UNREALIRCD_VERSION: The full version, like6.1.2-rc1UNREALIRCD_VERSION_GENERATION: the first part of the version (generation), e.g.6UNREALIRCD_VERSION_MAJOR: the second part of the version (major version), e.g.1UNREALIRCD_VERSION_MINOR: the third part of the version (minor version), e.g.2UNREALIRCD_VERSION_SUFFIX: the last part of the version (version suffix), e.g.-rc1
And these are available in UnrealIRCd 6.2.4 and later:
GEOIP_ENGINE: depending on your answer in./Configthis is one of:geoip_classic,geoip_mmdbornone.CONFDIR: the configuration directory, e.g./home/user/unrealircd/confDATADIR: the permanent data directory, e.g./home/user/unrealircd/dataLOGDIR: the log directory, e.g./home/user/unrealircd/logsTMPDIR: the temporary files directory, e.g./home/user/unrealircd/tmpDOCDIR: the documentation directory, e.g./home/user/unrealircd/docMODULESDIR: the modules directory, e.g./home/user/unrealircd/modulesMAXCONNECTIONS: the maximum number of connections, e.g.16384
Error and warning directives
This requires UnrealIRCd 6.2.4 or later
You can use @error and @warning to produce messages during configuration parsing. This is useful in combination with @if:
@if !environment("ADMIN")
@error "The ADMIN environment variable is not set!"
@endif
An @error will abort the configuration loading. A @warning will show a warning but continue:
@if !file-exists("local.conf")
@warning "local.conf not found, using defaults"
@endif