- }
- 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]);
- }
- /*
- * Check for "FRENCH " infection ;-) (actually this should
- * be replaced with routine to check the hostname syntax in
- * general). [ This check is still needed, even after the parse
- * is fixed, because someone can send "SERVER :foo bar " ].
- * Also, changed to check other "difficult" characters, now
- * that parse lets all through... --msa
- */
- if (strlen(host) > HOSTLEN)
- host[HOSTLEN] = '\0';
- for (ch = host; *ch; ch++)
- if (*ch <= ' ' || *ch > '~')
- break;
- if (*ch || !strchr(host, '.')) {
- sendto_opmask_butone(0, SNO_OLDSNO, "Bogus server name (%s) from %s",
- host, cli_name(cptr));
- return exit_client_msg(cptr, cptr, &me, "Bogus server name (%s)", host);
- }
-
- if (IsServer(cptr))
- {
- /*
- * A local server introduces a new server behind this link.
- * Check if this is allowed according L:, H: and Q: lines.
- */
- if (info[0] == '\0')
- return exit_client_msg(cptr, cptr, &me,
- "No server info specified for %s", host);
- /*
- * See if the newly found server is behind a guaranteed
- * leaf (L-line). If so, close the link.
- */
- if ((lhconf = find_conf_byhost(cli_confs(cptr), cli_name(cptr), CONF_LEAF)) &&
- (!lhconf->port || (hop > lhconf->port)))
- {
- /*
- * L: lines normally come in pairs, here we try to
- * make sure that the oldest link is squitted, not
- * both.
- */
- active_lh_line = 1;
- if (timestamp <= cli_serv(cptr)->timestamp)
- LHcptr = 0; /* Kill incoming server */
- else
- LHcptr = cptr; /* Squit ourselfs */
- }
- else if (!(lhconf = find_conf_byname(cli_confs(cptr), cli_name(cptr), CONF_HUB)) ||
- (lhconf->port && (hop > lhconf->port)))
- {
- struct Client *ac3ptr;
- active_lh_line = 2;
- /* Look for net junction causing this: */
- LHcptr = 0; /* incoming server */
- if (*parv[5] != 'J') {
- for (ac3ptr = sptr; ac3ptr != &me; ac3ptr = cli_serv(ac3ptr)->up) {
- if (IsJunction(ac3ptr)) {
- LHcptr = ac3ptr;
- break;
- }
- }
- }
- }
- }
-
- if (IsUnknown(cptr) || IsHandshake(cptr))
- {
- const char* encr;
-
- /*
- * A local link that is still in undefined state wants
- * to be a SERVER. Check if this is allowed and change
- * status accordingly...
- */
- /*
- * If there is more then one server on the same machine
- * that we try to connect to, it could be that the /CONNECT
- * <mask> caused this connect to be put at the wrong place
- * in the hashtable. --Run
- * Same thing for Unknown connections that first send NICK.
- * --Xorath
- * Better check if the two strings are (caseless) identical
- * and not mess with hash internals.
- * --Nemesi
- */
- if ((!(EmptyString(cli_name(cptr))))
- && (IsUnknown(cptr) || IsHandshake(cptr))
- && 0 != ircd_strcmp(cli_name(cptr), host))
- hChangeClient(cptr, host);
- ircd_strncpy(cli_name(cptr), host, HOSTLEN);
- ircd_strncpy(cli_info(cptr), info[0] ? info : cli_name(&me), REALLEN);
- cli_hopcount(cptr) = hop;
-
- /* check connection rules */
- if (0 != conf_eval_crule(host, CRULE_ALL)) {
- ServerStats->is_ref++;
- sendto_opmask_butone(0, SNO_OLDSNO, "Refused connection from %s.", cli_name(cptr));
- return exit_client(cptr, cptr, &me, "Disallowed by connection rule");
- }
- if (conf_check_server(cptr)) {
- ++ServerStats->is_ref;
- sendto_opmask_butone(0, SNO_OLDSNO, "Received unauthorized connection "
- "from %s.", cli_name(cptr));
- return exit_client(cptr, cptr, &me, "No C conf lines");
- }
-
- host = cli_name(cptr);
-
- update_load();