static time_t last_notice = 0;
int errtmp = errno; /* debug may change 'errno' */
const char* errmsg = (err) ? strerror(err) : "";
+
if (!errmsg)
errmsg = "Unknown error";
sendto_opmask_butone(0, SNO_OLDSNO, text, who, errmsg);
last_notice = CurrentTime;
}
- ircd_log(L_ERROR, text, who, errmsg);
+ log_write(LS_SOCKET, L_ERROR, 0, text, who, errmsg);
errno = errtmp;
}
}
else
sendto_opmask_butone(0, SNO_OLDSNO, "Connect to %s failed: host lookup",
- aconf->name);
+ aconf->name);
}
/*
me.sendK += (me.sendB >> 10);
me.sendB &= 0x03ff;
}
+ /*
+ * XXX - hrmm.. set blocked here? the socket didn't
+ * say it was blocked
+ */
if (bytes_written < len)
cptr->flags |= FLAGS_BLOCKED;
break;
if (!msg)
msg = "Unknown error";
sendto_opmask_butone(0, SNO_OLDSNO, "Connection failed to %s: %s",
- cptr->name, msg);
+ cptr->name, msg);
return 0;
}
if (!(aconf = find_conf_byname(cptr->confs, cptr->name, CONF_SERVER))) {
cptr->flags |= FLAGS_PINGSENT;
sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s :%s",
- me.name, me.serv->timestamp, newts, MAJOR_PROTOCOL,
- NumServCap(&me), me.info);
+ me.name, me.serv->timestamp, newts, MAJOR_PROTOCOL,
+ NumServCap(&me), me.info);
return (IsDead(cptr)) ? 0 : 1;
}
assert(0 != listener);
+
/*
* Removed preliminary access check. Full check is performed in m_server and
* m_user instead. Also connection time out help to get rid of unwanted
return;
}
-
/*
* Add this local client to the IPcheck registry.
*
- * If it is a connection to a user port and if the site has been throttled,
- * reject the user.
+ * If they're throttled, murder them, but tell them why first.
*/
- if (!ip_registry_check_local(addr.sin_addr.s_addr, &next_target) &&
- !listener->server) {
- send(fd, throttle_message, 66, 0);
- close(fd);
+ if (!IPcheck_local_connect(addr.sin_addr, &next_target) && !listener->server) {
++ServerStats->is_ref;
- return;
+ write(fd, throttle_message, strlen(throttle_message));
+ close(fd);
+ return;
}
new_client = make_client(0, ((listener->server) ?
- STAT_UNKNOWN_SERVER : STAT_UNKNOWN_USER));
-
- if (!listener->server)
- ip_registry_local_connect(new_client);
+ STAT_UNKNOWN_SERVER : STAT_UNKNOWN_USER));
/*
* Copy ascii address to 'sockhost' just in case. Then we have something
++listener->ref_count;
Count_newunknown(UserStats);
-
/* if we've made it this far we can put the client on the auth query pile */
start_auth(new_client);
}
const char* msg = (cptr->error) ? strerror(cptr->error) : "EOF from client";
if (!msg)
msg = "Unknown error";
- exit_client_msg(cptr, cptr, &me, "Read error: %s",
- msg);
+ exit_client_msg(cptr, cptr, &me, "Read error: %s", msg);
}
}
return 0;
if (CPTR_KILLED == (length = read_packet(cptr, read_ready)))
continue;
}
-#if 0
- /* Bullshit, why would we want to flush sockets while using non-blocking?
- * This uses > 4% cpu! --Run */
- if (length > 0)
- flush_connections(LocalClientArray[i]);
-#endif
if (IsDead(cptr)) {
const char* msg = (cptr->error) ? strerror(cptr->error) : cptr->info;
if (!msg)
const char* msg = (cptr->error) ? strerror(cptr->error) : "EOF from client";
if (!msg)
msg = "Unknown error";
- exit_client_msg(cptr, cptr, &me, "Read error: %s",
- msg);
+ exit_client_msg(cptr, cptr, &me, "Read error: %s", msg);
}
}
return 0;
if (aconf->dns_pending) {
sendto_opmask_butone(0, SNO_OLDSNO, "Server %s connect DNS pending",
- aconf->name);
+ aconf->name);
return 0;
}
Debug((DEBUG_NOTICE, "Connect to %s[@%s]", aconf->name,
if ((cptr = FindClient(aconf->name))) {
if (IsServer(cptr) || IsMe(cptr)) {
sendto_opmask_butone(0, SNO_OLDSNO, "Server %s already present from %s",
- aconf->name, cptr->from->name);
+ aconf->name, cptr->from->name);
if (by && IsUser(by) && !MyUser(by)) {
- sendcmdto_one(&me, CMD_NOTICE, by, "%C :Server %s already present "
- "from %s", by, aconf->name, cptr->from->name);
+ sendcmdto_one(&me, CMD_NOTICE, by, "%C :Server %s already present "
+ "from %s", by, aconf->name, cptr->from->name);
}
return 0;
}
else if (IsHandshake(cptr) || IsConnecting(cptr)) {
if (by && IsUser(by)) {
- sendcmdto_one(&me, CMD_NOTICE, by, "%C :Connection to %s already in "
- "progress", by, cptr->name);
+ sendcmdto_one(&me, CMD_NOTICE, by, "%C :Connection to %s already in "
+ "progress", by, cptr->name);
}
return 0;
}
if (!find_conf_byhost(cptr->confs, aconf->host, CONF_SERVER)) {
sendto_opmask_butone(0, SNO_OLDSNO, "Host %s is not enabled for "
- "connecting: no C-line", aconf->name);
+ "connecting: no C-line", aconf->name);
if (by && IsUser(by) && !MyUser(by)) {
sendcmdto_one(&me, CMD_NOTICE, by, "%C :Connect to host %s failed: no "
- "C-line", by, aconf->name);
+ "C-line", by, aconf->name);
}
det_confs_butmask(cptr, 0);
free_client(cptr);
if (!connect_inet(aconf, cptr)) {
if (by && IsUser(by) && !MyUser(by)) {
sendcmdto_one(&me, CMD_NOTICE, by, "%C :Couldn't connect to %s", by,
- cptr->name);
+ cptr->name);
}
det_confs_butmask(cptr, 0);
free_client(cptr);
if (cptr->fd > HighestFd)
HighestFd = cptr->fd;
+
+
LocalClientArray[cptr->fd] = cptr;
Count_newunknown(UserStats);
+ /* Actually we lie, the connect hasn't succeeded yet, but we have a valid
+ * cptr, so we register it now.
+ * Maybe these two calls should be merged.
+ */
add_client_to_list(cptr);
hAddClient(cptr);
nextping = CurrentTime;
/*
* Setup local socket structure to use for binding to.
*/
-void init_virtual_host(const struct ConfItem* conf)
+void set_virtual_host(struct in_addr addr)
{
- assert(0 != conf);
-
memset(&VirtualHost, 0, sizeof(VirtualHost));
VirtualHost.sin_family = AF_INET;
- VirtualHost.sin_addr.s_addr = INADDR_ANY;
-
- if (EmptyString(conf->passwd) || 0 == strcmp(conf->passwd, "*"))
- return;
- VirtualHost.sin_addr.s_addr = inet_addr(conf->passwd);
-
- if (INADDR_NONE == VirtualHost.sin_addr.s_addr)
- VirtualHost.sin_addr.s_addr = INADDR_ANY;
+ VirtualHost.sin_addr.s_addr = addr.s_addr;
}
/*
* matches the server's name) and its primary IP#. Hostname is stored
* in the client structure passed as a pointer.
*/
-int init_server_identity()
+void init_server_identity(void)
{
- struct ConfItem* conf = find_me();
-
- if (!conf || EmptyString(conf->host))
- return 0;
-
- ircd_strncpy(me.name, conf->host, HOSTLEN);
+ const struct LocalConf* conf = conf_get_local();
+ assert(0 != conf);
- init_virtual_host(conf);
- return 1;
+ ircd_strncpy(me.name, conf->name, HOSTLEN);
+ SetYXXServerName(&me, conf->numeric);
}