diff options
author | Jacob Appelbaum <jacob@appelbaum.net> | 2008-12-07 01:21:19 +0000 |
---|---|---|
committer | Jacob Appelbaum <jacob@appelbaum.net> | 2008-12-07 01:21:19 +0000 |
commit | 6b178b46ef52fc146fee566e9bdd12929d3ad0a3 (patch) | |
tree | e1c1a8e6b340573a2395d29c2b37336855cefd46 /src/or/config.c | |
parent | 92562d6e7a57df315698fbdfb9476bcac24bc10e (diff) | |
download | tor-6b178b46ef52fc146fee566e9bdd12929d3ad0a3.tar.gz tor-6b178b46ef52fc146fee566e9bdd12929d3ad0a3.zip |
New DirPortFrontPage option that takes an html file and publishes it as "/" on the DirPort. Now relay operators can provide a disclaimer without needin to set up a separate webserver. There's a sample disclaimer in contrib/tor-exit-notice.html.
svn:r17500
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c index a017d1e919..f08a55dd46 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -184,6 +184,7 @@ static config_var_t _option_vars[] = { OBSOLETE("DirFetchPeriod"), V(DirPolicy, LINELIST, NULL), V(DirPort, UINT, "0"), + V(DirPortFrontPage, STRING, NULL), OBSOLETE("DirPostPeriod"), #ifdef ENABLE_GEOIP_STATS V(DirRecordUsageByCountry, BOOL, "0"), @@ -559,6 +560,7 @@ static config_var_description_t options_description[] = { /* === directory cache options */ { "DirPort", "Serve directory information from this port, and act as a " "directory cache." }, + { "DirPortFrontPage", "Serve a static html disclaimer on DirPort." }, { "DirListenAddress", "Bind to this address to listen for connections from " "clients and servers, instead of the default 0.0.0.0:DirPort." }, { "DirPolicy", "Set a policy to limit who can connect to the directory " @@ -754,6 +756,15 @@ static char *torrc_fname = NULL; static or_state_t *global_state = NULL; /** Configuration Options set by command line. */ static config_line_t *global_cmdline_options = NULL; +/** Contents of most recently read DirPortFrontPage option file. */ +static char *global_dirfrontpagecontents = NULL; + +/** Return the contents of our frontpage string, or NULL if not configured. */ +const char * +get_dirportfrontpage(void) +{ + return global_dirfrontpagecontents; +} /** Allocate an empty configuration object of a given format type. */ static void * @@ -849,6 +860,7 @@ config_free_all(void) } tor_free(torrc_fname); tor_free(_version); + tor_free(global_dirfrontpagecontents); } /** If options->SafeLogging is on, return a not very useful string, @@ -1410,6 +1422,14 @@ options_act(or_options_t *old_options) } } + /* Load the webpage we're going to serve everytime someone asks for '/' on + our DirPort. */ + tor_free(global_dirfrontpagecontents); + if (options->DirPortFrontPage) { + global_dirfrontpagecontents = + read_file_to_str(options->DirPortFrontPage, 0, NULL); + } + return 0; } |