Преглед на файлове

* Keep settings.hubs around as a default and populate into settings.conf_hubs via -C

Bryan Drewery преди 14 години
родител
ревизия
770d315916
променени са 3 файла, в които са добавени 18 реда и са изтрити 10 реда
  1. 6 4
      src/binary.c
  2. 6 1
      src/conf.c
  3. 6 5
      src/settings.h

+ 6 - 4
src/binary.c

@@ -50,7 +50,7 @@
 settings_t settings = {
   SETTINGS_HEADER,
   /* -- STATIC -- */
-  "", "", "", "", "", "", "", "",
+  "", "", "", "", "", "", "", "", "",
   /* -- DYNAMIC -- */
   "", "", "", "", "", "", "", "", "", "",
   /* -- PADDING */
@@ -482,6 +482,7 @@ static void edpack(settings_t *incfg, const char *in_hash, int what)
   dofield(incfg->dcc_prefix);
   dofield(incfg->features);
   dofield(incfg->owners);
+  dofield(incfg->hubs);
 
   dohash(incfg->salt1);
   dohash(incfg->salt2);
@@ -489,7 +490,7 @@ static void edpack(settings_t *incfg, const char *in_hash, int what)
 
   /* -- DYNAMIC -- */
   dofield(incfg->dynamic_initialized);
-  dofield(incfg->hubs);
+  dofield(incfg->conf_hubs);
   dofield(incfg->bots);
   dofield(incfg->uid);
   dofield(incfg->autocron);
@@ -518,11 +519,12 @@ tellconfig(settings_t *incfg)
   dofield(incfg->dcc_prefix);
   dofield(incfg->features);
   dofield(incfg->owners);
+  dofield(incfg->hubs);
 //  dofield(incfg->salt1);
 //  dofield(incfg->salt2);
   // -- DYNAMIC --
   dofield(incfg->dynamic_initialized);
-  dofield(incfg->hubs);
+  dofield(incfg->conf_hubs);
   dofield(incfg->bots);
   dofield(incfg->uid);
   dofield(incfg->autocron);
@@ -699,7 +701,7 @@ void conf_to_bin(conf_t *in, bool move, int die)
                            bot->net.ip6 ? bot->net.ip6 : "");
     }
 
-  simple_snprintf(settings.hubs, sizeof(settings.hubs), in->hubs.join(',').c_str());
+  simple_snprintf(settings.conf_hubs, sizeof(settings.conf_hubs), in->hubs.join(',').c_str());
 
   newbin = binname;
 //  tellconfig(&settings); 

+ 6 - 1
src/conf.c

@@ -322,7 +322,12 @@ init_conf()
 //  conf.bots->next = NULL;
   conf.bots = NULL;
   conf.bot = NULL;
-  conf.hubs = bd::String(settings.hubs).split(',');
+  // If conf_hubs is blank, revert to pack hubs
+  if (strlen(settings.conf_hubs)) {
+    conf.hubs = bd::String(settings.conf_hubs).split(',');
+  } else {
+    conf.hubs = bd::String(settings.hubs).split(',');
+  }
 
   conf.localhub = NULL;
   conf.autocron = 1;

+ 6 - 5
src/settings.h

@@ -6,7 +6,7 @@
 #define PREFIXLEN sizeof(SETTINGS_HEADER)
 
 /* !!! THIS MUST BE CHANGED WHEN CHANGING THE PACK STRUCT OR ALGORITHMS !!! */
-#define SETTINGS_VER 2
+#define SETTINGS_VER 3
 
 #define DYNAMIC_HEADER dynamic_initialized
 
@@ -18,13 +18,14 @@ typedef struct settings_struct {
   char packname[65];
   char shellhash[65];
   char owners[513];
+  char hubs[513];
   char salt1[33];
   char salt2[17];
   char dcc_prefix[17];
   char features[17];
   /* -- DYNAMIC -- */
   char dynamic_initialized[17];
-  char hubs[513];
+  char conf_hubs[513];
   char bots[1025];
   char uid[17];
   char autocron[17];         /* should the bot auto crontab itself? */
@@ -34,7 +35,7 @@ typedef struct settings_struct {
   char portmin[17];       /* for hubs, the reserved port range for incoming connections */
   char portmax[17];       /* for hubs, the reserved port range for incoming connections */
   /* -- PADDING -- */
-  char padding[14];        // (16 - (sizeof(settings_t) % 16)) % 16]
+  char padding[13];        // (16 - (sizeof(settings_t) % 16)) % 16]
 } settings_t;
 
 #define SALT1 {s1_1[0],s1_1[1],s1_5[0],s1_5[1],s1_8[0],s1_8[1],s1_4[0],s1_9[1],s1_2[0],s1_13[0],s1_6[0],s1_6[1],s1_7[0],s1_7[1],s1_3[0],s1_13[1],s1_16[1],s1_4[1],s1_15[0],s1_10[1],s1_14[0],s1_14[1],s1_12[0],s1_12[1],s1_2[1],s1_3[1],s1_11[0],s1_11[1],s1_10[0],s1_15[1],s1_16[0],s1_9[0],'\0'}
@@ -46,10 +47,10 @@ typedef struct settings_struct {
 extern char s1_3[3],s1_2[3],s1_1[3],s2_7[3],s1_9[3],s1_13[3],s1_14[3],s2_2[3],s1_10[3],s2_4[3],s1_4[3],s2_3[3],s2_1[3],s2_6[3],s1_7[3],s1_12[3],s2_5[3],s1_5[3],s1_6[3],s1_11[3],s2_8[3],s1_8[3],s1_16[3],s1_15[3];
 
 #define SIZE_PACK sizeof(settings.hash) + sizeof(settings.packname) + sizeof(settings.shellhash) + \
-sizeof(settings.owners) + \
+sizeof(settings.owners) + sizeof(settings.hubs) + \
 sizeof(settings.salt1) + sizeof(settings.salt2) + sizeof(settings.dcc_prefix) + sizeof(settings.features)
 
-#define SIZE_CONF sizeof(settings.dynamic_initialized) + sizeof(settings.hubs) + sizeof(settings.bots) + sizeof(settings.uid) + \
+#define SIZE_CONF sizeof(settings.dynamic_initialized) + sizeof(settings.conf_hubs) + sizeof(settings.bots) + sizeof(settings.uid) + \
 sizeof(settings.autocron) + \
 sizeof(settings.username) + sizeof(settings.homedir) + \
 sizeof(settings.portmin) + sizeof(settings.portmin) + sizeof(settings.datadir)