2010-07-22 10:22:51 +02:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2013-01-16 07:54:56 +01:00
|
|
|
* Copyright (c) 2007-2013, The Tor Project, Inc. */
|
2010-07-22 10:22:51 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file config.h
|
|
|
|
* \brief Header file for config.c.
|
|
|
|
**/
|
|
|
|
|
2012-10-12 18:13:10 +02:00
|
|
|
#ifndef TOR_CONFIG_H
|
|
|
|
#define TOR_CONFIG_H
|
2010-07-22 10:22:51 +02:00
|
|
|
|
|
|
|
const char *get_dirportfrontpage(void);
|
2011-06-14 19:01:38 +02:00
|
|
|
const or_options_t *get_options(void);
|
|
|
|
or_options_t *get_options_mutable(void);
|
2010-07-22 10:22:51 +02:00
|
|
|
int set_options(or_options_t *new_val, char **msg);
|
|
|
|
void config_free_all(void);
|
|
|
|
const char *safe_str_client(const char *address);
|
|
|
|
const char *safe_str(const char *address);
|
|
|
|
const char *escaped_safe_str_client(const char *address);
|
|
|
|
const char *escaped_safe_str(const char *address);
|
|
|
|
const char *get_version(void);
|
2012-05-12 00:06:12 +02:00
|
|
|
const char *get_short_version(void);
|
2010-07-22 10:22:51 +02:00
|
|
|
setopt_err_t options_trial_assign(config_line_t *list, int use_defaults,
|
|
|
|
int clear_first, char **msg);
|
2012-09-12 23:34:50 +02:00
|
|
|
|
2011-06-14 19:01:38 +02:00
|
|
|
int resolve_my_address(int warn_severity, const or_options_t *options,
|
2013-02-10 22:45:48 +01:00
|
|
|
uint32_t *addr_out,
|
2013-02-11 23:09:10 +01:00
|
|
|
const char **method_out, char **hostname_out,
|
|
|
|
int use_cached_addr);
|
2011-11-25 17:56:00 +01:00
|
|
|
int is_local_addr(const tor_addr_t *addr);
|
2010-07-22 10:22:51 +02:00
|
|
|
void options_init(or_options_t *options);
|
2011-06-14 19:01:38 +02:00
|
|
|
char *options_dump(const or_options_t *options, int minimal);
|
2010-07-22 10:22:51 +02:00
|
|
|
int options_init_from_torrc(int argc, char **argv);
|
2011-11-28 04:25:52 +01:00
|
|
|
setopt_err_t options_init_from_string(const char *cf_defaults, const char *cf,
|
2010-07-22 10:22:51 +02:00
|
|
|
int command, const char *command_arg, char **msg);
|
|
|
|
int option_is_recognized(const char *key);
|
|
|
|
const char *option_get_canonical_name(const char *key);
|
2011-06-14 19:01:38 +02:00
|
|
|
config_line_t *option_get_assignment(const or_options_t *options,
|
2010-07-22 10:22:51 +02:00
|
|
|
const char *key);
|
|
|
|
int options_save_current(void);
|
2011-11-28 04:25:52 +01:00
|
|
|
const char *get_torrc_fname(int defaults_fname);
|
2011-06-14 19:01:38 +02:00
|
|
|
char *options_get_datadir_fname2_suffix(const or_options_t *options,
|
2010-07-22 10:22:51 +02:00
|
|
|
const char *sub1, const char *sub2,
|
|
|
|
const char *suffix);
|
|
|
|
#define get_datadir_fname2_suffix(sub1, sub2, suffix) \
|
|
|
|
options_get_datadir_fname2_suffix(get_options(), (sub1), (sub2), (suffix))
|
|
|
|
/** Return a newly allocated string containing datadir/sub1. See
|
|
|
|
* get_datadir_fname2_suffix. */
|
|
|
|
#define get_datadir_fname(sub1) get_datadir_fname2_suffix((sub1), NULL, NULL)
|
|
|
|
/** Return a newly allocated string containing datadir/sub1/sub2. See
|
|
|
|
* get_datadir_fname2_suffix. */
|
|
|
|
#define get_datadir_fname2(sub1,sub2) \
|
|
|
|
get_datadir_fname2_suffix((sub1), (sub2), NULL)
|
|
|
|
/** Return a newly allocated string containing datadir/sub1suffix. See
|
|
|
|
* get_datadir_fname2_suffix. */
|
|
|
|
#define get_datadir_fname_suffix(sub1, suffix) \
|
|
|
|
get_datadir_fname2_suffix((sub1), NULL, (suffix))
|
|
|
|
|
2010-09-28 20:36:28 +02:00
|
|
|
int get_num_cpus(const or_options_t *options);
|
|
|
|
|
2011-11-08 22:10:38 +01:00
|
|
|
const smartlist_t *get_configured_ports(void);
|
2011-11-29 11:00:43 +01:00
|
|
|
int get_first_advertised_port_by_type_af(int listener_type,
|
|
|
|
int address_family);
|
2011-11-08 22:10:38 +01:00
|
|
|
#define get_primary_or_port() \
|
2011-11-24 17:49:31 +01:00
|
|
|
(get_first_advertised_port_by_type_af(CONN_TYPE_OR_LISTENER, AF_INET))
|
2011-11-08 22:10:38 +01:00
|
|
|
#define get_primary_dir_port() \
|
2011-11-24 17:49:31 +01:00
|
|
|
(get_first_advertised_port_by_type_af(CONN_TYPE_DIR_LISTENER, AF_INET))
|
Parse prop171 options; refactor listener/port option code
Proposal 171 gives us a new syntax for parsing client port options.
You can now have as many FooPort options as you want (for Foo in
Socks, Trans, DNS, NATD), and they can have address:port arguments,
and you can specify the level of isolation on those ports.
Additionally, this patch refactors the client port parsing logic to
use a new type, port_cfg_t. Previously, ports to be bound were
half-parsed in config.c, and later re-parsed in connection.c when
we're about to bind them. Now, parsing a port means converting it
into a port_cfg_t, and binding it uses only a port_cfg_t, without
needing to parse the user-provided strings at all.
We should do a related refactoring on other port types. For
control ports, that'll be easy enough. For ORPort and DirPort,
we'll want to do this when we solve proposal 118 (letting servers
bind to and advertise multiple ports).
This implements tickets 3514 and 3515.
2011-06-30 20:01:02 +02:00
|
|
|
|
2012-04-12 22:42:37 +02:00
|
|
|
char *get_first_listener_addrport_string(int listener_type);
|
2012-03-31 14:04:58 +02:00
|
|
|
|
2011-06-14 19:01:38 +02:00
|
|
|
int options_need_geoip_info(const or_options_t *options,
|
|
|
|
const char **reason_out);
|
2011-10-07 22:05:13 +02:00
|
|
|
|
2012-06-29 18:32:34 +02:00
|
|
|
smartlist_t *get_list_of_ports_to_forward(void);
|
|
|
|
|
2010-07-22 10:22:51 +02:00
|
|
|
int getinfo_helper_config(control_connection_t *conn,
|
|
|
|
const char *question, char **answer,
|
|
|
|
const char **errmsg);
|
|
|
|
|
|
|
|
const char *tor_get_digests(void);
|
2011-06-14 19:01:38 +02:00
|
|
|
uint32_t get_effective_bwrate(const or_options_t *options);
|
|
|
|
uint32_t get_effective_bwburst(const or_options_t *options);
|
2010-07-22 10:22:51 +02:00
|
|
|
|
2012-10-30 03:17:13 +01:00
|
|
|
char *get_transport_bindaddr_from_config(const char *transport);
|
|
|
|
|
2010-07-22 10:22:51 +02:00
|
|
|
#ifdef CONFIG_PRIVATE
|
|
|
|
/* Used only by config.c and test.c */
|
|
|
|
or_options_t *options_new(void);
|
|
|
|
#endif
|
|
|
|
|
2011-07-13 18:12:16 +02:00
|
|
|
void config_register_addressmaps(const or_options_t *options);
|
2012-08-15 23:49:18 +02:00
|
|
|
/* XXXX024 move to connection_edge.h */
|
|
|
|
int addressmap_register_auto(const char *from, const char *to,
|
|
|
|
time_t expires,
|
|
|
|
addressmap_entry_source_t addrmap_source,
|
|
|
|
const char **msg);
|
|
|
|
|
2010-07-22 10:22:51 +02:00
|
|
|
#endif
|
|
|
|
|