- 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();
-
- if (!(aconf = find_conf_byname(cli_confs(cptr), host, CONF_SERVER))) {
- ++ServerStats->is_ref;
- sendto_opmask_butone(0, SNO_OLDSNO, "Access denied. No conf line for "
- "server %s", cli_name(cptr));
- return exit_client_msg(cptr, cptr, &me,
- "Access denied. No conf line for server %s", cli_name(cptr));
- }
- encr = cli_passwd(cptr);
-
- if (*(aconf->passwd) && !!strcmp(aconf->passwd, encr)) {
- ++ServerStats->is_ref;
- sendto_opmask_butone(0, SNO_OLDSNO, "Access denied (passwd mismatch) %s",
- cli_name(cptr));
- return exit_client_msg(cptr, cptr, &me,
- "No Access (passwd mismatch) %s", cli_name(cptr));
- }
- memset(cli_passwd(cptr), 0, sizeof(cli_passwd(cptr)));
-
- if (!feature_bool(FEAT_HUB)) {
- for (i = 0; i <= HighestFd; i++)
- if (LocalClientArray[i] && IsServer(LocalClientArray[i])) {
- active_lh_line = 3;
- LHcptr = 0;
- break;
- }
- }
- }
-