소스 검색

Patch from cagara: Add a CountPrivateBandwidth flag

Daniel Cagara 14 년 전
부모
커밋
e61f3293e4
3개의 변경된 파일12개의 추가작업 그리고 2개의 파일을 삭제
  1. 8 0
      src/or/config.c
  2. 3 2
      src/or/connection.c
  3. 1 0
      src/or/or.h

+ 8 - 0
src/or/config.c

@@ -211,6 +211,7 @@ static config_var_t _option_vars[] = {
   V(CookieAuthentication,        BOOL,     "0"),
   V(CookieAuthFileGroupReadable, BOOL,     "0"),
   V(CookieAuthFile,              STRING,   NULL),
+  V(CountPrivateBandwidth,       BOOL,     "0"),
   V(DataDirectory,               FILENAME, NULL),
   OBSOLETE("DebugLogFile"),
   V(DirAllowPrivateAddresses,    BOOL,     NULL),
@@ -418,6 +419,7 @@ static config_var_t testing_tor_network_defaults[] = {
   V(AuthDirMaxServersPerAuthAddr,UINT,     "0"),
   V(ClientDNSRejectInternalAddresses, BOOL,"0"),
   V(ClientRejectInternalAddresses, BOOL,   "0"),
+  V(CountPrivateBandwidth,       BOOL,     "1"),
   V(ExitPolicyRejectPrivate,     BOOL,     "0"),
   V(V3AuthVotingInterval,        INTERVAL, "5 minutes"),
   V(V3AuthVoteDelay,             INTERVAL, "20 seconds"),
@@ -429,6 +431,7 @@ static config_var_t testing_tor_network_defaults[] = {
   V(TestingEstimatedDescriptorPropagationTime, INTERVAL, "0 minutes"),
   V(MinUptimeHidServDirectoryV2, INTERVAL, "0 minutes"),
   V(_UsingTestNetworkDefaults,   BOOL,     "1"),
+
   { NULL, CONFIG_TYPE_OBSOLETE, 0, NULL }
 };
 #undef VAR
@@ -2955,6 +2958,11 @@ options_validate(or_options_t *old_options, or_options_t *options,
   tor_assert(msg);
   *msg = NULL;
 
+  // Cagara: Tell us if we use the private network fix!
+  if(options->CountPrivateBandwidth == 1) {
+      log_notice(LD_CONFIG, "Private bandwidth will be treated as normal traffic.");
+  }
+
   if (options->ORPort < 0 || options->ORPort > 65535)
     REJECT("ORPort option out of bounds.");
 

+ 3 - 2
src/or/connection.c

@@ -1953,9 +1953,10 @@ retry_all_listeners(smartlist_t *replaced_conns,
 static int
 connection_is_rate_limited(connection_t *conn)
 {
+  or_options_t *options = get_options();
   if (conn->linked || /* internal connection */
-      tor_addr_family(&conn->addr) == AF_UNSPEC || /* no address */
-      tor_addr_is_internal(&conn->addr, 0)) /* internal address */
+      (options->CountPrivateBandwidth==1 && ( tor_addr_family(&conn->addr) == AF_UNSPEC || /* no address */
+      tor_addr_is_internal(&conn->addr, 0)))) /* internal address */
     return 0;
   else
     return 1;

+ 1 - 0
src/or/or.h

@@ -2868,6 +2868,7 @@ typedef struct {
   /** Boolean: if set, we start even if our resolv.conf file is missing
    * or broken. */
   int ServerDNSAllowBrokenConfig;
+  int CountPrivateBandwidth; // Cagara: Flag to allow private addresses counting to bucket size
 
   smartlist_t *ServerDNSTestAddresses; /**< A list of addresses that definitely
                                         * should be resolvable. Used for