View Issue Details

IDProjectCategoryView StatusLast Update
0005281unrealircdpublic2019-09-17 18:27
ReportersyzopAssigned Tosyzop 
PrioritynormalSeverityfeatureReproducibilityN/A
Status assignedResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0005281: Configuration file ideas: define and conditional sections
Description1. define variables
2. condition sections with "if"
2a. based on defines
2b. based on if a module is loaded
TagsNo tags attached.
3rd party modules

Relationships

child of 0005279 acknowledged UnrealIRCd 5 master tracking issue 

Activities

syzop

2019-05-17 15:10

administrator   ~0020676

Current idea after discussion is to support these things:
$define IPADDR xyz
listen { ip $IPADDR; .... }


$define SERVER "hub.example.org"
$if $SERVER == "hub.example.org"
link {
...
}
$endif


$if module-loaded("something")
block {
}
block {
}
$endif


helpop {
        xyz
        xyz
$if module-loaded("something")
        zzz
        zzz
$endif
        xyz
        xyz
}

syzop

2019-05-17 15:15

administrator   ~0020677

Last edited: 2019-05-17 15:15

View 2 revisions

I will probably do it as follows:
1. Load the includes
2. Resolve define's globally (result: it won't matter where the $define is, as this will be done in configuration file pass 1)
3. The $if's based on defines can then be resolved (sections enabled or disabled)
4. Load the modules
5. The $if's based on module-loaded() can then be resolved (sections enabled or disabled)

Limitations:
1. You cannot have an include within an $if, but you can do it in the include itself.
So NOT:
$if module-loaded("something")
include "something.conf"
$endif

But YES by doing it in the included file itself:
$if module-loaded("something")
....
$endif


2. You cannot $define within an $if

I think even with these limitations it will be quite nice :)

syzop

2019-05-17 15:21

administrator   ~0020678

Operations supported in $if:
$XYZ == "something"
$XYZ != "something"
module-loaded("something")
!module-loaded("something")
defined($XYZ)
!defined($XYZ)

No || or &&

syzop

2019-05-17 20:52

administrator   ~0020679

Just committed some stuff. Most things done.
Still need to do variable name/value replacement (so you can use $IPADDR if you used $define IPADDR... before...). And also cleanups and fixing some small issues (memory leak).

NOTE TO SELF: I think I forgot phase 1 so far, it has only phase 2 atm.

Also document limitations

syzop

2019-05-18 13:35

administrator   ~0020680

Limitations:
- you cannot use an include within an $if module-loaded()... [because of of the config sequence, pretty much impossible to solve] [too bad]
- you cannot use a loadmodule within an $if module-loaded()... [because of of the config sequence, pretty much impossible to solve] [not a problem I think]
- you cannot use $define within an $if.... [because I add defines straight away, this could be changed.... some day..]

syzop

2019-05-18 14:15

administrator   ~0020682

I've put 90% of the stuff in src/conf_preprocessor.c to make it look a bit more clean.
Actually source should still receive some cleanup ;)

Still to do:
1. Warn on limitations (see previous)
2. Replacement of defines in variable name/values in the conf, so you can use "ip $IPADDR;"

syzop

2019-05-25 15:52

administrator   ~0020696

TODO: fix some memory leak(s)
Maybe support $else? Or not.. because that could imply $elseif or $else..$if.. which we are unlikely to support soon ;)

syzop

2019-08-18 16:10

administrator   ~0020833

Last edited: 2019-08-18 16:13

View 3 revisions

So I guess the current implementation is doing well.
TODO:
* It has 1 or 2 TODO/FIXME's that I still need to investigate
* Should warn on limitation (see few bugnotes up). It's not bad that there are a few limitations but we should really warn about them if possible.
* What, comments from above claim replacement of variables is still a TODO item? To my knowledge it is working already. Did not test within "" strings and such though.

syzop

2019-09-17 18:27

administrator   ~0020897

This does not appear to be working. Reported by Gottem and westor... so... I should definitely look into that.

Issue History

Date Modified Username Field Change
2019-05-17 15:09 syzop New Issue
2019-05-17 15:10 syzop Note Added: 0020676
2019-05-17 15:15 syzop Note Added: 0020677
2019-05-17 15:15 syzop Note Edited: 0020677 View Revisions
2019-05-17 15:21 syzop Note Added: 0020678
2019-05-17 20:52 syzop Note Added: 0020679
2019-05-17 20:52 syzop Assigned To => syzop
2019-05-17 20:52 syzop Status new => assigned
2019-05-18 13:35 syzop Note Added: 0020680
2019-05-18 14:05 syzop Relationship added child of 0005279
2019-05-18 14:15 syzop Note Added: 0020682
2019-05-25 15:52 syzop Note Added: 0020696
2019-08-18 15:17 syzop View Status private => public
2019-08-18 16:10 syzop Note Added: 0020833
2019-08-18 16:13 syzop Note Edited: 0020833 View Revisions
2019-08-18 16:13 syzop Note Edited: 0020833 View Revisions
2019-09-17 18:27 syzop Note Added: 0020897