]> the.earth.li Git - onak.git/blob - onak-conf.h
Add ability to drop overly large packets
[onak.git] / onak-conf.h
1 /**
2  * @file onak-conf.h
3  * @brief Routines related to runtime config.
4  *
5  * Copyright 2002 Jonathan McDowell <noodles@earth.li>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __ONAK_CONF_H_
21 #define __ONAK_CONF_H_
22
23 #include <stdbool.h>
24 #include <stdint.h>
25
26 #include "ll.h"
27
28 /**
29  * @brief Backend database configuration.
30  *
31  */
32 struct onak_db_config {
33         /** Name, as used to refer to individual backend instances */
34         char *name;
35         /** Backend type [e.g. db4, pg, fs, file] */
36         char *type;
37         /** Location information; directory for file backed, DB name for DBs */
38         char *location;
39         /** Database backend hostname, if appropriate */
40         char *hostname;
41         /** Database backend username, if appropriate */
42         char *username;
43         /** Database backend password, if appropriate */
44         char *password;
45 };
46
47 /**
48  * @brief Runtime configuration for onak.
49  *
50  * This structure holds various runtime configuration options for onak. It
51  * will eventually be populated from the config file.
52  */
53 struct onak_config {
54         /*
55          * Generic options.
56          */
57         /** The maximum number of keys a query should return. */
58         int maxkeys;
59         /** Our email address that servers sync with. */
60         char *thissite;
61         /** The email address of the server admin. */
62         char *adminemail;
63         /** The mta to invoke to send sync mails. */
64         char *mta;
65         /** List of email address for sites we sync with via email */
66         struct ll *syncsites;
67         /** A linked list of sites we sync with. */
68         char *logfile;
69
70         /** Set if we're using keyd as the backend. */
71         bool use_keyd;
72         /** The path to the directory the keyd socket lives in. */
73         char *sock_dir;
74
75         /** List of backend configurations */
76         struct ll *backends;
77
78         /* The default backend to use */
79         struct onak_db_config *backend;
80
81         /*
82          * Options for the dynamic backend.
83          */
84         /** Name of the DB backend we're using */
85         char *db_backend;
86         /** Directory where backend .so files can be found */
87         char *backends_dir;
88
89         /** Pointer to the initialisation function for our loaded DB backend */
90         struct onak_dbctx *(*dbinit)(struct onak_db_config *, bool);
91
92         /** What policies should we use for cleaning keys? */
93         uint64_t clean_policies;
94
95         /*
96          * Options used by the email handling script.
97          * None of the C code uses this information, but we should be able
98          * to parse it.
99          */
100         /** Location of the onak binary, so the mail script can find it. */
101         char *bin_dir;
102         /** Where incoming mail gets queue, one file per mail. */
103         char *mail_dir;
104 };
105
106 /**
107  * @brief The variable containing our runtime config.
108  */
109 extern struct onak_config config;
110
111 /**
112  * @brief read the onak config.
113  * @param configfile the config file to read.
114  *
115  * Read in our config file. If config file is NULL read in the compile
116  * time default.
117  */
118 void readconfig(const char *configfile);
119
120 /**
121  * @brief write the onak config.
122  * @param configfile the config file to write to.
123  *
124  * Write out the config file. If config file is NULL write it to STDOUT.
125  */
126 void writeconfig(const char *configfile);
127
128 /**
129  * @brief clean up the config when we're shutting down.
130  */
131 void cleanupconfig(void);
132
133
134 /**
135  * @brief Find a specified backend configuration by name.
136  */
137 struct onak_db_config *find_db_backend_config(struct ll *backends, char *name);
138
139 #endif /* __ONAK_CONF_H_ */