|
@@ -28,6 +28,7 @@
|
|
|
#include "feature/nodelist/routerparse.h"
|
|
|
#include "feature/stats/geoip.h"
|
|
|
#include "ht.h"
|
|
|
+#include "lib/crypt_ops/crypto_rand.h"
|
|
|
#include "lib/encoding/confline.h"
|
|
|
|
|
|
#include "core/or/addr_policy_st.h"
|
|
@@ -487,6 +488,15 @@ fascist_firewall_prefer_ipv6_impl(const or_options_t *options)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
+/* Choose whether we prefer IPv4 or IPv6 by randomly choosing an address
|
|
|
+ * family. Return 0 for IPv4, and 1 for IPv6. */
|
|
|
+static int
|
|
|
+fascist_firewall_rand_prefer_ipv6_addr(void)
|
|
|
+{
|
|
|
+ /* TODO: Check for failures, and infer our preference based on this. */
|
|
|
+ return crypto_rand_int(2);
|
|
|
+}
|
|
|
+
|
|
|
/** Do we prefer to connect to IPv6 ORPorts?
|
|
|
* Use node_ipv6_or_preferred() whenever possible: it supports bridge client
|
|
|
* per-node IPv6 preferences.
|
|
@@ -501,7 +511,10 @@ fascist_firewall_prefer_ipv6_orport(const or_options_t *options)
|
|
|
}
|
|
|
|
|
|
/* We can use both IPv4 and IPv6 - which do we prefer? */
|
|
|
- if (options->ClientPreferIPv6ORPort == 1) {
|
|
|
+ if (options->ClientAutoIPv6ORPort == 1) {
|
|
|
+ /* If ClientAutoIPv6ORPort is 1, we prefer IPv4 or IPv6 at random. */
|
|
|
+ return fascist_firewall_rand_prefer_ipv6_addr();
|
|
|
+ } else if (options->ClientPreferIPv6ORPort == 1) {
|
|
|
return 1;
|
|
|
}
|
|
|
|