1. 15 Nov, 2012 8 commits
    • Nick Mathewson's avatar
      85e8d35f
    • Nick Mathewson's avatar
      Actually send back correctly-formed IPv6 CONNECTED cells · 882b3896
      Nick Mathewson authored
      We had some old code to send back connected cells for IPv6 addresses,
      but it was wrong.  Fortunately, it was also unreachable.
      882b3896
    • Nick Mathewson's avatar
      Revise the DNS subsystem to handle IPv6 exits. · 2889bd26
      Nick Mathewson authored
      Now, every cached_resolve_t can remember an IPv4 result *and* an IPv6
      result.  As a light protection against timing-based distinguishers for
      IPv6 users (and against complexity!), every forward request generates
      an IPv4 *and* an IPv6 request, assuming that we're an IPv6 exit.  Once
      we have answers or errors for both, we act accordingly.
      
      This patch additionally makes some useful refactorings in the dns.c
      code, though there is quite a bit more of useful refactoring that could
      be done.
      
      Additionally, have a new interface for the argument passed to the
      evdns_callback function.  Previously, it was just the original address
      we were resolving.  But it turns out that, on error, evdns doesn't
      tell you the type of the query, so on a failure we didn't know whether
      IPv4 or IPv6 queries were failing.
      
      The new convention is to have the first byte of that argument include
      the query type.  I've refactored the code a bit to make that simpler.
      2889bd26
    • Nick Mathewson's avatar
      Whitespace cleanup · 25cf286f
      Nick Mathewson authored
      25cf286f
    • Nick Mathewson's avatar
      Get the client side of receiving an IPv6 address to work · cac53351
      Nick Mathewson authored
      This makes it so we can handle getting an IPv6 in the 3 different
      formats we specified it for in RESOLVED cells,
      END_STREAM_REASON_EXITPOLICY cells, and CONNECTED cells.
      
      We don't cache IPv6 addresses yet, since proposal 205 isn't
      implemented.
      
      There's a refactored function for parsing connected cells; it has unit
      tests.
      cac53351
    • Nick Mathewson's avatar
      Add an IPv6Exit configuration option · 9016d9e8
      Nick Mathewson authored
      Don't advertise an IPv6 exit policy, or accept IPv6 exit requests,
      if IPv6Exit is not true.
      9016d9e8
    • Nick Mathewson's avatar
      Refactor begin cell parsing into its own function, with tests. · 462ebb27
      Nick Mathewson authored
      Add 'flags' argument to begin cells, per proposal 208.
      462ebb27
    • Nick Mathewson's avatar
      Move address map into its own file. · 7908ab20
      Nick Mathewson authored
      7908ab20
  2. 12 Oct, 2012 2 commits
    • Nick Mathewson's avatar
      Rename all reserved C identifiers we defined · 56c0baa5
      Nick Mathewson authored
      For everything we declare that starts with _, make it end with _ instead.
      
      This is a machine-generated patch.  To make it, start by getting the
      list of reserved identifiers using:
      
           git ls-tree -r --name-only HEAD | grep  '\.[ch]$' | \
             xargs ctags --c-kinds=defglmpstuvx -o - | grep '^_' | \
             cut -f 1 | sort| uniq
      
      You might need gnu ctags.
      
      Then pipe the output through this script:
      ==============================
      
      use strict;
      
      BEGIN { print "#!/usr/bin/perl -w -i -p\n\n"; }
      
      chomp;
      
      next if (
           /^__attribute__/ or
           /^__func__/ or
           /^_FILE_OFFSET_BITS/ or
           /^_FORTIFY_SOURCE/ or
           /^_GNU_SOURCE/ or
           /^_WIN32/ or
           /^_DARWIN_UNLIMITED/ or
           /^_FILE_OFFSET_BITS/ or
           /^_LARGEFILE64_SOURCE/ or
           /^_LFS64_LARGEFILE/ or
           /^__cdecl/ or
           /^__attribute__/ or
           /^__func__/ or
          /^_WIN32_WINNT/);
      
      my $ident = $_;
      
      my $better = $ident;
      $better =~ s/^_//;
      
      $better = "${better}_";
      
      print "s/(?<![A-Za-z0-9_])$ident(?![A-Za-z0-9_])/$better/g;\n";
      ==============================
      
      Then run the resulting script on all the files you want to change.
      (That is, all the C except that in src/ext.)  The resulting script was:
      
      ==============================
      
      s/(?<![A-Za-z0-9_])_address(?![A-Za-z0-9_])/address_/g;
      s/(?<![A-Za-z0-9_])_aes_fill_buf(?![A-Za-z0-9_])/aes_fill_buf_/g;
      s/(?<![A-Za-z0-9_])_AllowInvalid(?![A-Za-z0-9_])/AllowInvalid_/g;
      s/(?<![A-Za-z0-9_])_AP_CONN_STATE_MAX(?![A-Za-z0-9_])/AP_CONN_STATE_MAX_/g;
      s/(?<![A-Za-z0-9_])_AP_CONN_STATE_MIN(?![A-Za-z0-9_])/AP_CONN_STATE_MIN_/g;
      s/(?<![A-Za-z0-9_])_assert_cache_ok(?![A-Za-z0-9_])/assert_cache_ok_/g;
      s/(?<![A-Za-z0-9_])_A_UNKNOWN(?![A-Za-z0-9_])/A_UNKNOWN_/g;
      s/(?<![A-Za-z0-9_])_base(?![A-Za-z0-9_])/base_/g;
      s/(?<![A-Za-z0-9_])_BridgePassword_AuthDigest(?![A-Za-z0-9_])/BridgePassword_AuthDigest_/g;
      s/(?<![A-Za-z0-9_])_buffer_stats_compare_entries(?![A-Za-z0-9_])/buffer_stats_compare_entries_/g;
      s/(?<![A-Za-z0-9_])_chan_circid_entries_eq(?![A-Za-z0-9_])/chan_circid_entries_eq_/g;
      s/(?<![A-Za-z0-9_])_chan_circid_entry_hash(?![A-Za-z0-9_])/chan_circid_entry_hash_/g;
      s/(?<![A-Za-z0-9_])_check_no_tls_errors(?![A-Za-z0-9_])/check_no_tls_errors_/g;
      s/(?<![A-Za-z0-9_])_c_hist_compare(?![A-Za-z0-9_])/c_hist_compare_/g;
      s/(?<![A-Za-z0-9_])_circ(?![A-Za-z0-9_])/circ_/g;
      s/(?<![A-Za-z0-9_])_circuit_get_global_list(?![A-Za-z0-9_])/circuit_get_global_list_/g;
      s/(?<![A-Za-z0-9_])_circuit_mark_for_close(?![A-Za-z0-9_])/circuit_mark_for_close_/g;
      s/(?<![A-Za-z0-9_])_CIRCUIT_PURPOSE_C_MAX(?![A-Za-z0-9_])/CIRCUIT_PURPOSE_C_MAX_/g;
      s/(?<![A-Za-z0-9_])_CIRCUIT_PURPOSE_MAX(?![A-Za-z0-9_])/CIRCUIT_PURPOSE_MAX_/g;
      s/(?<![A-Za-z0-9_])_CIRCUIT_PURPOSE_MIN(?![A-Za-z0-9_])/CIRCUIT_PURPOSE_MIN_/g;
      s/(?<![A-Za-z0-9_])_CIRCUIT_PURPOSE_OR_MAX(?![A-Za-z0-9_])/CIRCUIT_PURPOSE_OR_MAX_/g;
      s/(?<![A-Za-z0-9_])_CIRCUIT_PURPOSE_OR_MIN(?![A-Za-z0-9_])/CIRCUIT_PURPOSE_OR_MIN_/g;
      s/(?<![A-Za-z0-9_])_cmp_int_strings(?![A-Za-z0-9_])/cmp_int_strings_/g;
      s/(?<![A-Za-z0-9_])_compare_cached_resolves_by_expiry(?![A-Za-z0-9_])/compare_cached_resolves_by_expiry_/g;
      s/(?<![A-Za-z0-9_])_compare_digests(?![A-Za-z0-9_])/compare_digests_/g;
      s/(?<![A-Za-z0-9_])_compare_digests256(?![A-Za-z0-9_])/compare_digests256_/g;
      s/(?<![A-Za-z0-9_])_compare_dir_src_ents_by_authority_id(?![A-Za-z0-9_])/compare_dir_src_ents_by_authority_id_/g;
      s/(?<![A-Za-z0-9_])_compare_duration_idx(?![A-Za-z0-9_])/compare_duration_idx_/g;
      s/(?<![A-Za-z0-9_])_compare_int(?![A-Za-z0-9_])/compare_int_/g;
      s/(?<![A-Za-z0-9_])_compare_networkstatus_v2_published_on(?![A-Za-z0-9_])/compare_networkstatus_v2_published_on_/g;
      s/(?<![A-Za-z0-9_])_compare_old_routers_by_identity(?![A-Za-z0-9_])/compare_old_routers_by_identity_/g;
      s/(?<![A-Za-z0-9_])_compare_orports(?![A-Za-z0-9_])/compare_orports_/g;
      s/(?<![A-Za-z0-9_])_compare_pairs(?![A-Za-z0-9_])/compare_pairs_/g;
      s/(?<![A-Za-z0-9_])_compare_routerinfo_by_id_digest(?![A-Za-z0-9_])/compare_routerinfo_by_id_digest_/g;
      s/(?<![A-Za-z0-9_])_compare_routerinfo_by_ip_and_bw(?![A-Za-z0-9_])/compare_routerinfo_by_ip_and_bw_/g;
      s/(?<![A-Za-z0-9_])_compare_signed_descriptors_by_age(?![A-Za-z0-9_])/compare_signed_descriptors_by_age_/g;
      s/(?<![A-Za-z0-9_])_compare_string_ptrs(?![A-Za-z0-9_])/compare_string_ptrs_/g;
      s/(?<![A-Za-z0-9_])_compare_strings_for_pqueue(?![A-Za-z0-9_])/compare_strings_for_pqueue_/g;
      s/(?<![A-Za-z0-9_])_compare_strs(?![A-Za-z0-9_])/compare_strs_/g;
      s/(?<![A-Za-z0-9_])_compare_tor_version_str_ptr(?![A-Za-z0-9_])/compare_tor_version_str_ptr_/g;
      s/(?<![A-Za-z0-9_])_compare_vote_rs(?![A-Za-z0-9_])/compare_vote_rs_/g;
      s/(?<![A-Za-z0-9_])_compare_votes_by_authority_id(?![A-Za-z0-9_])/compare_votes_by_authority_id_/g;
      s/(?<![A-Za-z0-9_])_compare_without_first_ch(?![A-Za-z0-9_])/compare_without_first_ch_/g;
      s/(?<![A-Za-z0-9_])_connection_free(?![A-Za-z0-9_])/connection_free_/g;
      s/(?<![A-Za-z0-9_])_connection_mark_and_flush(?![A-Za-z0-9_])/connection_mark_and_flush_/g;
      s/(?<![A-Za-z0-9_])_connection_mark_for_close(?![A-Za-z0-9_])/connection_mark_for_close_/g;
      s/(?<![A-Za-z0-9_])_connection_mark_unattached_ap(?![A-Za-z0-9_])/connection_mark_unattached_ap_/g;
      s/(?<![A-Za-z0-9_])_connection_write_to_buf_impl(?![A-Za-z0-9_])/connection_write_to_buf_impl_/g;
      s/(?<![A-Za-z0-9_])_ConnLimit(?![A-Za-z0-9_])/ConnLimit_/g;
      s/(?<![A-Za-z0-9_])_CONN_TYPE_MAX(?![A-Za-z0-9_])/CONN_TYPE_MAX_/g;
      s/(?<![A-Za-z0-9_])_CONN_TYPE_MIN(?![A-Za-z0-9_])/CONN_TYPE_MIN_/g;
      s/(?<![A-Za-z0-9_])_CONTROL_CONN_STATE_MAX(?![A-Za-z0-9_])/CONTROL_CONN_STATE_MAX_/g;
      s/(?<![A-Za-z0-9_])_CONTROL_CONN_STATE_MIN(?![A-Za-z0-9_])/CONTROL_CONN_STATE_MIN_/g;
      s/(?<![A-Za-z0-9_])_CPUWORKER_STATE_MAX(?![A-Za-z0-9_])/CPUWORKER_STATE_MAX_/g;
      s/(?<![A-Za-z0-9_])_CPUWORKER_STATE_MIN(?![A-Za-z0-9_])/CPUWORKER_STATE_MIN_/g;
      s/(?<![A-Za-z0-9_])_crypto_dh_get_dh(?![A-Za-z0-9_])/crypto_dh_get_dh_/g;
      s/(?<![A-Za-z0-9_])_crypto_global_initialized(?![A-Za-z0-9_])/crypto_global_initialized_/g;
      s/(?<![A-Za-z0-9_])_crypto_new_pk_from_rsa(?![A-Za-z0-9_])/crypto_new_pk_from_rsa_/g;
      s/(?<![A-Za-z0-9_])_crypto_pk_get_evp_pkey(?![A-Za-z0-9_])/crypto_pk_get_evp_pkey_/g;
      s/(?<![A-Za-z0-9_])_crypto_pk_get_rsa(?![A-Za-z0-9_])/crypto_pk_get_rsa_/g;
      s/(?<![A-Za-z0-9_])_DIR_CONN_STATE_MAX(?![A-Za-z0-9_])/DIR_CONN_STATE_MAX_/g;
      s/(?<![A-Za-z0-9_])_DIR_CONN_STATE_MIN(?![A-Za-z0-9_])/DIR_CONN_STATE_MIN_/g;
      s/(?<![A-Za-z0-9_])_DIR_PURPOSE_MAX(?![A-Za-z0-9_])/DIR_PURPOSE_MAX_/g;
      s/(?<![A-Za-z0-9_])_DIR_PURPOSE_MIN(?![A-Za-z0-9_])/DIR_PURPOSE_MIN_/g;
      s/(?<![A-Za-z0-9_])_dirreq_map_get(?![A-Za-z0-9_])/dirreq_map_get_/g;
      s/(?<![A-Za-z0-9_])_dirreq_map_put(?![A-Za-z0-9_])/dirreq_map_put_/g;
      s/(?<![A-Za-z0-9_])_dns_randfn(?![A-Za-z0-9_])/dns_randfn_/g;
      s/(?<![A-Za-z0-9_])_dummy(?![A-Za-z0-9_])/dummy_/g;
      s/(?<![A-Za-z0-9_])_edge(?![A-Za-z0-9_])/edge_/g;
      s/(?<![A-Za-z0-9_])_END_CIRC_REASON_MAX(?![A-Za-z0-9_])/END_CIRC_REASON_MAX_/g;
      s/(?<![A-Za-z0-9_])_END_CIRC_REASON_MIN(?![A-Za-z0-9_])/END_CIRC_REASON_MIN_/g;
      s/(?<![A-Za-z0-9_])_EOF(?![A-Za-z0-9_])/EOF_/g;
      s/(?<![A-Za-z0-9_])_ERR(?![A-Za-z0-9_])/ERR_/g;
      s/(?<![A-Za-z0-9_])_escaped_val(?![A-Za-z0-9_])/escaped_val_/g;
      s/(?<![A-Za-z0-9_])_evdns_log(?![A-Za-z0-9_])/evdns_log_/g;
      s/(?<![A-Za-z0-9_])_evdns_nameserver_add_impl(?![A-Za-z0-9_])/evdns_nameserver_add_impl_/g;
      s/(?<![A-Za-z0-9_])_EVENT_MAX(?![A-Za-z0-9_])/EVENT_MAX_/g;
      s/(?<![A-Za-z0-9_])_EVENT_MIN(?![A-Za-z0-9_])/EVENT_MIN_/g;
      s/(?<![A-Za-z0-9_])_ExcludeExitNodesUnion(?![A-Za-z0-9_])/ExcludeExitNodesUnion_/g;
      s/(?<![A-Za-z0-9_])_EXIT_CONN_STATE_MAX(?![A-Za-z0-9_])/EXIT_CONN_STATE_MAX_/g;
      s/(?<![A-Za-z0-9_])_EXIT_CONN_STATE_MIN(?![A-Za-z0-9_])/EXIT_CONN_STATE_MIN_/g;
      s/(?<![A-Za-z0-9_])_EXIT_PURPOSE_MAX(?![A-Za-z0-9_])/EXIT_PURPOSE_MAX_/g;
      s/(?<![A-Za-z0-9_])_EXIT_PURPOSE_MIN(?![A-Za-z0-9_])/EXIT_PURPOSE_MIN_/g;
      s/(?<![A-Za-z0-9_])_extrainfo_free(?![A-Za-z0-9_])/extrainfo_free_/g;
      s/(?<![A-Za-z0-9_])_find_by_keyword(?![A-Za-z0-9_])/find_by_keyword_/g;
      s/(?<![A-Za-z0-9_])_free_cached_dir(?![A-Za-z0-9_])/free_cached_dir_/g;
      s/(?<![A-Za-z0-9_])_free_cached_resolve(?![A-Za-z0-9_])/free_cached_resolve_/g;
      s/(?<![A-Za-z0-9_])_free_duplicate_routerstatus_entry(?![A-Za-z0-9_])/free_duplicate_routerstatus_entry_/g;
      s/(?<![A-Za-z0-9_])_free_link_history(?![A-Za-z0-9_])/free_link_history_/g;
      s/(?<![A-Za-z0-9_])_geoip_compare_entries(?![A-Za-z0-9_])/geoip_compare_entries_/g;
      s/(?<![A-Za-z0-9_])_geoip_compare_key_to_entry(?![A-Za-z0-9_])/geoip_compare_key_to_entry_/g;
      s/(?<![A-Za-z0-9_])_hex_decode_digit(?![A-Za-z0-9_])/hex_decode_digit_/g;
      s/(?<![A-Za-z0-9_])_idxplus1(?![A-Za-z0-9_])/idxplus1_/g;
      s/(?<![A-Za-z0-9_])__libc_enable_secure(?![A-Za-z0-9_])/_libc_enable_secure_/g;
      s/(?<![A-Za-z0-9_])_log_debug(?![A-Za-z0-9_])/log_debug_/g;
      s/(?<![A-Za-z0-9_])_log_err(?![A-Za-z0-9_])/log_err_/g;
      s/(?<![A-Za-z0-9_])_log_fn(?![A-Za-z0-9_])/log_fn_/g;
      s/(?<![A-Za-z0-9_])_log_fn_function_name(?![A-Za-z0-9_])/log_fn_function_name_/g;
      s/(?<![A-Za-z0-9_])_log_global_min_severity(?![A-Za-z0-9_])/log_global_min_severity_/g;
      s/(?<![A-Za-z0-9_])_log_info(?![A-Za-z0-9_])/log_info_/g;
      s/(?<![A-Za-z0-9_])_log_notice(?![A-Za-z0-9_])/log_notice_/g;
      s/(?<![A-Za-z0-9_])_log_prefix(?![A-Za-z0-9_])/log_prefix_/g;
      s/(?<![A-Za-z0-9_])_log_warn(?![A-Za-z0-9_])/log_warn_/g;
      s/(?<![A-Za-z0-9_])_magic(?![A-Za-z0-9_])/magic_/g;
      s/(?<![A-Za-z0-9_])_MALLOC_LOCK(?![A-Za-z0-9_])/MALLOC_LOCK_/g;
      s/(?<![A-Za-z0-9_])_MALLOC_LOCK_INIT(?![A-Za-z0-9_])/MALLOC_LOCK_INIT_/g;
      s/(?<![A-Za-z0-9_])_MALLOC_UNLOCK(?![A-Za-z0-9_])/MALLOC_UNLOCK_/g;
      s/(?<![A-Za-z0-9_])_microdesc_eq(?![A-Za-z0-9_])/microdesc_eq_/g;
      s/(?<![A-Za-z0-9_])_microdesc_hash(?![A-Za-z0-9_])/microdesc_hash_/g;
      s/(?<![A-Za-z0-9_])_MIN_TOR_TLS_ERROR_VAL(?![A-Za-z0-9_])/MIN_TOR_TLS_ERROR_VAL_/g;
      s/(?<![A-Za-z0-9_])_mm_free(?![A-Za-z0-9_])/mm_free_/g;
      s/(?<![A-Za-z0-9_])_NIL(?![A-Za-z0-9_])/NIL_/g;
      s/(?<![A-Za-z0-9_])_n_openssl_mutexes(?![A-Za-z0-9_])/n_openssl_mutexes_/g;
      s/(?<![A-Za-z0-9_])_openssl_dynlock_create_cb(?![A-Za-z0-9_])/openssl_dynlock_create_cb_/g;
      s/(?<![A-Za-z0-9_])_openssl_dynlock_destroy_cb(?![A-Za-z0-9_])/openssl_dynlock_destroy_cb_/g;
      s/(?<![A-Za-z0-9_])_openssl_dynlock_lock_cb(?![A-Za-z0-9_])/openssl_dynlock_lock_cb_/g;
      s/(?<![A-Za-z0-9_])_openssl_locking_cb(?![A-Za-z0-9_])/openssl_locking_cb_/g;
      s/(?<![A-Za-z0-9_])_openssl_mutexes(?![A-Za-z0-9_])/openssl_mutexes_/g;
      s/(?<![A-Za-z0-9_])_option_abbrevs(?![A-Za-z0-9_])/option_abbrevs_/g;
      s/(?<![A-Za-z0-9_])_option_vars(?![A-Za-z0-9_])/option_vars_/g;
      s/(?<![A-Za-z0-9_])_OR_CONN_STATE_MAX(?![A-Za-z0-9_])/OR_CONN_STATE_MAX_/g;
      s/(?<![A-Za-z0-9_])_OR_CONN_STATE_MIN(?![A-Za-z0-9_])/OR_CONN_STATE_MIN_/g;
      s/(?<![A-Za-z0-9_])_OutboundBindAddressIPv4(?![A-Za-z0-9_])/OutboundBindAddressIPv4_/g;
      s/(?<![A-Za-z0-9_])_OutboundBindAddressIPv6(?![A-Za-z0-9_])/OutboundBindAddressIPv6_/g;
      s/(?<![A-Za-z0-9_])_PDS_PREFER_TUNNELED_DIR_CONNS(?![A-Za-z0-9_])/PDS_PREFER_TUNNELED_DIR_CONNS_/g;
      s/(?<![A-Za-z0-9_])_port(?![A-Za-z0-9_])/port_/g;
      s/(?<![A-Za-z0-9_])__progname(?![A-Za-z0-9_])/_progname_/g;
      s/(?<![A-Za-z0-9_])_PublishServerDescriptor(?![A-Za-z0-9_])/PublishServerDescriptor_/g;
      s/(?<![A-Za-z0-9_])_remove_old_client_helper(?![A-Za-z0-9_])/remove_old_client_helper_/g;
      s/(?<![A-Za-z0-9_])_rend_cache_entry_free(?![A-Za-z0-9_])/rend_cache_entry_free_/g;
      s/(?<![A-Za-z0-9_])_routerlist_find_elt(?![A-Za-z0-9_])/routerlist_find_elt_/g;
      s/(?<![A-Za-z0-9_])_SafeLogging(?![A-Za-z0-9_])/SafeLogging_/g;
      s/(?<![A-Za-z0-9_])_SHORT_FILE_(?![A-Za-z0-9_])/SHORT_FILE__/g;
      s/(?<![A-Za-z0-9_])_state_abbrevs(?![A-Za-z0-9_])/state_abbrevs_/g;
      s/(?<![A-Za-z0-9_])_state_vars(?![A-Za-z0-9_])/state_vars_/g;
      s/(?<![A-Za-z0-9_])_t(?![A-Za-z0-9_])/t_/g;
      s/(?<![A-Za-z0-9_])_t32(?![A-Za-z0-9_])/t32_/g;
      s/(?<![A-Za-z0-9_])_test_op_ip6(?![A-Za-z0-9_])/test_op_ip6_/g;
      s/(?<![A-Za-z0-9_])_thread1_name(?![A-Za-z0-9_])/thread1_name_/g;
      s/(?<![A-Za-z0-9_])_thread2_name(?![A-Za-z0-9_])/thread2_name_/g;
      s/(?<![A-Za-z0-9_])_thread_test_func(?![A-Za-z0-9_])/thread_test_func_/g;
      s/(?<![A-Za-z0-9_])_thread_test_mutex(?![A-Za-z0-9_])/thread_test_mutex_/g;
      s/(?<![A-Za-z0-9_])_thread_test_start1(?![A-Za-z0-9_])/thread_test_start1_/g;
      s/(?<![A-Za-z0-9_])_thread_test_start2(?![A-Za-z0-9_])/thread_test_start2_/g;
      s/(?<![A-Za-z0-9_])_thread_test_strmap(?![A-Za-z0-9_])/thread_test_strmap_/g;
      s/(?<![A-Za-z0-9_])_tor_calloc(?![A-Za-z0-9_])/tor_calloc_/g;
      s/(?<![A-Za-z0-9_])_TOR_CHANNEL_INTERNAL(?![A-Za-z0-9_])/TOR_CHANNEL_INTERNAL_/g;
      s/(?<![A-Za-z0-9_])_TOR_CIRCUITMUX_EWMA_C(?![A-Za-z0-9_])/TOR_CIRCUITMUX_EWMA_C_/g;
      s/(?<![A-Za-z0-9_])_tor_free(?![A-Za-z0-9_])/tor_free_/g;
      s/(?<![A-Za-z0-9_])_tor_malloc(?![A-Za-z0-9_])/tor_malloc_/g;
      s/(?<![A-Za-z0-9_])_tor_malloc_zero(?![A-Za-z0-9_])/tor_malloc_zero_/g;
      s/(?<![A-Za-z0-9_])_tor_memdup(?![A-Za-z0-9_])/tor_memdup_/g;
      s/(?<![A-Za-z0-9_])_tor_realloc(?![A-Za-z0-9_])/tor_realloc_/g;
      s/(?<![A-Za-z0-9_])_tor_strdup(?![A-Za-z0-9_])/tor_strdup_/g;
      s/(?<![A-Za-z0-9_])_tor_strndup(?![A-Za-z0-9_])/tor_strndup_/g;
      s/(?<![A-Za-z0-9_])_TOR_TLS_SYSCALL(?![A-Za-z0-9_])/TOR_TLS_SYSCALL_/g;
      s/(?<![A-Za-z0-9_])_TOR_TLS_ZERORETURN(?![A-Za-z0-9_])/TOR_TLS_ZERORETURN_/g;
      s/(?<![A-Za-z0-9_])__USE_ISOC99(?![A-Za-z0-9_])/_USE_ISOC99_/g;
      s/(?<![A-Za-z0-9_])_UsingTestNetworkDefaults(?![A-Za-z0-9_])/UsingTestNetworkDefaults_/g;
      s/(?<![A-Za-z0-9_])_val(?![A-Za-z0-9_])/val_/g;
      s/(?<![A-Za-z0-9_])_void_for_alignment(?![A-Za-z0-9_])/void_for_alignment_/g;
      
      ==============================
      56c0baa5
    • Nick Mathewson's avatar
      Convert all include-guard macros to avoid reserved identifiers. · 0cb921f3
      Nick Mathewson authored
      In C, we technically aren't supposed to define our own things that
      start with an underscore.
      
      This is a purely machine-generated commit.  First, I ran this script
      on all the headers in src/{common,or,test,tools/*}/*.h :
      ==============================
      
      use strict;
      
      my %macros = ();
      my %skipped = ();
      FILE: for my $fn (@ARGV) {
          my $f = $fn;
          if ($fn !~ /^\.\//) {
      	$f = "./$fn";
          }
          $skipped{$fn} = 0;
          open(F, $fn);
          while (<F>) {
      	if (/^#ifndef ([A-Za-z0-9_]+)/) {
      	    $macros{$fn} = $1;
      	    next FILE;
      	}
          }
      }
      
      print "#!/usr/bin/perl -w -i -p\n\n";
      for my $fn (@ARGV) {
          if (! exists $macros{$fn}) {
      	print "# No macro known for $fn!\n" if (!$skipped{$fn});
      	next;
          }
          if ($macros{$fn} !~ /_H_?$/) {
      	print "# Weird macro for $fn...\n";
          }
          my $goodmacro = uc $fn;
          $goodmacro =~ s#.*/##;
          $goodmacro =~ s#[\/\-\.]#_#g;
          print "s/(?<![A-Za-z0-9_])$macros{$fn}(?![A-Za-z0-9_])/TOR_${goodmacro}/g;\n"
      }
      ==============================
      
      It produced the following output, which I then re-ran on those same files:
      
      ==============================
      
      s/(?<![A-Za-z0-9_])_TOR_ADDRESS_H(?![A-Za-z0-9_])/TOR_ADDRESS_H/g;
      s/(?<![A-Za-z0-9_])_TOR_AES_H(?![A-Za-z0-9_])/TOR_AES_H/g;
      s/(?<![A-Za-z0-9_])_TOR_COMPAT_H(?![A-Za-z0-9_])/TOR_COMPAT_H/g;
      s/(?<![A-Za-z0-9_])_TOR_COMPAT_LIBEVENT_H(?![A-Za-z0-9_])/TOR_COMPAT_LIBEVENT_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CONTAINER_H(?![A-Za-z0-9_])/TOR_CONTAINER_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CRYPTO_H(?![A-Za-z0-9_])/TOR_CRYPTO_H/g;
      s/(?<![A-Za-z0-9_])TOR_DI_OPS_H(?![A-Za-z0-9_])/TOR_DI_OPS_H/g;
      s/(?<![A-Za-z0-9_])_TOR_MEMAREA_H(?![A-Za-z0-9_])/TOR_MEMAREA_H/g;
      s/(?<![A-Za-z0-9_])_TOR_MEMPOOL_H(?![A-Za-z0-9_])/TOR_MEMPOOL_H/g;
      s/(?<![A-Za-z0-9_])TOR_PROCMON_H(?![A-Za-z0-9_])/TOR_PROCMON_H/g;
      s/(?<![A-Za-z0-9_])_TOR_TORGZIP_H(?![A-Za-z0-9_])/TOR_TORGZIP_H/g;
      s/(?<![A-Za-z0-9_])_TOR_TORINT_H(?![A-Za-z0-9_])/TOR_TORINT_H/g;
      s/(?<![A-Za-z0-9_])_TOR_LOG_H(?![A-Za-z0-9_])/TOR_TORLOG_H/g;
      s/(?<![A-Za-z0-9_])_TOR_TORTLS_H(?![A-Za-z0-9_])/TOR_TORTLS_H/g;
      s/(?<![A-Za-z0-9_])_TOR_UTIL_H(?![A-Za-z0-9_])/TOR_UTIL_H/g;
      s/(?<![A-Za-z0-9_])_TOR_BUFFERS_H(?![A-Za-z0-9_])/TOR_BUFFERS_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CHANNEL_H(?![A-Za-z0-9_])/TOR_CHANNEL_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CHANNEL_TLS_H(?![A-Za-z0-9_])/TOR_CHANNELTLS_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CIRCUITBUILD_H(?![A-Za-z0-9_])/TOR_CIRCUITBUILD_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CIRCUITLIST_H(?![A-Za-z0-9_])/TOR_CIRCUITLIST_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CIRCUITMUX_EWMA_H(?![A-Za-z0-9_])/TOR_CIRCUITMUX_EWMA_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CIRCUITMUX_H(?![A-Za-z0-9_])/TOR_CIRCUITMUX_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CIRCUITUSE_H(?![A-Za-z0-9_])/TOR_CIRCUITUSE_H/g;
      s/(?<![A-Za-z0-9_])_TOR_COMMAND_H(?![A-Za-z0-9_])/TOR_COMMAND_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CONFIG_H(?![A-Za-z0-9_])/TOR_CONFIG_H/g;
      s/(?<![A-Za-z0-9_])TOR_CONFPARSE_H(?![A-Za-z0-9_])/TOR_CONFPARSE_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CONNECTION_EDGE_H(?![A-Za-z0-9_])/TOR_CONNECTION_EDGE_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CONNECTION_H(?![A-Za-z0-9_])/TOR_CONNECTION_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CONNECTION_OR_H(?![A-Za-z0-9_])/TOR_CONNECTION_OR_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CONTROL_H(?![A-Za-z0-9_])/TOR_CONTROL_H/g;
      s/(?<![A-Za-z0-9_])_TOR_CPUWORKER_H(?![A-Za-z0-9_])/TOR_CPUWORKER_H/g;
      s/(?<![A-Za-z0-9_])_TOR_DIRECTORY_H(?![A-Za-z0-9_])/TOR_DIRECTORY_H/g;
      s/(?<![A-Za-z0-9_])_TOR_DIRSERV_H(?![A-Za-z0-9_])/TOR_DIRSERV_H/g;
      s/(?<![A-Za-z0-9_])_TOR_DIRVOTE_H(?![A-Za-z0-9_])/TOR_DIRVOTE_H/g;
      s/(?<![A-Za-z0-9_])_TOR_DNS_H(?![A-Za-z0-9_])/TOR_DNS_H/g;
      s/(?<![A-Za-z0-9_])_TOR_DNSSERV_H(?![A-Za-z0-9_])/TOR_DNSSERV_H/g;
      s/(?<![A-Za-z0-9_])TOR_EVENTDNS_TOR_H(?![A-Za-z0-9_])/TOR_EVENTDNS_TOR_H/g;
      s/(?<![A-Za-z0-9_])_TOR_GEOIP_H(?![A-Za-z0-9_])/TOR_GEOIP_H/g;
      s/(?<![A-Za-z0-9_])_TOR_HIBERNATE_H(?![A-Za-z0-9_])/TOR_HIBERNATE_H/g;
      s/(?<![A-Za-z0-9_])_TOR_MAIN_H(?![A-Za-z0-9_])/TOR_MAIN_H/g;
      s/(?<![A-Za-z0-9_])_TOR_MICRODESC_H(?![A-Za-z0-9_])/TOR_MICRODESC_H/g;
      s/(?<![A-Za-z0-9_])_TOR_NETWORKSTATUS_H(?![A-Za-z0-9_])/TOR_NETWORKSTATUS_H/g;
      s/(?<![A-Za-z0-9_])_TOR_NODELIST_H(?![A-Za-z0-9_])/TOR_NODELIST_H/g;
      s/(?<![A-Za-z0-9_])_TOR_NTMAIN_H(?![A-Za-z0-9_])/TOR_NTMAIN_H/g;
      s/(?<![A-Za-z0-9_])_TOR_ONION_H(?![A-Za-z0-9_])/TOR_ONION_H/g;
      s/(?<![A-Za-z0-9_])_TOR_OR_H(?![A-Za-z0-9_])/TOR_OR_H/g;
      s/(?<![A-Za-z0-9_])_TOR_POLICIES_H(?![A-Za-z0-9_])/TOR_POLICIES_H/g;
      s/(?<![A-Za-z0-9_])_TOR_REASONS_H(?![A-Za-z0-9_])/TOR_REASONS_H/g;
      s/(?<![A-Za-z0-9_])_TOR_RELAY_H(?![A-Za-z0-9_])/TOR_RELAY_H/g;
      s/(?<![A-Za-z0-9_])_TOR_RENDCLIENT_H(?![A-Za-z0-9_])/TOR_RENDCLIENT_H/g;
      s/(?<![A-Za-z0-9_])_TOR_RENDCOMMON_H(?![A-Za-z0-9_])/TOR_RENDCOMMON_H/g;
      s/(?<![A-Za-z0-9_])_TOR_RENDMID_H(?![A-Za-z0-9_])/TOR_RENDMID_H/g;
      s/(?<![A-Za-z0-9_])_TOR_RENDSERVICE_H(?![A-Za-z0-9_])/TOR_RENDSERVICE_H/g;
      s/(?<![A-Za-z0-9_])_TOR_REPHIST_H(?![A-Za-z0-9_])/TOR_REPHIST_H/g;
      s/(?<![A-Za-z0-9_])_TOR_REPLAYCACHE_H(?![A-Za-z0-9_])/TOR_REPLAYCACHE_H/g;
      s/(?<![A-Za-z0-9_])_TOR_ROUTER_H(?![A-Za-z0-9_])/TOR_ROUTER_H/g;
      s/(?<![A-Za-z0-9_])_TOR_ROUTERLIST_H(?![A-Za-z0-9_])/TOR_ROUTERLIST_H/g;
      s/(?<![A-Za-z0-9_])_TOR_ROUTERPARSE_H(?![A-Za-z0-9_])/TOR_ROUTERPARSE_H/g;
      s/(?<![A-Za-z0-9_])TOR_ROUTERSET_H(?![A-Za-z0-9_])/TOR_ROUTERSET_H/g;
      s/(?<![A-Za-z0-9_])TOR_STATEFILE_H(?![A-Za-z0-9_])/TOR_STATEFILE_H/g;
      s/(?<![A-Za-z0-9_])_TOR_STATUS_H(?![A-Za-z0-9_])/TOR_STATUS_H/g;
      s/(?<![A-Za-z0-9_])TOR_TRANSPORTS_H(?![A-Za-z0-9_])/TOR_TRANSPORTS_H/g;
      s/(?<![A-Za-z0-9_])_TOR_TEST_H(?![A-Za-z0-9_])/TOR_TEST_H/g;
      s/(?<![A-Za-z0-9_])_TOR_FW_HELPER_H(?![A-Za-z0-9_])/TOR_TOR_FW_HELPER_H/g;
      s/(?<![A-Za-z0-9_])_TOR_FW_HELPER_NATPMP_H(?![A-Za-z0-9_])/TOR_TOR_FW_HELPER_NATPMP_H/g;
      s/(?<![A-Za-z0-9_])_TOR_FW_HELPER_UPNP_H(?![A-Za-z0-9_])/TOR_TOR_FW_HELPER_UPNP_H/g;
      ==============================
      0cb921f3
  3. 05 Jun, 2012 1 commit
  4. 14 May, 2012 1 commit
  5. 11 May, 2012 1 commit
    • Nick Mathewson's avatar
      An attempt at bug3940 and making AllowDotExit 0 work with MapAddress · 35d08e30
      Nick Mathewson authored
      This time, I follow grarpamp's suggestion and move the check for
      .exit+AllowDotExit 0 to the top of connection_ap_rewrite_and_attach,
      before any rewriting occurs.  This way, .exit addresses are
      forbidden as they arrive from a socks connection or a DNSPort
      request, and not otherwise.
      
      It _is_ a little more complicated than that, though.  We need to
      treat any .exit addresses whose source is TrackHostExits as meaning
      that we can retry without that exit.  We also need to treat any
      .exit address that comes from an AutomapHostsOnResolve operation as
      user-provided (and thus forbidden if AllowDotExits==0), so that
      transitioning from AllowDotExits==1 to AllowDotExits==0 will
      actually turn off automapped .exit addresses.
      35d08e30
  6. 30 Nov, 2011 1 commit
    • Nick Mathewson's avatar
      Refactor addressmap_match_superdomains and representation of wildcards · 69d16900
      Nick Mathewson authored
      In this new representation for wildcarded addresses, there are no
      longer any 'magic addresses': rather, "a.b c.d", "*.a.b c.d" and
      "*.a.b *.c.d" are all represented by a mapping from "a.b" to "c.d". we
      now distinguish them by setting bits in the addressmap_entry_t
      structure, where src_wildcard is set if the source address had a
      wildcard, and dst_wildcard is set if the target address had a
      wildcard.
      
      This lets the case where "*.a.b *.c.d" or "*.a.b c.d" remap the
      address "a.b" get handled trivially, and lets us simplify and improve
      the addressmap_match_superdomains implementation: we can now have it
      run in O(parts of address) rather than O(entries in addressmap).
      69d16900
  7. 08 Sep, 2011 1 commit
  8. 08 Aug, 2011 1 commit
  9. 21 Jul, 2011 1 commit
  10. 19 Jul, 2011 4 commits
    • Nick Mathewson's avatar
      Implement sensible isolation for tunneled directory conns · 8314fa5e
      Nick Mathewson authored
      One-hop dirconn streams all share a session group, and get the
      ISO_SESSIONGRP flag: they may share circuits with each other and
      nothing else.
      
      Anonymized dirconn streams get a new internal-use-only ISO_STREAM
      flag: they may not share circuits with anything, including each other.
      8314fa5e
    • Nick Mathewson's avatar
      Launch sufficient circuits to satisfy pending isolated streams · 20c0581a
      Nick Mathewson authored
      Our old "do we need to launch a circuit for stream S" logic was,
      more or less, that if we had a pending circuit that could handle S,
      we didn't need to launch a new one.
      
      But now that we have streams isolated from one another, we need
      something stronger here: It's possible that some pending C can
      handle either S1 or S2, but not both.
      
      This patch reuses the existing isolation logic for a simple
      solution: when we decide during circuit launching that some pending
      C would satisfy stream S1, we "hypothetically" mark C as though S1
      had been connected to it.  Now if S2 is incompatible with S1, it
      won't be something that can attach to C, and so we'll launch a new
      stream.
      
      When the circuit becomes OPEN for the first time (with no streams
      attached to it), we reset the circuit's isolation status.  I'm not
      too sure about this part: I wanted some way to be sure that, if all
      streams that would have used a circuit die before the circuit is
      done, the circuit can still get used.  But I worry that this
      approach could also lead to us launching too many circuits.  Careful
      thought needed here.
      20c0581a
    • Nick Mathewson's avatar
      Const-ify a few functions · 461623e7
      Nick Mathewson authored
      461623e7
    • Nick Mathewson's avatar
      (Unused) backend logic for stream isolation · ea0a9b16
      Nick Mathewson authored
      This patch adds fields to track how streams should be isolated, and
      ensures that those fields are set correctly.  It also adds fields to
      track what streams can go on a circuit, and adds functions to see
      whether a streams can go on a circuit and update the circuit
      accordingly.  Those functions aren't yet called.
      ea0a9b16
  11. 11 Jul, 2011 1 commit
  12. 14 Jun, 2011 1 commit
    • Nick Mathewson's avatar
      Make the get_options() return const · 47c8433a
      Nick Mathewson authored
      This lets us make a lot of other stuff const, allows the compiler to
      generate (slightly) better code, and will make me get slightly fewer
      patches from folks who stick mutable stuff into or_options_t.
      
      const: because not every input is an output!
      47c8433a
  13. 13 May, 2011 1 commit
    • Nick Mathewson's avatar
      Handle transitions in Automap*, VirtualAddrNetwork correctly · da8297db
      Nick Mathewson authored
      Previously, if they changed in torrc during a SIGHUP, all was well,
      since we would just clear all transient entries from the addrmap
      thanks to bug 1345.  But if you changed them from the controller, Tor
      would leave old mappings in place.
      
      The VirtualAddrNetwork bug has been here since 0.1.1.19-rc; the
      AutomapHosts* bug has been here since 0.2.0.1-alpha.
      da8297db
  14. 27 Apr, 2011 2 commits
    • Roger Dingledine's avatar
      revert most of ef81649d · f962dda8
      Roger Dingledine authored and Nick Mathewson's avatar Nick Mathewson committed
      Now we believe it to be the case that we never build a circuit for our
      stream that has an unsuitable exit, so we'll never need to use such
      a circuit. The risk is that we have some code that builds the circuit,
      but now we refuse to use it, meaning we just build a bazillion circuits
      and ignore them all.
      f962dda8
    • Nick Mathewson's avatar
      When there is a transition in permitted nodes, apply it to trackexithosts map · 80adb3de
      Nick Mathewson authored
      IOW, if we were using TrackExitHosts, and we added an excluded node or
      removed a node from exitnodes, we wouldn't actually remove the mapping
      that points us at the new node.
      
      Also, note with an XXX022 comment a place that I think we are looking
      at the wrong string.
      80adb3de
  15. 14 Mar, 2011 1 commit
    • Nick Mathewson's avatar
      Consider sending stream-level SENDME cells on partial flushes. · 1d36a8e9
      Nick Mathewson authored
      Right now, we only consider sending stream-level SENDME cells when we
      have completely flushed a connection_edge's outbuf, or when it sends
      us a DATA cell.  Neither of these is ideal for throughput.
      
      This patch changes the behavior so we now call
      connection_edge_consider_sending_sendme when we flush _some_ data from
      an edge outbuf.
      
      Fix for bug 2756; bugfix on svn r152.
      1d36a8e9
  16. 03 Jan, 2011 1 commit
  17. 01 Oct, 2010 2 commits
    • Nick Mathewson's avatar
      Initial conversion to use node_t throughout our codebase. · 26e89742
      Nick Mathewson authored
      A node_t is an abstraction over routerstatus_t, routerinfo_t, and
      microdesc_t.  It should try to present a consistent interface to all
      of them.  There should be a node_t for a server whenever there is
        * A routerinfo_t for it in the routerlist
        * A routerstatus_t in the current_consensus.
      (note that a microdesc_t alone isn't enough to make a node_t exist,
      since microdescriptors aren't usable on their own.)
      
      There are three ways to get a node_t right now: looking it up by ID,
      looking it up by nickname, and iterating over the whole list of
      microdescriptors.
      
      All (or nearly all) functions that are supposed to return "a router"
      -- especially those used in building connections and circuits --
      should return a node_t, not a routerinfo_t or a routerstatus_t.
      
      A node_t should hold all the *mutable* flags about a node.  This
      patch moves the is_foo flags from routerinfo_t into node_t.  The
      flags in routerstatus_t remain, but they get set from the consensus
      and should not change.
      
      Some other highlights of this patch are:
      
        * Looking up routerinfo and routerstatus by nickname is now
          unified and based on the "look up a node by nickname" function.
          This tries to look only at the values from current consensus,
          and not get confused by the routerinfo_t->is_named flag, which
          could get set for other weird reasons.  This changes the
          behavior of how authorities (when acting as clients) deal with
          nodes that have been listed by nickname.
      
        * I tried not to artificially increase the size of the diff here
          by moving functions around.  As a result, some functions that
          now operate on nodes are now in the wrong file -- they should
          get moved to nodelist.c once this refactoring settles down.
          This moving should happen as part of a patch that moves
          functions AND NOTHING ELSE.
      
        * Some old code is now left around inside #if 0/1 blocks, and
          should get removed once I've verified that I don't want it
          sitting around to see how we used to do things.
      
      There are still some unimplemented functions: these are flagged
      with "UNIMPLEMENTED_NODELIST()."  I'll work on filling in the
      implementation here, piece by piece.
      
      I wish this patch could have been smaller, but there did not seem to
      be any piece of it that was independent from the rest.  Moving flags
      forces many functions that once returned routerinfo_t * to return
      node_t *, which forces their friends to change, and so on.
      26e89742
    • Nick Mathewson's avatar
      d84d20cb
  18. 27 Sep, 2010 1 commit
  19. 17 Aug, 2010 1 commit
  20. 08 Aug, 2010 1 commit
    • Robert Hogan's avatar
      Ensure controller RESOLVE commands respect __LeaveStreamsUnattached · 46256867
      Robert Hogan authored
      https://trac.torproject.org/projects/tor/ticket/1525
      
      "The codepath taken by the control port "RESOLVE" command to create a
      synthetic SOCKS resolve request isn't the same as the path taken by
      a real SOCKS request from 'tor-resolve'.
      This prevents controllers who set LeaveStreamsUnattached=1 from
      being able to attach RESOLVE streams to circuits of their choosing."
      
      Create a new function connection_ap_rewrite_and_attach_if_allowed()
      and call that when Tor needs to attach a stream to a circuit but
      needs to know if the controller permits it.
      
      No tests added.
      46256867
  21. 27 Jul, 2010 1 commit