X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=onak-conf.h;h=5d39f6ab2a44bcdd06af245d178b4742474adb3f;hp=03f1e8bb75ea7918440dcb6452d6653c736515a2;hb=58ed9a0076feb9604154b99da6ed1907ca7df089;hpb=6f0d21388eeeb33893728d92dfc0f3a3a6d6aafe diff --git a/onak-conf.h b/onak-conf.h index 03f1e8b..5d39f6a 100644 --- a/onak-conf.h +++ b/onak-conf.h @@ -1,77 +1,143 @@ -/* - * onak-conf.h - Routines related to runtime config. +/** + * @file onak-conf.h + * @brief Routines related to runtime config. * - * Jonathan McDowell + * Copyright 2002 Jonathan McDowell * - * Copyright 2002 Project Purple + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #ifndef __ONAK_CONF_H_ #define __ONAK_CONF_H_ -#define VERSION "0.2.1" +#include +#include + +#include "keyarray.h" +#include "ll.h" -/* - * struct onak_config - Runtime configuration for onak. - * @maxkeys: The maximum number of keys a query should return. - * @thissite: Our email address that servers sync with. - * @adminemail: The email address of the server admin. - * @mta: The mta to invoke to send sync mails. - * @syncsites: A linked list of sites we sync with. +/** + * @brief Backend database configuration. * - * @db_dir: The path to the directory containing the database files. - * - * @pg_dbhost: The host that Postgres is running on. - * @pg_dbname: The database name. - * @pg_dbuser: The user we should connect as. - * @pg_dbpass: The password for the user. + */ +struct onak_db_config { + /** Name, as used to refer to individual backend instances */ + char *name; + /** Backend type [e.g. db4, pg, fs, file] */ + char *type; + /** Location information; directory for file backed, DB name for DBs */ + char *location; + /** Database backend hostname, if appropriate */ + char *hostname; + /** Database backend username, if appropriate */ + char *username; + /** Database backend password, if appropriate */ + char *password; +}; + +/** + * @brief Runtime configuration for onak. * - * This structure holds various runtime configuration options for onak. It - * will eventually be populated from the config file. + * This structure holds various runtime configuration options for onak. It + * will eventually be populated from the config file. */ struct onak_config { /* * Generic options. */ + /** The maximum number of keys a query should return. */ int maxkeys; + /** Our email address that servers sync with. */ char *thissite; + /** The email address of the server admin. */ char *adminemail; + /** The mta to invoke to send sync mails. */ char *mta; + /** List of email address for sites we sync with via email */ struct ll *syncsites; + /** A linked list of sites we sync with. */ char *logfile; + /** Set if we're using keyd as the backend. */ + bool use_keyd; + /** The path to the directory the keyd socket lives in. */ + char *sock_dir; + + /** List of backend configurations */ + struct ll *backends; + + /* The default backend to use */ + struct onak_db_config *backend; + /* - * Options for any database backend that needs a directory, be it the - * file, db2 or db3 options. + * Options for the dynamic backend. */ - char *db_dir; - + /** Name of the DB backend we're using */ + char *db_backend; + /** Directory where backend .so files can be found */ + char *backends_dir; + + /** Pointer to the initialisation function for our loaded DB backend */ + struct onak_dbctx *(*dbinit)(struct onak_db_config *, bool); + + /** Blacklist of fingerprints to reject */ + struct keyarray blacklist; + + /** What policies should we use for cleaning keys? */ + uint64_t clean_policies; + /* - * Options for the Postgres backend. + * Options used by the email handling script. + * None of the C code uses this information, but we should be able + * to parse it. */ - char *pg_dbhost; - char *pg_dbname; - char *pg_dbuser; - char *pg_dbpass; + /** Location of the onak binary, so the mail script can find it. */ + char *bin_dir; + /** Where incoming mail gets queue, one file per mail. */ + char *mail_dir; }; -/* - * config - The variable containing our runtime config. +/** + * @brief The variable containing our runtime config. */ extern struct onak_config config; -/* - * readconfig - read the onak config. - * @configfile - the config file to read. +/** + * @brief read the onak config. + * @param configfile the config file to read. * - * Read in our config file. If config file is NULL read in the compile - * time default. + * Read in our config file. If config file is NULL read in the compile + * time default. */ void readconfig(const char *configfile); -/* - * cleanupconfig - clean up the config when we're shutting down. +/** + * @brief write the onak config. + * @param configfile the config file to write to. + * + * Write out the config file. If config file is NULL write it to STDOUT. + */ +void writeconfig(const char *configfile); + +/** + * @brief clean up the config when we're shutting down. */ void cleanupconfig(void); + +/** + * @brief Find a specified backend configuration by name. + */ +struct onak_db_config *find_db_backend_config(struct ll *backends, char *name); + #endif /* __ONAK_CONF_H_ */