瀏覽代碼

Add IPv4 address assignment to ffffffffffffffff test network.

Adam Ierymenko 10 年之前
父節點
當前提交
3f15752f73
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      node/NetworkConfig.cpp

+ 9 - 0
node/NetworkConfig.cpp

@@ -25,6 +25,8 @@
  * LLC. Start here: http://www.zerotier.com/
  * LLC. Start here: http://www.zerotier.com/
  */
  */
 
 
+#include <stdint.h>
+
 #include "NetworkConfig.hpp"
 #include "NetworkConfig.hpp"
 #include "Utils.hpp"
 #include "Utils.hpp"
 
 
@@ -51,6 +53,13 @@ SharedPtr<NetworkConfig> NetworkConfig::createTestNetworkConfig(const Address &s
 	nc->_name = "ZT_TEST_NETWORK";
 	nc->_name = "ZT_TEST_NETWORK";
 	nc->_description = "Built-in dummy test network";
 	nc->_description = "Built-in dummy test network";
 
 
+	// Make up a V4 IP from 'self' in the 10.0.0.0/8 range -- no
+	// guarantee of uniqueness but collisions are unlikely.
+	uint32_t ip = (uint32_t)((self.toInt() & 0x00ffffff) | 0x0a000000); // 10.x.x.x
+	if ((ip & 0x000000ff) == 0x000000ff) ip ^= 0x00000001; // but not ending in .255
+	if ((ip & 0x000000ff) == 0x00000000) ip ^= 0x00000001; // or .0
+	nc->_staticIps.push_back(InetAddress(Utils::hton(ip),8));
+
 	return nc;
 	return nc;
 }
 }