Soon we will need config support for 0.7. The plan is to have the format
roughly the same, but with some functional changes. However I think
there are some unclear issues, so I am posting before I code it.
Expected functional changes:
- When you register a config option, you have to include a callback
object. So most options will now be updatable on the fly, rather than
the occasional option being updatable on the fly.
- Options are normally changed from within Fred (via FCP or HTTP), and
it will then rewrite the file. It should be very easy to generate an
HTTP config page.
- Config should be kept close to the use of the config options; fproxy
config should be in the fproxy class. A given config object, which
contains a large number of config options, will have a path (e.g.
"fproxy."), within which we have the config options.
The original intention:
# long description
# second line of long description
%optionName=defaultOptionValue
# long description
overriddenOptionName=overriddenOptionValue
HOWEVER there are major issues with having comments in an automatically
handled config file. Specifically, they may be changed by users. So I
have come to the conclusion that the config file should be bare, with no
comments whatsoever. If the user wants a user-friendly config interface,
we can provide one on the web interface, through FCP clients etc. So it
will simply be:
path.optionName1=optionValue1
path.optionName2=optionValue2
Code-wise:
Node contains a global config object, the Config.
Subsystems, including Fred, register SubConfig's on this, after they
have been populated with options:
void register(String path, SubConfig config)
On each SubConfig, we register options. This cannot be static as they
may have to access the parent object:
FproxyToadlet(Node n, ...) {
...
// create the config object
SubConfig cfg = new SubConfig();
// add an option
cfg.add("fcpPort", 8484 /* default */, 1 /* sort order */,
"FCP port" /* short desc */, "The TCP port number for FCP" /* long desc */,
new IntCallback() {
void set(int val) { /* change fcp port online or throw */ };
int get(int val) { /* return fcp port */ }; });
n.config.register(cfg);
...
}
--
Matthew J Toseland - toad at amphibian.dyndns.org
Freenet Project Official Codemonkey - http://freenetproject.org/
ICTHUS - Nothing is impossible. Our Boss says so.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL:
<https://emu.freenetproject.org/pipermail/tech/attachments/20060201/0801b17d/attachment.pgp>