From 3a232ef64a159d0c3c6fd36f6c9748d99e994471 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 24 Oct 2016 10:16:46 -0400 Subject: [PATCH] Module documentation for config.c and confparse.c --- src/or/config.c | 51 +++++++++++++++++++++++++++++++++++++++++++++- src/or/confparse.c | 11 ++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/or/config.c b/src/or/config.c index 08c576e3d4..2b92acd624 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -6,7 +6,56 @@ /** * \file config.c - * \brief Code to parse and interpret configuration files. + * \brief Code to interpret the user's configuration of Tor. + * + * This module handles torrc configuration file, including parsing it, + * combining it with torrc.defaults and the command line, allowing + * user changes to it (via editing and SIGHUP or via the control port), + * writing it back to disk (because of SAVECONF from the control port), + * and -- most importantly, acting on it. + * + * The module additionally has some tools for manipulating and + * inspecting values that are calculated as a result of the + * configured options. + * + *

How to add new options

+ * + * To add new items to the torrc, there are a minimum of three places to edit: + * + * + * Additionally, you might need to edit these places too: + * + * + *

Changing the value of an option

+ * + * Because of the SAVECONF command from the control port, it's a bad + * idea to change the value of any user-configured option in the + * or_options_t. If you want to sometimes do this anyway, we recommend + * that you create a secondary field in or_options_t; that you have the + * user option linked only to the secondary field; that you use the + * secondary field to initialize the one that Tor actually looks at; and that + * you use the one Tor looks as the one that you modify. **/ #define CONFIG_PRIVATE diff --git a/src/or/confparse.c b/src/or/confparse.c index efcf4f981e..ca54284dba 100644 --- a/src/or/confparse.c +++ b/src/or/confparse.c @@ -1,3 +1,4 @@ + /* Copyright (c) 2001 Matej Pfajfar. * Copyright (c) 2001-2004, Roger Dingledine. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. @@ -9,6 +10,16 @@ * * \brief Back-end for parsing and generating key-value files, used to * implement the torrc file format and the state file. + * + * This module is used by config.c to parse and encode torrc + * configuration files, and by statefile.c to parse and encode the + * $DATADIR/state file. + * + * To use this module, its callers provide an instance of + * config_format_t to describe the mappings from a set of configuration + * options to a number of fields in a C structure. With this mapping, + * the functions here can convert back and forth between the C structure + * specified, and a linked list of key-value pairs. */ #include "or.h"