- int i;
- char info[REALLEN + 1];
- char* host;
- struct Client* acptr;
- struct Client* LHcptr = 0;
- struct ConfItem* aconf = 0;
- struct ConfItem* lhconf = 0;
- struct Jupe* ajupe = 0;
- int hop;
- int ret;
- int active_lh_line = 0;
- unsigned short prot;
- time_t start_timestamp;
- time_t timestamp = 0;
- time_t recv_time;
- time_t ghost = 0;
-
- if (IsUserPort(cptr))
- return exit_client_msg(cptr, cptr, &me,
- "Cannot connect a server to a user port");
-
- recv_time = TStime();
- info[0] = '\0';
-
- if (parc < 7)
- {
- need_more_params(sptr, "SERVER");
- return exit_client(cptr, cptr, &me, "Need more parameters");
- }
- host = parv[1];
-
- if ((ajupe = jupe_find(host)) && JupeIsActive(ajupe))
- return exit_client_msg(cptr, sptr, &me, "Juped: %s", JupeReason(ajupe));
-
- log_write(LS_NETWORK, L_NOTICE, LOG_NOSNOTICE, "SERVER: %s %s[%s]", parv[1],
- cli_sockhost(cptr), cli_sock_ip(cptr));
-
- /*
- * Detect protocol
- */
- if (strlen(parv[5]) != 3 || (parv[5][0] != 'P' && parv[5][0] != 'J'))
- return exit_client_msg(cptr, sptr, &me, "Bogus protocol (%s)", parv[5]);
-
- *parv[5] = 'J';
-
- if (*parv[7] == '+') {
- for (ch = parv[7] + 1; *ch; ch++)
- switch (*ch) {
- case 'h':
- SetHub(cptr);
- break;
- case 's':
- SetService(cptr);
- break;
- }
- }
-
- prot = atoi(parv[5] + 1);
- if (prot > atoi(MAJOR_PROTOCOL))
- prot = atoi(MAJOR_PROTOCOL);
-
- hop = atoi(parv[2]);
- start_timestamp = atoi(parv[3]);
- timestamp = atoi(parv[4]);
- Debug((DEBUG_INFO, "Got SERVER %s with timestamp [%s] age %Tu (%Tu)",
- host, parv[4], start_timestamp, cli_serv(&me)->timestamp));
-
- if ((timestamp < OLDEST_TS || (hop == 1 && start_timestamp < OLDEST_TS)))
- {
- return exit_client_msg(cptr, sptr, &me,
- "Bogus timestamps (%s %s)", parv[3], parv[4]);
- }
- ircd_strncpy(info, parv[parc - 1], REALLEN);
- info[REALLEN] = '\0';
- if (prot < atoi(MINOR_PROTOCOL)) {
- sendto_opmask_butone(0, SNO_OLDSNO, "Got incompatible protocol version "
- "(%s) from %s", parv[5], cli_name(cptr));
- return exit_new_server(cptr, sptr, host, timestamp,
- "Incompatible protocol: %s", parv[5]);
- }