Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_server.c
index 7daaaa71c7f43a76c9221a37a702a22568d946e9..491b5e14b3606488513faff861e3bb8ff4ca2272 100644 (file)
@@ -768,7 +768,7 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 #endif
     }
 
-    ret = server_estab(cptr, aconf);
+    ret = server_estab(cptr, aconf, ajupe);
   }
   else
     ret = 0;
@@ -800,6 +800,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
  *    parv[6] = "YMM", where 'Y' is the server numeric and "MM" is the
  *              numeric nick mask of this server.
  *    parv[7] = 0 (not used yet, mandatory unsigned int after u2.10.06)
+ *    parv[8] = %<lastmod> - optional parameter only present if there's an
+ *             outstanding JUPE; specifies the JUPE's lastmod field
  */
 int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
@@ -822,6 +824,7 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   time_t           timestamp = 0;
   time_t           recv_time;
   time_t           ghost = 0;
+  time_t           lastmod = 0;
 
   if (IsUserPort(cptr))
     return exit_client_msg(cptr, cptr, &me,
@@ -836,9 +839,6 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   }
   host = parv[1];
 
-  if ((ajupe = jupe_find(host)) && JupeIsActive(ajupe))
-    jupe_resend(cptr, ajupe);
-
   /*
    * Detect protocol
    */
@@ -875,6 +875,16 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     return exit_new_server(cptr, sptr, host, timestamp,
                            "Incompatible protocol: %s", parv[5]);
   }
+  if (parc > 9 && *parv[8] == '%')
+    lastmod = atoi(parv[8] + 1);
+  /* If there's a jupe that matches, and it's a global jupe, and the
+   * introducer didn't indicate it knew of the jupe or has an older
+   * version of the jupe, and the connection isn't in a BURST, resynch
+   * the jupe.
+   */
+  if ((ajupe = jupe_find(host)) && !JupeIsLocal(ajupe) &&
+      JupeLastMod(ajupe) > lastmod && !IsBurstOrBurstAck(cptr))
+    jupe_resend(cptr, ajupe);
   /*
    * Check for "FRENCH " infection ;-) (actually this should
    * be replaced with routine to check the hostname syntax in
@@ -1435,7 +1445,7 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 #endif
     }
 
-    ret = server_estab(cptr, aconf);
+    ret = server_estab(cptr, aconf, ajupe);
   }
   else
     ret = 0;
@@ -2099,7 +2109,7 @@ int m_server(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 #endif
     }
 
-    ret = server_estab(cptr, aconf);
+    ret = server_estab(cptr, aconf); /* XXX DEAD */
   }
   else
     ret = 0;