Commit 4da4c4c6 authored by Nick Mathewson's avatar Nick Mathewson 🤹
Browse files

Apply GeoIPExcludeUnknown before checking transitions

Otherwise, it always seems as though our Exclude* options have
changed, since we're comparing modified to unmodified values.

Patch from qwerty1. Fixes bug 9801. Bugfix on 0.2.4.10-alpha, where
GeoIPExcludeUnknown was introduced.
parent 7591ce64
Loading
Loading
Loading
Loading

changes/bug9801

0 → 100644
+5 −0
Original line number Diff line number Diff line
  o Minor bugfixes:
    - When GeoIPExcludeUnkonwn is enabled, do not incorrectly decide
      that our options have changed every time we SIGHUP. Fixes bug
      9801; bugfix on 0.2.4.10-alpha. Patch from "qwerty1".
+14 −14
Original line number Diff line number Diff line
@@ -1592,6 +1592,20 @@ options_act(const or_options_t *old_options)
    return -1;
  }

  config_maybe_load_geoip_files_(options, old_options);

  if (geoip_is_loaded(AF_INET) && options->GeoIPExcludeUnknown) {
    /* ExcludeUnknown is true or "auto" */
    const int is_auto = options->GeoIPExcludeUnknown == -1;
    int changed;

    changed  = routerset_add_unknown_ccs(&options->ExcludeNodes, is_auto);
    changed += routerset_add_unknown_ccs(&options->ExcludeExitNodes, is_auto);

    if (changed)
      routerset_add_unknown_ccs(&options->ExcludeExitNodesUnion_, is_auto);
  }

  /* Check for transitions that need action. */
  if (old_options) {
    int revise_trackexithosts = 0;
@@ -1687,20 +1701,6 @@ options_act(const or_options_t *old_options)
      connection_or_update_token_buckets(get_connection_array(), options);
  }

  config_maybe_load_geoip_files_(options, old_options);

  if (geoip_is_loaded(AF_INET) && options->GeoIPExcludeUnknown) {
    /* ExcludeUnknown is true or "auto" */
    const int is_auto = options->GeoIPExcludeUnknown == -1;
    int changed;

    changed  = routerset_add_unknown_ccs(&options->ExcludeNodes, is_auto);
    changed += routerset_add_unknown_ccs(&options->ExcludeExitNodes, is_auto);

    if (changed)
      routerset_add_unknown_ccs(&options->ExcludeExitNodesUnion_, is_auto);
  }

  if (options->CellStatistics || options->DirReqStatistics ||
      options->EntryStatistics || options->ExitPortStatistics ||
      options->ConnDirectionStatistics ||