Ver Fonte

Obsolete "test network" removal.

Adam Ierymenko há 9 anos atrás
pai
commit
77f7dcf40a
3 ficheiros alterados com 25 adições e 91 exclusões
  1. 0 13
      node/Constants.hpp
  2. 19 28
      node/Network.cpp
  3. 6 50
      node/NetworkConfig.hpp

+ 0 - 13
node/Constants.hpp

@@ -354,19 +354,6 @@
  */
 #define ZT_SUPPORT_OLD_STYLE_NETCONF 1
 
-/**
- * A test pseudo-network-ID that can be joined
- *
- * Joining this network ID will result in a network with no IP addressing
- * and default parameters. No network configuration master will be consulted
- * and instead a static config will be used. This is used in built-in testnet
- * scenarios and can also be used for external testing.
- *
- * This is an impossible real network ID since 0xff is a reserved address
- * prefix.
- */
-#define ZT_TEST_NETWORK_ID 0xffffffffffffffffULL
-
 /**
  * Desired buffer size for UDP sockets (used in service and osdep but defined here)
  */

+ 19 - 28
node/Network.cpp

@@ -409,33 +409,26 @@ Network::Network(const RuntimeEnvironment *renv,uint64_t nwid,void *uptr) :
 	char confn[128];
 	Utils::snprintf(confn,sizeof(confn),"networks.d/%.16llx.conf",_id);
 
