summaryrefslogtreecommitdiff
path: root/controller
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-07-07 15:55:40 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-07-07 15:55:40 -0700
commitb9329dc49ac99a09a7cf9b488904e50ca8e1c4bc (patch)
tree280292f85c74809e667832aaef3cda118ecb2cdb /controller
parent6e08e1ae97014b9663da9b5f8475d66fc0f7dc88 (diff)
downloadinfinitytier-b9329dc49ac99a09a7cf9b488904e50ca8e1c4bc.tar.gz
infinitytier-b9329dc49ac99a09a7cf9b488904e50ca8e1c4bc.zip
Fix to IPv6 picking for small ranges.
Diffstat (limited to 'controller')
-rw-r--r--controller/SqliteNetworkController.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/controller/SqliteNetworkController.cpp b/controller/SqliteNetworkController.cpp
index 9c44c510..5e340c54 100644
--- a/controller/SqliteNetworkController.cpp
+++ b/controller/SqliteNetworkController.cpp
@@ -807,18 +807,16 @@ NetworkController::ResultCode SqliteNetworkController::doNetworkConfigRequest(co
xx[0] = Utils::hton(x[0]);
xx[1] = Utils::hton(x[1] + identity.address().toInt());
} else {
- if (x[1] == 0xffffffffffffffffULL) {
- if (x[0] == 0xffffffffffffffffULL)
- break;
- ++x[0];
- x[1] = 0;
- } else {
- ++x[1];
- }
- if ((x[0] >= e[0])&&(x[1] >= e[1]))
- break;
- xx[0] = Utils::hton(x[0]);
- xx[1] = Utils::hton(x[1]);
+ // Otherwise pick random addresses -- this technically doesn't explore the whole range if the lower 64 bit range is >= 1 but that won't matter since that would be huge anyway
+ Utils::getSecureRandom((void *)xx,16);
+ if ((e[0] > s[0]))
+ xx[0] %= (e[0] - s[0]);
+ else xx[0] = 0;
+ if ((e[1] > s[1]))
+ xx[1] %= (e[1] - s[1]);
+ else xx[1] = 0;
+ xx[0] = Utils::hton(x[0] + xx[0]);
+ xx[1] = Utils::hton(x[1] + xx[1]);
}
InetAddress ip6((const void *)xx,16,0);