Change the PublishServerDescriptor config option from a boolean

into a string: "v1", "v2", bridge", "". Continue to support
"0" and "1".


svn:r10136
This commit is contained in:
Roger Dingledine 2007-05-08 09:09:26 +00:00
parent 89753e2163
commit e4f40dd794
3 changed files with 61 additions and 18 deletions

View File

@ -210,7 +210,7 @@ static config_var_t _option_vars[] = {
VAR("PidFile", STRING, PidFile, NULL),
VAR("PreferTunneledDirConns", BOOL, PreferTunneledDirConns, "0"),
VAR("ProtocolWarnings", BOOL, ProtocolWarnings, "0"),
VAR("PublishServerDescriptor",BOOL, PublishServerDescriptor,"1"),
VAR("PublishServerDescriptor",STRING,PublishServerDescriptor,"v2"),
VAR("PublishHidServDescriptors",BOOL,PublishHidServDescriptors, "1"),
VAR("ReachableAddresses", LINELIST, ReachableAddresses, NULL),
VAR("ReachableDirAddresses",LINELIST,ReachableDirAddresses,NULL),
@ -450,7 +450,7 @@ static config_var_description_t options_description[] = {
"and servers." },
{ "ORListenAddress", "Bind to this address to listen for connections from "
"clients and servers, instead of the default 0.0.0.0:ORPort." },
{ "PublishServerDescriptors", "Set to 0 in order to keep the server from "
{ "PublishServerDescriptors", "Set to \"\" to keep the server from "
"uploading info to the directory authorities." },
/*{ "RedirectExit", "When an outgoing connection tries to connect to a "
*"given address, redirect it to another address instead." },
@ -1915,7 +1915,7 @@ resolve_my_address(int warn_severity, or_options_t *options,
tor_inet_ntoa(&in,tmpbuf,sizeof(tmpbuf));
if (is_internal_IP(ntohl(in.s_addr), 0) &&
options->PublishServerDescriptor) {
options->_PublishServerDescriptor != NO_AUTHORITY) {
/* make sure we're ok with publishing an internal IP */
if (!options->DirServers) {
/* if they are using the default dirservers, disallow internal IPs
@ -2294,6 +2294,30 @@ ensure_bandwidth_cap(uint64_t value, const char *desc, char **msg)
return 0;
}
/** Parse an authority type from <b>string</b> and write it to *<b>auth</b>.
* If <b>compatible</b> is non-zero, treat "1" as "v2" and treat "0" as "".
* Return 0 on success or -1 if not a recognized authority type.
*/
static int
parse_authority_type_from_string(const char *string, authority_type_t *auth,
int compatible)
{
tor_assert(auth);
if (!strcasecmp(string, "v1"))
*auth = V1_AUTHORITY;
else if (!strcasecmp(string, "v2") || (compatible && !strcmp(string, "1")))
*auth = V2_AUTHORITY;
else if (!strcasecmp(string, "bridge"))
*auth = BRIDGE_AUTHORITY;
else if (!strcasecmp(string, "hidserv"))
*auth = HIDSERV_AUTHORITY;
else if (!strcasecmp(string, "") || (compatible && !strcmp(string, "0")))
*auth = NO_AUTHORITY;
else
return -1;
return 0;
}
/** Lowest allowable value for RendPostPeriod; if this is too low, hidden
* services can overload the directory system. */
#define MIN_REND_POST_PERIOD (10*60)
@ -2435,7 +2459,8 @@ options_validate(or_options_t *old_options, or_options_t *options,
if (options->NoPublish) {
log(LOG_WARN, LD_CONFIG,
"NoPublish is obsolete. Use PublishServerDescriptor instead.");
options->PublishServerDescriptor = 0;
tor_free(options->PublishServerDescriptor);
options->PublishServerDescriptor = tor_strdup("");
}
if (authdir_mode(options)) {
@ -2642,6 +2667,15 @@ options_validate(or_options_t *old_options, or_options_t *options,
});
}
if (parse_authority_type_from_string(options->PublishServerDescriptor,
&options->_PublishServerDescriptor, 1) < 0) {
r = tor_snprintf(buf, sizeof(buf),
"Unrecognized value '%s' for PublishServerDescriptor",
options->PublishServerDescriptor);
*msg = tor_strdup(r >= 0 ? buf : "internal error");
return -1;
}
#if 0
if (options->SocksPort >= 1 &&
(options->PathlenCoinWeight < 0.0 || options->PathlenCoinWeight >= 1.0))
@ -2910,8 +2944,8 @@ options_transition_affects_descriptor(or_options_t *old_options,
old_options->DirPort != new_options->DirPort ||
old_options->ClientOnly != new_options->ClientOnly ||
old_options->NoPublish != new_options->NoPublish ||
old_options->PublishServerDescriptor !=
new_options->PublishServerDescriptor ||
old_options->_PublishServerDescriptor !=
new_options->_PublishServerDescriptor ||
old_options->BandwidthRate != new_options->BandwidthRate ||
old_options->BandwidthBurst != new_options->BandwidthBurst ||
!opt_streq(old_options->ContactInfo, new_options->ContactInfo) ||

View File

@ -1308,6 +1308,11 @@ typedef struct authority_cert_t {
time_t expires;
} authority_cert_t;
typedef enum {
NO_AUTHORITY=0, V1_AUTHORITY, V2_AUTHORITY,
HIDSERV_AUTHORITY, BRIDGE_AUTHORITY
} authority_type_t;
#define CRYPT_PATH_MAGIC 0x70127012u
/** Holds accounting information for a single step in the layered encryption
@ -1683,8 +1688,9 @@ typedef struct {
char *RendExcludeNodes; /**< Comma-separated list of nicknames not to use
* as introduction points. */
smartlist_t *AllowInvalidNodes; /**< List of "entry", "middle", "exit" */
int _AllowInvalid; /**< Bitmask; derived from AllowInvalidNodes; */
/** List of "entry", "middle", "exit", "introduction", "rendezvous". */
smartlist_t *AllowInvalidNodes;
int _AllowInvalid; /**< Bitmask; derived from AllowInvalidNodes. */
config_line_t *ExitPolicy; /**< Lists of exit policy components. */
int ExitPolicyRejectPrivate; /**< Should we not exit to local addresses? */
config_line_t *SocksPolicy; /**< Lists of socks policy components */
@ -1740,9 +1746,15 @@ typedef struct {
int AvoidDiskWrites; /**< Boolean: should we never cache things to disk?
* Not used yet. */
int ClientOnly; /**< Boolean: should we never evolve into a server role? */
int NoPublish; /**< Boolean: should we never publish a descriptor? */
int PublishServerDescriptor; /**< Do we publish our descriptor as normal? */
int PublishHidServDescriptors; /**< and our hidden service descriptors? */
/** Boolean: should we never publish a descriptor? Deprecated. */
int NoPublish;
/** To what authority types do we publish our descriptor? Choices are
* "v1", "v2", "bridge", or "". */
char *PublishServerDescriptor;
/** An authority type, derived from PublishServerDescriptor. */
authority_type_t _PublishServerDescriptor;
/** Boolean: do we publish hidden service descriptors to the HS auths? */
int PublishHidServDescriptors;
int FetchServerDescriptors; /**< Do we fetch server descriptors as normal? */
int FetchHidServDescriptors; /** and hidden service descriptors? */
int FetchUselessDescriptors; /**< Do we fetch non-running descriptors too? */
@ -2497,9 +2509,6 @@ int assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type,
/********************************* directory.c ***************************/
typedef enum {
V1_AUTHORITY, V2_AUTHORITY, HIDSERV_AUTHORITY, BRIDGE_AUTHORITY
} authority_type_t;
void directory_post_to_dirservers(uint8_t purpose, authority_type_t type,
const char *payload,
size_t payload_len, size_t extrainfo_len);

View File

@ -528,7 +528,7 @@ router_orport_found_reachable(void)
routerinfo_t *me = router_get_my_routerinfo();
log_notice(LD_OR,"Self-testing indicates your ORPort is reachable from "
"the outside. Excellent.%s",
get_options()->PublishServerDescriptor ?
get_options()->_PublishServerDescriptor != NO_AUTHORITY ?
" Publishing server descriptor." : "");
can_reach_or_port = 1;
mark_my_descriptor_dirty();
@ -676,7 +676,7 @@ proxy_mode(or_options_t *options)
/** Decide if we're a publishable server. We are a publishable server if:
* - We don't have the ClientOnly option set
* and
* - We have the PublishServerDescriptor option set
* - We have the PublishServerDescriptor option set to non-empty
* and
* - We have ORPort set
* and
@ -690,7 +690,7 @@ decide_if_publishable_server(void)
if (options->ClientOnly)
return 0;
if (!options->PublishServerDescriptor)
if (options->_PublishServerDescriptor == NO_AUTHORITY)
return 0;
if (!server_mode(options))
return 0;
@ -771,7 +771,7 @@ router_upload_dir_desc_to_dirservers(int force)
return;
}
ei = router_get_my_extrainfo();
if (!get_options()->PublishServerDescriptor)
if (get_options()->_PublishServerDescriptor == NO_AUTHORITY)
return;
if (!force && !desc_needs_upload)
return;