-	if (_id == ZT_TEST_NETWORK_ID) {
-		applyConfiguration(NetworkConfig::createTestNetworkConfig(RR->identity.address()));
-
-		// Save a one-byte CR to persist membership in the test network
-		RR->node->dataStorePut(confn,"\n",1,false);
-	} else {
-		bool gotConf = false;
-		Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> *dconf = new Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY>();
-		NetworkConfig *nconf = new NetworkConfig();
-		try {
-			std::string conf(RR->node->dataStoreGet(confn));
-			if (conf.length()) {
-				dconf->load(conf.c_str());
-				if (nconf->fromDictionary(Identity(),*dconf)) {
-					this->setConfiguration(*nconf,false);
-					_lastConfigUpdate = 0; // we still want to re-request a new config from the network
-					gotConf = true;
-				}
+	bool gotConf = false;
+	Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> *dconf = new Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY>();
+	NetworkConfig *nconf = new NetworkConfig();
+	try {
+		std::string conf(RR->node->dataStoreGet(confn));
+		if (conf.length()) {
+			dconf->load(conf.c_str());
+			if (nconf->fromDictionary(Identity(),*dconf)) {
+				this->setConfiguration(*nconf,false);
+				_lastConfigUpdate = 0; // we still want to re-request a new config from the network
+				gotConf = true;
 			}
-		} catch ( ... ) {} // ignore invalids, we'll re-request
-		delete nconf;
-		delete dconf;
-
-		if (!gotConf) {
-			// Save a one-byte CR to persist membership while we request a real netconf
-			RR->node->dataStorePut(confn,"\n",1,false);
 		}
+	} catch ( ... ) {} // ignore invalids, we'll re-request
+	delete nconf;
+	delete dconf;
+
+	if (!gotConf) {
+		// Save a one-byte CR to persist membership while we request a real netconf
+		RR->node->dataStorePut(confn,"\n",1,false);
 	}
 
 	if (!_portInitialized) {
@@ -698,9 +691,6 @@ void Network::handleInboundConfigChunk(const uint64_t inRePacketId,const void *d
 
 void Network::requestConfiguration()
 {
-	if (_id == ZT_TEST_NETWORK_ID) // pseudo-network-ID, uses locally generated static config
-		return;
-
 	Dictionary<ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY> rmd;
 	rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_VERSION,(uint64_t)ZT_NETWORKCONFIG_VERSION);
 	rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_PROTOCOL_VERSION,(uint64_t)ZT_PROTO_VERSION);
@@ -711,6 +701,7 @@ void Network::requestConfiguration()
 	rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_CAPABILITIES,(uint64_t)ZT_MAX_NETWORK_CAPABILITIES);
 	rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_CAPABILITY_RULES,(uint64_t)ZT_MAX_CAPABILITY_RULES);
 	rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_TAGS,(uint64_t)ZT_MAX_NETWORK_TAGS);
+	rmd.add(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_FLAGS,(uint64_t)0);
 
 	if (controller() == RR->identity.address()) {
 		if (RR->localNetworkController) {

+ 6 - 50
node/NetworkConfig.hpp

@@ -61,7 +61,7 @@
 #define ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE 0x0000020000000000ULL
 
 /**
- * An anchor is a device that is willing to be one and has been online/stable for a long time on this network
+ * Anchors are stable devices on this network that can cache multicast info, etc.
  */
 #define ZT_NETWORKCONFIG_SPECIALIST_TYPE_ANCHOR 0x0000040000000000ULL
 
@@ -74,35 +74,30 @@ namespace ZeroTier {
 #define ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY 1024
 
 // Network config version
-#define ZT_NETWORKCONFIG_VERSION 6
+#define ZT_NETWORKCONFIG_VERSION 7
 
 // Fields for meta-data sent with network config requests
 
 // Network config version
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_VERSION "v"
-
 // Protocol version (see Packet.hpp)
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_PROTOCOL_VERSION "pv"
-
 // Software major, minor, revision
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_NODE_MAJOR_VERSION "majv"
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_NODE_MINOR_VERSION "minv"
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_NODE_REVISION "revv"
-
 // Maximum number of rules per network this node can accept
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_RULES "mr"
-
 // Maximum number of capabilities this node can accept
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_CAPABILITIES "mc"
-
 // Maximum number of rules per capability this node can accept
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_CAPABILITY_RULES "mcr"
-
 // Maximum number of tags this node can accept
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_MAX_NETWORK_TAGS "mt"
-
 // Network join authorization token (if any)
 #define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_AUTH_TOKEN "atok"
+// Network configuration meta-data flags
+#define ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_FLAGS "f"
 
 // These dictionary keys are short so they don't take up much room.
 // By convention we use upper case for binary blobs, but it doesn't really matter.
@@ -167,6 +162,8 @@ namespace ZeroTier {
 // node;IP/port[,node;IP/port]
 #define ZT_NETWORKCONFIG_DICT_KEY_RELAYS_OLD "rl"
 
+// End legacy fields
+
 /**
  * Network configuration received from network controller nodes
  *
@@ -176,47 +173,6 @@ namespace ZeroTier {
 class NetworkConfig
 {
 public:
-	/**
-	 * Create an instance of a NetworkConfig for the test network ID
-	 *
-	 * The test network ID is defined as ZT_TEST_NETWORK_ID. This is a
-	 * "fake" network with no real controller and default options.
-	 *
-	 * @param self This node's ZT address
-	 * @return Configuration for test network ID
-	 */
-	static inline NetworkConfig createTestNetworkConfig(const Address &self)
-	{
-		NetworkConfig nc;
-
-		nc.networkId = ZT_TEST_NETWORK_ID;
-		nc.timestamp = 1;
-		nc.revision = 1;
-		nc.issuedTo = self;
-		nc.multicastLimit = ZT_MULTICAST_DEFAULT_LIMIT;
-		nc.flags = ZT_NETWORKCONFIG_FLAG_ENABLE_BROADCAST;
-		nc.type = ZT_NETWORK_TYPE_PUBLIC;
-
-		nc.rules[0].t = ZT_NETWORK_RULE_ACTION_ACCEPT;
-		nc.ruleCount = 1;
-
-		Utils::snprintf(nc.name,sizeof(nc.name),"ZT_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[0] = InetAddress(Utils::hton(ip),8);
-
-		// Assign an RFC4193-compliant IPv6 address -- will never collide
-		nc.staticIps[1] = InetAddress::makeIpv6rfc4193(ZT_TEST_NETWORK_ID,self.toInt());
-
-		nc.staticIpCount = 2;
-
-		return nc;
-	}
-
 	NetworkConfig()
 	{
 		memset(this,0,sizeof(NetworkConfig));