-ircu2.10.07+.08
+ircu2.10.07+.09
#
# ChangeLog for Undernet ircu Servers
#
-# $Id: ChangeLog,v 1.11 2000-03-14 01:35:20 bleep Exp $
+# $Id: ChangeLog,v 1.12 2000-03-18 01:59:56 bleep Exp $
#
# Please insert new entries on the top of the list, a one or two line comment
# is sufficient. Please include your name on the entries we know who to blame.
# Please keep lines < 80 chars.
#-------------------------------------------------------------------------------
-* s_auth.c (start_auth): Bugfix - uninitialized len variable caused binding to
- client local address to fail, initialize to sizeof(struct sockaddr_in).
- Clean up leaking file descriptors, set authfd to -1 when closed for error.
- Bug stomping and fix by Gte. --Bleep
-* Add Run's pline patch. --Run
-* channel.c (send_channel_modes): send modes for second line for channels with
- a lot of ops. --Gte
-* config-sh.in: add runs fix for symlink restart bug. --Bleep
+* Added hostname hiding compatible with ircu2.10.10 to allow host hiding
+ for transitioning services, back out pline8 for now. --Bleep
* Fixed default behavior for BADCHAN. supposed to DEFAULT yes, however
should not change each time a make config is done. -- WT
* doc/readme.www: add Runs link update patch for linux info. --Bleep
fi
fi
bool 'Set up a Unix domain socket to connect clients/servers' UNIXPORT
+ bool 'Do you need virtual hosting' VIRTUAL_HOST
PREV_HUB=$HUB
bool 'Will you connect to more then one server at a time' HUB
if [ "$PREV_HUB" != "$HUB" ]; then
define_bool MEMSIZESTATS $MEMSIZESTATS
define_bool MEMTIMESTATS $MEMTIMESTATS
fi
+ bool 'Are you testing on a host without DNS' NODNS
endmenu
mainmenu_option next_comment
comment 'Paths and files'
eval DPATH_DEFAULT="${prefix}/lib/ircd"
string 'Directory where all ircd stuff resides' DPATH $DPATH_DEFAULT
- define_string SPATH "$BINDIR/$SYMLINK"
+ define_string SPATH "$BINDIR/ircd"
echo "The following filenames are either full paths or files within DPATH"
string 'Server configuration file' CPATH 'ircd.conf'
string 'Server MOTD file' MPATH 'ircd.motd'
or when your local IRC client doesn't support UNIX domain sockets,
specify 'n' here. Otherwise specify 'y'.
+Do you need virtual hosting
+VIRTUAL_HOST
+ This is only needed when you want to run two or more servers on the
+ same machine and on the same port (but different devices).
+ In general you will only need this if you have at least two ethernet
+ cards in your machine with a different IP-number.
+ If you specify 'y' here, then you can "bind" a server to one of your
+ interfaces. You should use the command line option '-w' to tell the
+ server to which interface to bind to. No error is reported if this
+ fails, the server will simply not run.
+ If no '-w' option is given then the server name specified in the
+ 'M: line' of the "ircd.conf" file of the server is used, provided it
+ resolves to an IP-number of one of your interfaces. Note that
+ normally the name does not have to resolve, but when you define this,
+ it MUST resolve or you must use the -w command line option, or the
+ "bind" will fail.
+ If you are unsure, specify 'n'.
+
Will you connect to more then one server at a time
HUB
All servers of one IRC "network" are connected in a "tree" (no loops).
counted blocks must be returned. This allows to ignore recently allocated
blocks and permanently allocated blocks (since the start of the server).
+Are you testing on a host without DNS
+NODNS
+ If you are playing with the server off-line, and no DNS is available, then
+ long delays occur before the server starts up because it tries to resolv
+ the name given on the M:line (which usually isn't given in /etc/hosts) and
+ for each connecting client.
+ If you specify 'y' here, then a call to gethostbyname() will be done only
+ for the real hostname, and the server will not try to resolv clients that
+ connect to `localhost'.
+ Note that other calls to gethostbyname() are still done anyway if you
+ use VIRTUAL_HOST and that the server still tries to resolv clients
+ that connect to the real IP-number of the server.
+
Directory where all ircd stuff sits
DPATH
DPATH is provided so that the other path names may be provided in just
#
# First some information about the server.
-# M:<server name>:*:<description>:<server port>:<server numeric>
+# M:<server name>:<virtual ip>:<description>:<server port>:<server numeric>
+#
+# The <virtual ip> must be either be empty, contain a "*", or contain
+# the IP address of an interface on your system. If it contains an address,
+# the address will be bound to if you have specified virtual hosting.
#
# The <server port> is the port that other servers can connect to.
# Client ports need to be specified with a P: line, see below.
-# Note that P: lines can still be used to override the address
-# that a server port is bound to, use the <server port> of the M:
-# line in that case on the P: line.
#
# Note that <server numeric> has to be unique on the network your server
# is running on, must be between 1 and 64, and is not updated on a rehash.
-M:London.UK.Eu.UnderNet.org:*:[127.0.0.1] University of London, England:4400:1
+# M:London.UK.Eu.UnderNet.org:127.0.0.1:University of London, England:4400:1
+M:London.UK.Eu.UnderNet.org:*:University of London, England:4400:1
#
# This sets information that can be retrieved with the /ADMIN command.
# is located behind a firewall, you may want to make another hole in it
# for this port.
#
-# P:<ipmask, or path>:[<interface>|*]::<client port number>
-#
-# or
-#
-# P:<ipmask, or path>:[<interface>|*]::<server port>
-#
-# where <server port> is the port specified on the M: line.
-#
+# P:<hostmask, or path>:::<client port number>
-# Listen on port 6667 and 6668, use the default interface
-# (that is: the interface specified on the commandline with
-# -w <interface IP#>, or the interface of the IP# that the
-# M: line resolves too (or ALL interfaces if it doesn't
-# resolve)).
P::::6667
P::::6668
-# Only accept clients from 168.* on port 6666
-P:168.*:::6666
-
-# Listen on port 7700 for clients that connect to "127.0.0.1"
-# where "127.0.0.1" can be the IP number of any of your interfaces.
-P::127.0.0.1::7700
-# Bind to all interfaces:
-P::*::6669
-
-# Open a client UNIX port on /tmp/.ircd
+P:*.nl:::6666
P:/tmp/.ircd:::6667
-# Listen on loopback and eth0 (192.168.1.1) for other servers:
-P::192.168.1.1::4400 # <<--- The last P: line not specifying 127.0.0.1
- # is uses as IP# for _outgoing_ connections.
-P::127.0.0.1::4400
-# where 4400 is the server port (as specified on the M: line)
-
#
# Well, you have now reached the end of this sample configuration file
# If you have any questions, feel free to mail <doco-com@undernet.org>
allows inetd to start up ircd on request.
.TP
.B \-w interface
-\fIinterface\fP is passed to gethostbyname(3) in order to retrieve the
-IP-number of the default interface to bind to. An example would be to
-use `-w localhost' after which the server listens by default on the
-loopback interface. Use `ifconfig -a' to see which interfaces you have.
-Without this option the hostname in the M: line is used as default
-interface and if that doesn't resolve, all interfaces are used. The
-server uses the default interface to listen for UDP packets (UPING)
-and for each listen port without a specified interface to bind to.
-Interfaces can be specified per listen port in the configuration file
-(ircd.conf) using P: lines. Note that the last P: line in the
-ircd.conf specifying an interface (not localhost) overrules the
-default CONNECT interface (outgoing connections) but does not change
-the default listen interface as described above.
+If the server was compiled with VIRTUAL_HOST (run 'make config' to toggle
+this compile option), then \fIinterface\fP is passed to gethostbyname(3) in
+order to retrieve the IP-number of the interface to bind to. An example
+would be to use '-w localhost', after which the server only listens on the
+loopback interface. Run `ifconfig -a' to see which interfaces you have.
.TP
.B \-f filename
Specifies the ircd.conf file to be used for this ircdaemon. The option
extern aClient *client;
extern time_t TSoffset;
extern unsigned int bootopt;
-extern int have_server_port;
extern time_t nextdnscheck;
extern time_t nextconnect;
extern int dorehash;
\
\
\
- ".hide8"
+ ""
/*
* Deliberate empty lines
extern snomask_t umode_make_snomask(snomask_t oldmask, char *arg, int what);
extern int connect_server(aConfItem *aconf, aClient *by, struct hostent *hp);
extern void report_error(char *text, aClient *cptr);
-extern int inetport(aClient *cptr, char *name, char *bind_addr, unsigned short int port);
+extern int inetport(aClient *cptr, char *name, unsigned short int port);
extern int add_listener(aConfItem *aconf);
extern void close_listeners(void);
extern void init_sys(void);
extern void set_non_blocking(int fd, aClient *cptr);
extern aClient *add_connection(aClient *cptr, int fd, int type);
extern int read_message(time_t delay);
-extern void get_my_name(aClient *cptr, char *name, size_t len);
+extern void get_my_name(aClient *cptr);
extern int setup_ping(void);
extern int highest_fd, resfd;
extern unsigned int readcalls;
extern aClient *loc_clients[MAXCONNECTIONS];
+#ifdef VIRTUAL_HOST
extern struct sockaddr_in vserv;
-extern struct sockaddr_in cserv;
+#endif
#endif /* S_BSD_H */
if (new_mode) /* Do we have a nick with a new mode ? */
{
new_mode = 0;
- if (lp1->flags & (CHFL_CHANOP | CHFL_VOICE)) {
- sendbuf[sblen++] = ':';
- if (lp1->flags & CHFL_CHANOP)
- sendbuf[sblen++] = 'o';
- if (lp1->flags & CHFL_VOICE)
- sendbuf[sblen++] = 'v';
- }
+ sendbuf[sblen++] = ':';
+ if (lp1->flags & CHFL_CHANOP)
+ sendbuf[sblen++] = 'o';
+ if (lp1->flags & CHFL_VOICE)
+ sendbuf[sblen++] = 'v';
}
}
if (full)
break;
case 'x':
debugflag = 1;
- if (isdigit((int)argv[1][2]))
+ if (isdigit(argv[1][2]))
debugflag = atoi(&argv[1][2]);
break;
default:
#include <arpa/nameser.h>
#include <resolv.h>
#endif
+#ifdef VIRTUAL_HOST
#include <sys/socket.h> /* Needed for AF_INET on some OS */
+#endif
#include "h.h"
#include "res.h"
#include "struct.h"
(*pconf = con_conf)->next = 0;
}
if (connect_server(con_conf, (aClient *)NULL, (struct hostent *)NULL) == 0)
- sendto_ops("Connection to %s[%s] activated.",
- con_conf->name, con_conf->host);
+ sendto_ops("Connection to %s activated.", con_conf->name);
}
Debug((DEBUG_NOTICE, "Next connection check : %s", myctime(next)));
return (next);
if (!IsRegistered(cptr) && (DoingDNS(cptr) || DoingAuth(cptr)))
{
Debug((DEBUG_NOTICE, "%s/%s timeout %s", DoingDNS(cptr) ? "DNS" : "",
- DoingAuth(cptr) ? "AUTH" : "", get_client_name(cptr, TRUE)));
+ DoingAuth(cptr) ? "AUTH" : "", get_client_name(cptr, FALSE)));
if (cptr->authfd >= 0)
{
close(cptr->authfd);
}
if (IsServer(cptr) || IsConnecting(cptr) || IsHandshake(cptr))
{
- sendto_ops("No response from %s, closing link",
- get_client_name(cptr, FALSE));
+ sendto_ops("No response from %s, closing link", cptr->name);
exit_client(cptr, cptr, &me, "Ping timeout");
continue;
}
me.name, ERR_BADPING, cptr->name);
}
exit_client_msg(cptr, cptr, &me, "Ping timeout for %s",
- get_client_name(cptr, FALSE));
+ IsServer(cptr) ? cptr->name : get_client_name(cptr, FALSE));
}
continue;
}
cptr->flags = 0;
cptr->acpt = cptr;
loc_clients[2] = cptr;
- strcpy(cptr->sockhost, me.sockhost);
+ strcpy(cptr->sockhost, me.name);
printf("isatty = %d ttyname = %#x\n", isatty(2), (unsigned int)ttyname(2));
if (!(bootopt & BOOT_TTY)) /* leave debugging output on fd 2 */
return;
}
-int have_server_port;
-
int main(int argc, char *argv[])
{
unsigned short int portarg = 0;
myargv = argv;
umask(077); /* better safe than sorry --SRB */
memset(&me, 0, sizeof(me));
+#ifdef VIRTUAL_HOST
memset(&vserv, 0, sizeof(vserv));
- vserv.sin_family = AF_INET;
- vserv.sin_addr.s_addr = htonl(INADDR_ANY);
- memset(&cserv, 0, sizeof(cserv));
- cserv.sin_addr.s_addr = htonl(INADDR_ANY);
- cserv.sin_family = AF_INET;
+#endif
setup_signals();
initload();
case 'v':
printf("ircd %s\n", version);
exit(0);
+#ifdef VIRTUAL_HOST
case 'w':
{
struct hostent *hep;
if (!(hep = gethostbyname(p)))
{
- fprintf(stderr, "%s: Error resolving \"%s\" (h_errno == %d).\n",
- argv[-1], p, h_errno);
+ fprintf(stderr, "%s: Error creating virtual host \"%s\": %d",
+ argv[0], p, h_errno);
return -1;
}
if (hep->h_addrtype == AF_INET && hep->h_addr_list[0] &&
!hep->h_addr_list[1])
{
- int fd;
memcpy(&vserv.sin_addr, hep->h_addr_list[0], sizeof(struct in_addr));
- memcpy(&cserv.sin_addr, hep->h_addr_list[0], sizeof(struct in_addr));
- /* Test if we can bind to this address */
- fd = socket(AF_INET, SOCK_STREAM, 0);
- if (bind(fd, (struct sockaddr *)&vserv, sizeof(vserv)) == 0)
- {
- close(fd);
- break;
- }
+ vserv.sin_family = AF_INET;
}
- fprintf(stderr, "%s:\tError binding to interface \"%s\".\n"
- " \tUse `ifconfig -a' to check your interfaces.\n", argv[-1], p);
- return -1;
+ else
+ {
+ fprintf(stderr, "%s: Error creating virtual host \"%s\": "
+ "Use -w <IP-number of interface>\n", argv[0], p);
+ return -1;
+ }
+ break;
}
+#endif
case 'x':
#ifdef DEBUGMODE
if (euid != uid)
initmsgtree();
initstats();
open_debugfile();
+ if (portnum == 0)
+ portnum = PORTNUM;
+ me.port = portnum;
init_sys();
me.flags = FLAGS_LISTEN;
if ((bootopt & BOOT_INETD))
printf("Couldn't open configuration file %s\n", configfile);
exit(-1);
}
+ get_my_name(&me);
+
if (!(bootopt & BOOT_INETD))
{
+ static char star[] = "*";
+ aConfItem *aconf;
+
+ if ((aconf = find_me()) && portarg == 0 && aconf->port != 0)
+ portnum = aconf->port;
Debug((DEBUG_ERROR, "Port = %u", portnum));
- if (!have_server_port && inetport(&me, "*", "", portnum))
+ if (inetport(&me, star, portnum))
exit(1);
}
- else if (inetport(&me, "*", "*", 0))
+ else if (inetport(&me, "*", 0))
exit(1);
read_tlines();
rmotd = read_motd(RPATH);
motd = read_motd(MPATH);
setup_ping();
- get_my_name(&me, me.sockhost, sizeof(me.sockhost) - 1);
now = time(NULL);
me.hopcount = 0;
me.authfd = -1;
sendto_one(sptr, rpl_str(p[1]),
me.name, sptr->name, c, host, pass, name, port,
get_conf_class(tmp));
+ else if ((tmp->status & (CONF_CONNECT_SERVER|CONF_NOCONNECT_SERVER)))
+ sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, "*", name,
+ port, get_conf_class(tmp));
else
sendto_one(sptr, rpl_str(p[1]), me.name, sptr->name, c, host, name,
port, get_conf_class(tmp));
if (!(doall || wilds) && strCasediff(name, acptr->name))
continue;
sendto_one(sptr, Lformat, me.name, RPL_STATSLINKINFO, parv[0],
- (isUpper(stat)) ?
- get_client_name(acptr, TRUE) : get_client_name(acptr, FALSE),
+ acptr->name,
(int)DBufLength(&acptr->sendQ), (int)acptr->sendM,
(int)acptr->sendK, (int)acptr->receiveM, (int)acptr->receiveK,
time(NULL) - acptr->firsttime);
*
* parv[0] = sender prefix
* parv[1] = servername
- * parv[2] = [IP-number:]port number
+ * parv[2] = port number
* parv[3] = remote server
*/
int m_connect(aClient *cptr, aClient *sptr, int parc, char *parv[])
unsigned short int port, tmpport;
aConfItem *aconf, *cconf;
aClient *acptr;
- char *p;
if (!IsPrivileged(sptr))
{
return 0;
}
- if (parc > 2 && !BadPtr(parv[2]))
- p = strchr(parv[2], ':');
- else
- p = 0;
- if (p)
- *p = 0;
for (aconf = conf; aconf; aconf = aconf->next)
if (aconf->status == CONF_CONNECT_SERVER &&
- match(parv[1], aconf->name) == 0 &&
- (!p || match(parv[2], aconf->host) == 0 ||
- match(parv[2], strchr(aconf->host, '@') + 1) == 0))
+ match(parv[1], aconf->name) == 0)
break;
/* Checked first servernames, then try hostnames. */
if (!aconf)
(match(parv[1], aconf->host) == 0 ||
match(parv[1], strchr(aconf->host, '@') + 1) == 0))
break;
- if (p)
- *p = ':';
if (!aconf)
{
tmpport = port = aconf->port;
if (parc > 2 && !BadPtr(parv[2]))
{
- p = strchr(parv[2], ':');
- if (!p)
- p = parv[2];
- else
- p = p + 1;
- if ((port = atoi(p)) == 0)
+ if ((port = atoi(parv[2])) == 0)
{
if (MyUser(sptr) || Protocol(cptr) < 10)
sendto_one(sptr,
case 0:
if (MyUser(sptr) || Protocol(cptr) < 10)
sendto_one(sptr,
- ":%s NOTICE %s :*** Connecting to %s[%s].",
- me.name, parv[0], aconf->host, aconf->name);
+ ":%s NOTICE %s :*** Connecting to %s.",
+ me.name, parv[0], aconf->name);
else
sendto_one(sptr,
- "%s NOTICE %s%s :*** Connecting to %s[%s].",
- NumServ(&me), NumNick(sptr), aconf->host, aconf->name);
+ "%s NOTICE %s%s :*** Connecting to %s.",
+ NumServ(&me), NumNick(sptr), aconf->name);
break;
case -1:
/* Comments already sent */
case -2:
if (MyUser(sptr) || Protocol(cptr) < 10)
sendto_one(sptr, ":%s NOTICE %s :*** Host %s is unknown.",
- me.name, parv[0], aconf->host);
+ me.name, parv[0], aconf->name);
else
sendto_one(sptr, "%s NOTICE %s%s :*** Host %s is unknown.",
- NumServ(&me), NumNick(sptr), aconf->host);
+ NumServ(&me), NumNick(sptr), aconf->name);
break;
default:
if (MyUser(sptr) || Protocol(cptr) < 10)
sendto_one(sptr,
":%s NOTICE %s :*** Connection to %s failed: %s",
- me.name, parv[0], aconf->host, strerror(retval));
+ me.name, parv[0], aconf->name, strerror(retval));
else
sendto_one(sptr,
"%s NOTICE %s%s :*** Connection to %s failed: %s",
- NumServ(&me), NumNick(sptr), aconf->host, strerror(retval));
+ NumServ(&me), NumNick(sptr), aconf->name, strerror(retval));
}
aconf->port = tmpport;
return 0;
}
#else
sendto_ops("SETTIME from %s, clock is set %ld seconds %s",
- get_client_name(sptr, FALSE), (dt < 0) ? -dt : dt,
+ sptr->name, (dt < 0) ? -dt : dt,
(dt < 0) ? "forwards" : "backwards");
TSoffset -= dt;
if (IsUser(sptr))
for (i = 0; i <= highest_fd; i++)
{
- char *name;
unsigned int conClass;
if (!(acptr = loc_clients[i])) /* Local Connection? */
continue;
if (!dow && strCasediff(tname, acptr->name))
continue;
- name = get_client_name(acptr, FALSE);
conClass = get_client_class(acptr);
switch (acptr->status)
{
case STAT_CONNECTING:
sendto_one(sptr, rpl_str(RPL_TRACECONNECTING),
- me.name, parv[0], conClass, name);
+ me.name, parv[0], conClass, acptr->name);
cnt++;
break;
case STAT_HANDSHAKE:
sendto_one(sptr, rpl_str(RPL_TRACEHANDSHAKE),
- me.name, parv[0], conClass, name);
+ me.name, parv[0], conClass, acptr->name);
cnt++;
break;
case STAT_ME:
break;
case STAT_UNKNOWN:
case STAT_UNKNOWN_USER:
+ sendto_one(sptr, rpl_str(RPL_TRACEUNKNOWN),
+ me.name, parv[0], conClass, get_client_name(acptr, FALSE));
+ cnt++;
+ break;
case STAT_UNKNOWN_SERVER:
sendto_one(sptr, rpl_str(RPL_TRACEUNKNOWN),
- me.name, parv[0], conClass, name);
+ me.name, parv[0], conClass, acptr->name);
cnt++;
break;
case STAT_USER:
{
if (IsAnOper(acptr))
sendto_one(sptr, rpl_str(RPL_TRACEOPERATOR),
- me.name, parv[0], conClass, name, now - acptr->lasttime);
+ me.name, parv[0], conClass, get_client_name(acptr, FALSE), now - acptr->lasttime);
else
sendto_one(sptr, rpl_str(RPL_TRACEUSER),
- me.name, parv[0], conClass, name, now - acptr->lasttime);
+ me.name, parv[0], conClass, get_client_name(acptr, FALSE), now - acptr->lasttime);
cnt++;
}
break;
if (acptr->serv->user)
sendto_one(sptr, rpl_str(RPL_TRACESERVER),
me.name, parv[0], conClass, link_s[i],
- link_u[i], name, acptr->serv->by,
+ link_u[i], acptr->name, acptr->serv->by,
acptr->serv->user->username,
acptr->serv->user->host,
now - acptr->lasttime, now - acptr->serv->timestamp);
else
sendto_one(sptr, rpl_str(RPL_TRACESERVER),
me.name, parv[0], conClass, link_s[i],
- link_u[i], name, *(acptr->serv->by) ?
+ link_u[i], acptr->name, *(acptr->serv->by) ?
acptr->serv->by : "*", "*", me.name,
now - acptr->lasttime, now - acptr->serv->timestamp);
cnt++;
break;
case STAT_PING:
sendto_one(sptr, rpl_str(RPL_TRACEPING), me.name,
- parv[0], name, (acptr->acpt) ? acptr->acpt->name : "<null>");
+ parv[0], acptr->name, (acptr->acpt) ? acptr->acpt->name : "<null>");
break;
default: /* We actually shouldn't come here, -msa */
- sendto_one(sptr, rpl_str(RPL_TRACENEWTYPE), me.name, parv[0], name);
+ sendto_one(sptr, rpl_str(RPL_TRACENEWTYPE), me.name, parv[0], acptr->name);
cnt++;
break;
}
if (!IsUnknown(acptr) && !IsConnecting(acptr) && !IsHandshake(acptr))
continue;
sendto_one(sptr, rpl_str(RPL_CLOSING), me.name, parv[0],
- get_client_name(acptr, TRUE), acptr->status);
+ get_client_name(acptr, FALSE), acptr->status);
exit_client(cptr, acptr, &me, "Oper Closing");
closed++;
}
continue;
if (IsUser(acptr))
sendto_one(acptr, ":%s NOTICE %s :Server Terminating. %s",
- me.name, acptr->name, get_client_name(sptr, TRUE));
+ me.name, acptr->name, get_client_name(sptr, FALSE));
else if (IsServer(acptr))
sendto_one(acptr, ":%s ERROR :Terminated by %s",
- me.name, get_client_name(sptr, TRUE));
+ me.name, get_client_name(sptr, FALSE));
}
#ifdef __cplusplus
s_die(0);
sendto_one(from, ":%s %d %s %s :Unknown command",
me.name, ERR_UNKNOWNCOMMAND, from->name, ch);
Debug((DEBUG_ERROR, "Unknown (%s) from %s",
- ch, get_client_name(cptr, TRUE)));
+ ch, get_client_name(cptr, FALSE)));
}
ircstp->is_unco++;
return (-1);
if (buffer[0] != '\0')
{
Debug((DEBUG_ERROR, "Unknown (%s) from %s",
- ch, get_client_name(cptr, TRUE)));
+ ch, get_client_name(cptr, FALSE)));
}
#endif
ircstp->is_unco++;
{
struct sockaddr_in sock;
int err;
- int len = sizeof(struct sockaddr_in);
Debug((DEBUG_NOTICE, "start_auth(%p) fd %d status %d",
cptr, cptr->fd, cptr->status));
cptr->authfd = socket(AF_INET, SOCK_STREAM, 0);
err = errno;
alarm(0);
- if (cptr->authfd < 0 && err == EAGAIN)
- sendto_ops("Can't allocate fd for auth on %s : socket: No more sockets",
- get_client_name(cptr, TRUE));
if (cptr->authfd < 0)
{
#ifdef USE_SYSLOG
syslog(LOG_ERR, "Unable to create auth socket for %s:%m",
- get_client_name(cptr, TRUE));
+ get_client_name(cptr, FALSE));
#endif
Debug((DEBUG_ERROR, "Unable to create auth socket for %s:%s",
- get_client_name(cptr, TRUE), strerror(get_sockerr(cptr))));
+ get_client_name(cptr, FALSE), strerror(get_sockerr(cptr))));
if (!DoingDNS(cptr))
SetAccess(cptr);
ircstp->is_abad++;
}
if (cptr->authfd >= (MAXCONNECTIONS - 2))
{
- sendto_ops("Can't allocate fd for auth on %s", get_client_name(cptr, TRUE));
close(cptr->authfd);
cptr->authfd = -1;
return;
set_non_blocking(cptr->authfd, cptr);
- if (getsockname(cptr->fd, (struct sockaddr *)&sock, &len) == -1
- || (sock.sin_port = 0) /* Reset sin_port and let OS choose the port */
- || bind(cptr->authfd, (struct sockaddr *)&sock, len) == -1)
+#ifdef VIRTUAL_HOST
+ if (bind(cptr->authfd, (struct sockaddr *)&vserv, sizeof(vserv)) == -1)
{
report_error("binding auth stream socket %s: %s", cptr);
close(cptr->authfd);
cptr->authfd = -1;
- /*
- * fsck can't return exit_client here ... let read_message
- * do it when we get done here. At any rate this error is
- * fatal for the client, mark it dead.
- */
- cptr->flags |= FLAGS_DEADSOCKET;
return;
}
-
+#endif
memcpy(&sock.sin_addr, &cptr->ip, sizeof(struct in_addr));
sock.sin_port = htons(113);
{
#ifdef USE_SYSLOG
syslog(LOG_ERR, "auth get{sock,peer}name error for %s:%m",
- get_client_name(cptr, TRUE));
+ get_client_name(cptr, FALSE));
#endif
goto authsenderr;
}
static struct pollfd poll_fds[MAXCONNECTIONS + 1];
static aClient *poll_cptr[MAXCONNECTIONS + 1];
#endif /* USE_POLL */
-struct sockaddr_in vserv; /* Default address/interface to bind listen sockets to.
- This is set with the -w commandline option OR whatever
- the name in the M: line resolves to OR INADDR_ANY. */
-struct sockaddr_in cserv; /* Default address/interface to bind connecting sockets to.
- This is set with the -w commandline option OR whatever
- the name in the M: line resolves to OR the first
- interface specified in the ircd.conf file for the
- server port. */
+#ifdef VIRTUAL_HOST
+struct sockaddr_in vserv;
+#endif
static int running_in_background;
#ifdef GODMODE
+#ifndef NODNS
+#define NODNS
+#endif
#ifndef NOFLOODCONTROL
#define NOFLOODCONTROL
#endif
{
Reg1 int errtmp = errno; /* debug may change 'errno' */
Reg2 char *host;
-#if defined(SO_ERROR) && !defined(SOL2)
int err;
size_t len = sizeof(err);
-#endif
- host = (cptr) ? get_client_name(cptr, FALSE) : "";
+ host = (cptr) ? cptr->name : "";
Debug((DEBUG_ERROR, text, host, strerror(errtmp)));
* depending on the IP# mask given by 'name'. Returns the fd of the
* socket created or -1 on error.
*/
-int inetport(aClient *cptr, char *name, char *bind_addr, unsigned short int port)
+int inetport(aClient *cptr, char *name, unsigned short int port)
{
- unsigned short int sin_port;
+ static struct sockaddr_in server;
int ad[4], opt;
+ size_t len = sizeof(server);
char ipname[20];
-#ifdef TESTNET
- sin_port = htons(port + 10000);
-#else
- sin_port = htons(port);
-#endif
-
ad[0] = ad[1] = ad[2] = ad[3] = 0;
/*
* do it this way because building ip# from separate values for each
* byte requires endian knowledge or some nasty messing. Also means
- * easy conversion of "*" to 0.0.0.0 or 134.* to 134.0.0.0 :-)
+ * easy conversion of "*" 0.0.0.0 or 134.* to 134.0.0.0 :-)
*/
sscanf(name, "%d.%d.%d.%d", &ad[0], &ad[1], &ad[2], &ad[3]);
sprintf_irc(ipname, "%d.%d.%d.%d", ad[0], ad[1], ad[2], ad[3]);
if (cptr->fd < 0 && errno == EAGAIN)
{
sendto_ops("opening stream socket %s: No more sockets",
- get_client_name(cptr, TRUE));
+ cptr->name);
return -1;
}
}
*/
if (port)
{
- struct sockaddr_in bindaddr;
- memset(&bindaddr, 0, sizeof(struct sockaddr_in));
- if (*bind_addr == '*' && bind_addr[1] == 0)
- bindaddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Bind to all interfaces */
- else if (*bind_addr)
- {
- bindaddr.sin_addr.s_addr = inet_addr(bind_addr); /* Use name from P: line */
- /* If server port and bind_addr isn't localhost: */
- if (port == portnum && strcmp("127.0.0.1", bind_addr))
- cserv.sin_addr.s_addr = bindaddr.sin_addr.s_addr; /* Initialize /connect port */
- }
- else
- bindaddr.sin_addr = vserv.sin_addr; /* Default */
- bindaddr.sin_family = AF_INET;
- bindaddr.sin_port = sin_port;
- if (bind(cptr->fd, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) == -1)
+ server.sin_family = AF_INET;
+#ifndef VIRTUAL_HOST
+ server.sin_addr.s_addr = INADDR_ANY;
+#else
+ server.sin_addr = vserv.sin_addr;
+#endif
+#ifdef TESTNET
+ server.sin_port = htons(port + 10000);
+#else
+ server.sin_port = htons(port);
+#endif
+ if (bind(cptr->fd, (struct sockaddr *)&server, sizeof(server)) == -1)
{
report_error("binding stream socket %s: %s", cptr);
close(cptr->fd);
return -1;
}
}
+ if (getsockname(cptr->fd, (struct sockaddr *)&server, &len))
+ {
+ report_error("getsockname failed for %s: %s", cptr);
+ close(cptr->fd);
+ return -1;
+ }
if (cptr == &me) /* KLUDGE to get it work... */
{
char buf[1024];
- sprintf_irc(buf, rpl_str(RPL_MYPORTIS), me.name, "*", port);
+
+#ifdef TESTNET
+ sprintf_irc(buf, rpl_str(RPL_MYPORTIS), me.name, "*",
+ ntohs(server.sin_port) - 10000);
+#else
+ sprintf_irc(buf, rpl_str(RPL_MYPORTIS), me.name, "*",
+ ntohs(server.sin_port));
+#endif
write(1, buf, strlen(buf));
}
if (cptr->fd > highest_fd)
highest_fd = cptr->fd;
cptr->ip.s_addr = inet_addr(ipname);
- cptr->port = port;
+#ifdef TESTNET
+ cptr->port = ntohs(server.sin_port) - 10000;
+#else
+ cptr->port = ntohs(server.sin_port);
+#endif
listen(cptr->fd, 128); /* Use listen port backlog of 128 */
loc_clients[cptr->fd] = cptr;
if (cptr->fd == -1 && errno == EAGAIN)
{
sendto_ops("error opening unix domain socket %s: No more sockets",
- get_client_name(cptr, TRUE));
+ cptr->name);
return -1;
}
if (cptr->fd == -1)
}
else
#endif
- if (inetport(cptr, aconf->host, aconf->passwd, aconf->port))
+ if (inetport(cptr, aconf->host, aconf->port))
cptr->fd = -2;
if (cptr->fd >= 0)
cptr->confs->next = NULL;
cptr->confs->value.aconf = aconf;
set_non_blocking(cptr->fd, cptr);
- if (aconf->port == portnum)
- have_server_port = 1;
}
else
free_client(cptr);
/* If descriptor is a tty, special checking... */
if (isatty(cptr->fd))
{
- strncpy(sockn, me.sockhost, HOSTLEN);
+ strncpy(sockn, me.name, HOSTLEN);
memset(&sk, 0, sizeof(struct sockaddr_in));
}
else if (getpeername(cptr->fd, (struct sockaddr *)&sk, &len) == -1)
if (inet_netof(sk.sin_addr) == IN_LOOPBACKNET)
{
cptr->hostp = NULL;
- strncpy(sockn, me.sockhost, HOSTLEN);
+ strncpy(sockn, me.name, HOSTLEN);
}
memcpy(&cptr->ip, &sk.sin_addr, sizeof(struct in_addr));
#ifdef TESTNET
n_conf = find_conf(lp, name, NFLAG);
if (!c_conf || !n_conf)
{
- sendto_ops("Connecting Error: %s[%s]", name, cptr->sockhost);
+ sendto_ops("Connecting Error: %s", name);
det_confs_butmask(cptr, 0);
return -1;
}
aconf = find_conf(cptr->confs, cptr->name, CONF_CONNECT_SERVER);
if (!aconf)
{
- sendto_ops("Lost C-Line for %s", get_client_name(cptr, FALSE));
+ sendto_ops("Lost C-Line for %s", cptr->name);
return -1;
}
if (!BadPtr(aconf->passwd))
aconf = find_conf(cptr->confs, cptr->name, CONF_NOCONNECT_SERVER);
if (!aconf)
{
- sendto_ops("Lost N-Line for %s", get_client_name(cptr, FALSE));
+ sendto_ops("Lost N-Line for %s", cptr->name);
return -1;
}
make_server(cptr);
sprintf(s, "%02x:", *t++);
*s = '\0';
sendto_ops("Connection %s using IP opts: (%s)",
- get_client_name(cptr, TRUE), readbuf);
+ get_client_name(cptr, FALSE), readbuf);
}
if (setsockopt(fd, IPPROTO_IP, IP_OPTIONS, (OPT_TYPE *)NULL, 0) < 0)
report_error("setsockopt(IP_OPTIONS) %s: %s", cptr);
int get_sockerr(aClient *cptr)
{
- int errtmp = errno;
-#if defined(SO_ERROR) && !defined(SOL2)
- int err = 0;
+ int errtmp = errno, err = 0;
size_t len = sizeof(err);
+#if defined(SO_ERROR) && !defined(SOL2)
if (cptr->fd >= 0)
if (!getsockopt(cptr->fd, SOL_SOCKET, SO_ERROR, (OPT_TYPE *)&err, &len))
if (err)
return;
}
+extern unsigned short server_port;
+
/*
* Creates a client which has just connected to us on the given fd.
* The sockhost field is initialized with the ip# of the host.
aConfItem *aconf = NULL;
acptr =
make_client(NULL,
- (cptr->port == portnum) ? STAT_UNKNOWN_SERVER : STAT_UNKNOWN_USER);
+ (cptr->port == server_port) ? STAT_UNKNOWN_SERVER : STAT_UNKNOWN_USER);
if (cptr != &me)
aconf = cptr->confs->value.aconf;
lin.flags = ASYNC_CLIENT;
lin.value.cptr = acptr;
- Debug((DEBUG_DNS, "lookup %s", inetntoa(addr.sin_addr)));
- acptr->hostp = gethost_byaddr(&acptr->ip, &lin);
- if (!acptr->hostp)
- SetDNS(acptr);
- nextdnscheck = 1;
+#ifdef NODNS
+ if (!strcmp("127.0.0.1", inetntoa(addr.sin_addr)))
+ {
+ static struct hostent lhe = { "localhost", NULL, 0, 0, NULL };
+ acptr->hostp = &lhe;
+ if (!DoingAuth(acptr))
+ SetAccess(acptr);
+ }
+ else
+ {
+#endif
+ Debug((DEBUG_DNS, "lookup %s", inetntoa(addr.sin_addr)));
+ acptr->hostp = gethost_byaddr(&acptr->ip, &lin);
+ if (!acptr->hostp)
+ SetDNS(acptr);
+ nextdnscheck = 1;
+#ifdef NODNS
+ }
+#endif
}
if (aconf)
* Copy ascii address to 'sockhost' just in case. Then we
* have something valid to put into error messages...
*/
- get_sockhost(acptr, me.sockhost);
+ strncpy(acptr->sockhost, me.name, HOSTLEN);
if (cptr != &me)
aconf = cptr->confs->value.aconf;
if (aconf)
STIME_T_FMT " minutes", count, (now - last_time) / 60);
}
else
- sendto_ops("All connections in use. (%s)", get_client_name(cptr,
- TRUE));
+ sendto_ops("All connections in use. (%s)", cptr->name);
count = 0;
last_time = now;
}
continue;
nfds--;
readcalls++;
- if (length > 0 || length == CPTR_KILLED)
+ if (length > 0)
continue;
/*
*/
Debug((DEBUG_ERROR, "READ ERROR: fd = %d %d %d", LOC_FD(i), errno, length));
+ if (length == CPTR_KILLED)
+ continue;
+
if ((IsServer(cptr) || IsHandshake(cptr)) && errno == 0 && length == 0)
exit_client_msg(cptr, cptr, &me, "Server %s closed the connection (%s)",
- get_client_name(cptr, FALSE), cptr->serv->last_error_msg);
+ cptr->name, cptr->serv->last_error_msg);
else
exit_client_msg(cptr, cptr, &me, "Read error to %s: %s",
get_client_name(cptr, FALSE), (length < 0) ?
{
if (MyUser(by) || Protocol(by->from) < 10)
sendto_one(by, ":%s NOTICE %s :Connection to %s already in progress",
- me.name, by->name, get_client_name(c2ptr, TRUE));
+ me.name, by->name, c2ptr->name);
else
sendto_one(by,
"%s NOTICE %s%s :Connection to %s already in progress",
- NumServ(&me), NumNick(by), get_client_name(c2ptr, TRUE));
+ NumServ(&me), NumNick(by), c2ptr->name);
}
return -1;
}
#ifndef NO_PROTOCOL9
if (Protocol(by->from) < 10)
sendto_one(by, ":%s NOTICE %s :Couldn't connect to %s",
- me.name, by->name, get_client_name(cptr, TRUE));
+ me.name, by->name, cptr->name);
else
#endif
sendto_one(by, "%s NOTICE %s%s :Couldn't connect to %s",
- NumServ(&me), NumNick(by), get_client_name(cptr, TRUE));
+ NumServ(&me), NumNick(by), cptr->name);
}
free_client(cptr);
return -1;
#ifndef NO_PROTOCOL9
if (Protocol(by->from) < 10)
sendto_one(by, ":%s NOTICE %s :Connect to host %s failed: %s",
- me.name, by->name, get_client_name(cptr, TRUE), strerror(err));
+ me.name, by->name, cptr->name, strerror(err));
else
#endif
sendto_one(by, "%s NOTICE %s%s :Connect to host %s failed: %s",
- NumServ(&me), NumNick(by), get_client_name(cptr, TRUE),
- strerror(err));
+ NumServ(&me), NumNick(by), cptr->name, strerror(err));
}
close(cptr->fd);
cptr->fd = -2;
!find_conf_host(cptr->confs, aconf->host, CONF_CONNECT_SERVER))
{
sendto_ops("Host %s is not enabled for connecting:no C/N-line",
- aconf->host);
+ aconf->name);
if (by && IsUser(by) && !MyUser(by))
{
#ifndef NO_PROTOCOL9
if (Protocol(by->from) < 10)
sendto_one(by,
":%s NOTICE %s :Connect to host %s failed: no C/N-lines",
- me.name, by->name, get_client_name(cptr, TRUE));
+ me.name, by->name, cptr->name);
else
#endif
sendto_one(by,
"%s NOTICE %s%s :Connect to host %s failed: no C/N-lines",
- NumServ(&me), NumNick(by), get_client_name(cptr, TRUE));
+ NumServ(&me), NumNick(by), cptr->name);
}
det_confs_butmask(cptr, 0);
close(cptr->fd);
{
static struct sockaddr_in server;
Reg3 struct hostent *hp;
- struct sockaddr_in bindaddr;
/*
* Might as well get sockhost from here, the connection is attempted
if (cptr->fd == -1 && errno == EAGAIN)
{
sendto_ops("opening stream socket to server %s: No more sockets",
- get_client_name(cptr, TRUE));
+ cptr->name);
return NULL;
}
if (cptr->fd == -1)
return NULL;
}
mysk.sin_port = 0;
+
memset(&server, 0, sizeof(server));
server.sin_family = AF_INET;
get_sockhost(cptr, aconf->host);
+#ifdef VIRTUAL_HOST
+ mysk.sin_addr = vserv.sin_addr;
+#endif
+
/*
* Bind to a local IP# (with unknown port - let unix decide) so
* we have some chance of knowing the IP# that gets used for a host
* with more than one IP#.
*/
- memcpy(&bindaddr, &cserv, sizeof(bindaddr));
- if (aconf->ipnum.s_addr == 0x100007f)
- bindaddr.sin_addr.s_addr = 0x100007f; /* bind with localhost when we are connecting to localhost */
- if (bind(cptr->fd, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) == -1)
+ /* No we don't bind it, not all OS's can handle connecting with
+ * an already bound socket, different ip# might occur anyway
+ * leading to a freezing select() on this side for some time.
+ * I had this on my Linux 1.1.88 --Run
+ */
+#ifdef VIRTUAL_HOST
+ /*
+ * No, we do bind it if we have virtual host support. If we don't
+ * explicitly bind it, it will default to IN_ADDR_ANY and we lose
+ * due to the other server not allowing our base IP --smg
+ */
+ if (bind(cptr->fd, (struct sockaddr *)&mysk, sizeof(mysk)) == -1)
{
report_error("error binding to local port for %s: %s", cptr);
return NULL;
}
+#endif
/*
* By this point we should know the IP# of the host listed in the
if (cptr->fd == -1 && errno == EAGAIN)
{
sendto_ops("Unix domain connect to host %s failed: No more sockets",
- get_client_name(cptr, TRUE));
+ cptr->name);
return NULL;
}
if (cptr->fd == -1)
* matches the server's name) and its primary IP#. Hostname is stored
* in the client structure passed as a pointer.
*/
-void get_my_name(aClient *cptr, char *name, size_t len)
+void get_my_name(aClient *cptr)
{
- static char tmp[HOSTLEN + 1];
-#if HAVE_UNAME
- struct utsname utsn;
-#endif
- struct hostent *hp;
- char *cname = cptr->name;
- size_t len2;
-
+ struct ConfItem* aconf = find_me();
/*
* Setup local socket structure to use for binding to.
*/
memset(&mysk, 0, sizeof(mysk));
mysk.sin_family = AF_INET;
+ mysk.sin_addr.s_addr = INADDR_ANY;
-#if HAVE_UNAME
- if (uname(&utsn) == -1)
- return;
- len2 = strlen(utsn.nodename);
- if (len2 > len)
- len2 = len;
- strncpy(name, utsn.nodename, len2);
-#else /* HAVE_GETHOSTNAME */
- if (gethostname(name, len) == -1)
- return;
-#endif
- name[len] = '\0';
-
- /* Assume that a name containing '.' is a FQDN */
- if (!strchr(name, '.'))
- add_local_domain(name, len - strlen(name));
-
- /*
- * If hostname gives another name than cname, then check if there is
- * a CNAME record for cname pointing to hostname. If so accept
- * cname as our name. meLazy
- */
- if (BadPtr(cname))
+ if (!aconf || BadPtr(aconf->host))
return;
- if ((hp = gethostbyname(cname)) || (hp = gethostbyname(name)))
- {
- const char *hname;
- int i = 0;
-
- for (hname = hp->h_name; hname; hname = hp->h_aliases[i++])
- {
- strncpy(tmp, hname, sizeof(tmp) - 1);
- add_local_domain(tmp, sizeof(tmp) - 1 - strlen(tmp));
+ strncpy(me.name, aconf->host, sizeof(me.name) - 1);
- /*
- * Copy the matching name over and store the
- * 'primary' IP# as 'myip' which is used
- * later for making the right one is used
- * for connecting to other hosts.
- */
- if (!strCasediff(me.name, tmp))
- break;
- }
- if (strCasediff(me.name, tmp))
- strncpy(name, hp->h_name, len);
- else
- strncpy(name, tmp, len);
- memcpy(&mysk.sin_addr, hp->h_addr, sizeof(struct in_addr));
- Debug((DEBUG_DEBUG, "local name is %s", get_client_name(&me, TRUE)));
+ if (!BadPtr(aconf->passwd) && 0 != strcmp(aconf->passwd, "*")) {
+ mysk.sin_addr.s_addr = inet_addr(aconf->passwd);
+ if (INADDR_NONE == mysk.sin_addr.s_addr)
+ mysk.sin_addr.s_addr = INADDR_ANY;
+#ifdef VIRTUAL_HOST
+ memcpy(&vserv, &mysk, sizeof(struct sockaddr_in));
+#endif
}
- return;
+ Debug((DEBUG_DEBUG, "local name is %s", get_client_name(&me, TRUE)));
}
/*
int on = 1;
memset(&from, 0, sizeof(from));
- from.sin_addr = cserv.sin_addr;
+#ifdef VIRTUAL_HOST
+ from.sin_addr = vserv.sin_addr;
+#else
+ from.sin_addr.s_addr = htonl(INADDR_ANY);
+#endif
#ifdef TESTNET
from.sin_port = htons(atoi(UDP_PORT) + 10000);
#else
#define MAXCONFLINKS 150
+unsigned short server_port;
+
int initconf(int opt)
{
static char quotes[9][2] = {
tmp = getfield(NULL, ':');
if (aconf->status & CONF_ME)
{
- portnum = aconf->port;
- if (portnum == 0)
- portnum = PORTNUM;
- me.port = portnum;
- vserv.sin_port = htons(portnum);
+ server_port = aconf->port;
if (!tmp)
{
Debug((DEBUG_FATAL, "Your M: line must have the Numeric, "
if (aconf->status == CONF_ME)
{
strncpy(me.info, aconf->name, sizeof(me.info) - 1);
- if (me.name[0] == '\0' && aconf->host[0])
- {
- strncpy(me.name, aconf->host, sizeof(me.name) - 1);
- if (vserv.sin_addr.s_addr == htonl(INADDR_ANY)) /* Not already initialised on commandline with -w ? */
- {
- struct hostent *hep;
- hep = gethostbyname(me.name);
- if (hep && hep->h_addrtype == AF_INET && hep->h_addr_list[0] && !hep->h_addr_list[1])
- {
- memcpy(&vserv.sin_addr, hep->h_addr_list[0], sizeof(struct in_addr));
- memcpy(&cserv.sin_addr, hep->h_addr_list[0], sizeof(struct in_addr));
- }
- }
- }
if (portnum == 0)
portnum = aconf->port;
- have_server_port = 0;
}
/*
#if defined(USE_POLL) && defined(HAVE_POLL_H)
'U',
#endif
+#ifdef VIRTUAL_HOST
+ 'v',
+#endif
#ifdef BADCHAN
'W',
#ifdef LOCAL_BADCHAN
if (showip)
sprintf_irc(nbuf, "%s[%s]", sptr->name, sptr->sockhost);
else
- sprintf_irc(nbuf, "%s[%s]", sptr->name, me.sockhost);
+ sprintf_irc(nbuf, "%s[%s]", sptr->name, me.name);
}
else
{
sendto_lops_butone(sptr, "%s SQUIT by %s [%s]:",
(sptr->user->server == bcptr ||
sptr->user->server == bcptr->serv->up) ? "Local" : "Remote",
- get_client_name(sptr, TRUE), sptr->user->server->name);
+ get_client_name(sptr, FALSE), sptr->user->server->name);
else if (sptr != &me && bcptr->serv->up != sptr)
sendto_ops("Received SQUIT %s from %s :", bcptr->name,
- IsServer(sptr) ? sptr->name : get_client_name(sptr, TRUE));
+ IsServer(sptr) ? sptr->name : get_client_name(sptr, FALSE));
sendto_op_mask(SNO_NETWORK, "Net break: %s (%s)", comment1, comment);
}
aConfItem *aconf;
unsigned short int port;
int fd, opt;
- char *p;
if (!IsPrivileged(sptr))
{
}
/* Check if a CONNECT would be possible at all (adapted from m_connect) */
- if (parc > 2 && !BadPtr(parv[2]))
- p = strchr(parv[2], ':');
- else
- p = 0;
- if (p)
- *p = 0;
for (aconf = conf; aconf; aconf = aconf->next)
if (aconf->status == CONF_CONNECT_SERVER &&
- match(parv[1], aconf->name) == 0 &&
- (!p || match(parv[2], aconf->host) == 0 ||
- match(parv[2], strchr(aconf->host, '@') + 1) == 0))
+ match(parv[1], aconf->name) == 0)
break;
if (!aconf)
for (aconf = conf; aconf; aconf = aconf->next)
(match(parv[1], aconf->host) == 0 ||
match(parv[1], strchr(aconf->host, '@') + 1) == 0))
break;
- if (p)
- *p = ':';
if (!aconf)
{
if (MyUser(sptr) || Protocol(cptr) < 10)
/*
* Determine port: First user supplied, then default : 7007
*/
- if (!p || (port = atoi(p + 1)) <= 0)
+ if (BadPtr(parv[2]) || (port = atoi(parv[2])) <= 0)
port = atoi(UDP_PORT);
alarm(2);
close(fd);
return 0;
}
- if (bind(fd, (struct sockaddr *)&cserv, sizeof(cserv)) == -1)
- {
- sendto_ops("Failure binding fd for uping");
- if (MyUser(sptr) || Protocol(cptr) < 10)
- sendto_one(sptr, ":%s NOTICE %s :UPING: failure binding udp socket",
- me.name, parv[0]);
- else
- sendto_one(sptr, "%s NOTICE %s%s :UPING: failure binding udp socket",
- NumServ(&me), NumNick(sptr));
- close(fd);
- return 0;
- }
if (fd > highest_fd)
highest_fd = fd;
return (a == b ? 1 : 0);
}
+extern unsigned short server_port;
+
/*
* m_server
*
if (IsUserPort(cptr))
return exit_client_msg(cptr, cptr, &me,
"You cannot connect a server to a user port; connect to %s port %u",
- me.name, portnum);
+ me.name, server_port);
recv_time = TStime();
info[0] = '\0';
- inpath = get_client_name(cptr, TRUE);
+ inpath = cptr->name;
if (parc < 7)
{
sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "SERVER");
if (prot < atoi(MINOR_PROTOCOL))
{
sendto_ops("Got incompatible protocol version (%s) from %s",
- parv[5], get_client_name(cptr, TRUE));
+ parv[5], get_client_name(cptr, FALSE));
return exit_new_server(cptr, sptr, host, timestamp,
"Incompatible protocol: %s", parv[5]);
}
if (*ch || !strchr(host, '.'))
{
sendto_ops("Bogus server name (%s) from %s",
- host, get_client_name(cptr, TRUE));
+ host, get_client_name(cptr, FALSE));
return exit_client_msg(cptr, cptr, &me, "Bogus server name (%s)", host);
}
if (crule_eval(cconf->passwd))
{
ircstp->is_ref++;
- sendto_ops("Refused connection from %s.", get_client_host(cptr));
+ sendto_ops("Refused connection from %s.", cptr->name);
return exit_client(cptr, cptr, &me, "Disallowed by connection rule");
}
if (check_server(cptr))
{
ircstp->is_ref++;
- sendto_ops("Received unauthorized connection from %s.",
- get_client_host(cptr));
+ sendto_ops("Received unauthorized connection from %s.", cptr->name);
return exit_client(cptr, cptr, &me, "No C/N conf lines");
}
*s = '@';
ircstp->is_ref++;
sendto_ops("Username mismatch [%s]v[%s] : %s",
- aconf->host, cptr->username, get_client_name(cptr, TRUE));
+ aconf->host, cptr->username, get_client_name(cptr, FALSE));
return exit_client(cptr, cptr, &me, "Bad Username");
}
*s = '@';
return exit_new_server(cptr, sptr, host, timestamp,
(active_lh_line == 2) ?
"Non-Hub link %s <- %s(%s)" : "Leaf-only link %s <- %s(%s)",
- get_client_name(cptr, TRUE), host,
+ cptr->name, host,
lhconf ? (lhconf->host ? lhconf->host : "*") : "!");
else
{
if (exit_client_msg(cptr, LHcptr, &me,
(active_lh_line == 2) ?
"Non-Hub link %s <- %s(%s)" : "Leaf-only link %s <- %s(%s)",
- get_client_name(cptr, TRUE), host,
+ cptr->name, host,
lhconf ? (lhconf->host ? lhconf->host : "*") : "!") == CPTR_KILLED)
return CPTR_KILLED;
}
if (!(cconf = bcptr->serv->nline))
{
sendto_ops("Lost N-line for %s on %s. Closing",
- get_client_name(cptr, TRUE), host);
+ cptr->name, host);
return exit_client(cptr, cptr, &me, "Lost N line");
}
if (match(my_name_for_link(me.name, cconf), acptr->name) == 0)
split = (strCasediff(cptr->name, cptr->sockhost)
&& strnCasecmp(cptr->info, "JUPE", 4));
- inpath = get_client_name(cptr, TRUE);
+ inpath = cptr->name;
host = cptr->name;
if (IsUnknown(cptr))
{
if (Protocol(acptr) > 9)
sendto_one(acptr,
- "%s SERVER %s 2 0 " TIME_T_FMT " %s%u %s%s 0 :[%s] %s",
+ "%s SERVER %s 2 0 " TIME_T_FMT " %s%u %s%s 0 :%s",
NumServ(&me), cptr->name, cptr->serv->timestamp,
(Protocol(cptr) > 9) ? "J" : "J0", Protocol(cptr), NumServCap(cptr),
- cptr->sockhost, cptr->info);
+ cptr->info);
else
sendto_one(acptr,
- ":%s SERVER %s 2 0 " TIME_T_FMT " %s%u %s%s 0 :[%s] %s", me.name,
+ ":%s SERVER %s 2 0 " TIME_T_FMT " %s%u %s%s 0 :%s", me.name,
cptr->name, cptr->serv->timestamp,
(Protocol(cptr) > 9) ? "J" : "J0", Protocol(cptr), NumServCap(cptr),
- cptr->sockhost, cptr->info);
+ cptr->info);
}
else
{
{
if (Protocol(cptr) > 9)
sendto_one(cptr,
- "%s SERVER %s %d 0 " TIME_T_FMT " %s%u %s%s 0 :[%s] %s",
+ "%s SERVER %s %d 0 " TIME_T_FMT " %s%u %s%s 0 :%s",
NumServ(acptr->serv->up), acptr->name,
acptr->hopcount + 1, acptr->serv->timestamp,
protocol_str, Protocol(acptr),
- NumServCap(acptr), acptr->sockhost, acptr->info);
+ NumServCap(acptr), acptr->info);
else
sendto_one(cptr,
- ":%s SERVER %s %d 0 " TIME_T_FMT " %s%u %s%s 0 :[%s] %s",
+ ":%s SERVER %s %d 0 " TIME_T_FMT " %s%u %s%s 0 :%s",
acptr->serv->up->name, acptr->name,
acptr->hopcount + 1, acptr->serv->timestamp,
protocol_str, Protocol(acptr),
- NumServCap(acptr), acptr->sockhost, acptr->info);
+ NumServCap(acptr), acptr->info);
}
else
{
return exit_client_msg(cptr, cptr, &me, "Register first");
if (cptr == sptr)
- sendto_ops("ERROR :from %s -- %s", get_client_name(cptr, FALSE), para);
+ sendto_ops("ERROR :from %s -- %s", cptr->name, para);
else
sendto_ops("ERROR :from %s via %s -- %s",
- sptr->name, get_client_name(cptr, FALSE), para);
+ sptr->name, cptr->name, para);
if (sptr->serv)
{
break;
case ACR_NO_AUTHORIZATION:
sendto_op_mask(SNO_UNAUTH, "Unauthorized connection from %s.",
- get_client_host(sptr));
+ sptr->sockhost);
ircstp->is_ref++;
return exit_client(cptr, sptr, &me,
"No Authorization - use another server");
{
last_too_many1 = now;
sendto_op_mask(SNO_TOOMANY, "Too many connections in class for %s.",
- get_client_host(sptr));
+ sptr->sockhost);
}
IPcheck_connect_fail(sptr);
ircstp->is_ref++;
last_too_many2 = now;
sendto_op_mask(SNO_TOOMANY,
"Too many connections from same IP for %s.",
- get_client_host(sptr));
+ sptr->sockhost);
}
ircstp->is_ref++;
return exit_client(cptr, sptr, &me,
return exit_client(cptr, sptr, &me, "Unknown error -- Try again");
}
if (IsUnixSocket(sptr))
- strncpy(user->host, me.sockhost, HOSTLEN);
+ strncpy(user->host, me.name, HOSTLEN);
else
strncpy(user->host, sptr->sockhost, HOSTLEN);
aconf = sptr->confs->value.aconf;
sendto_one(sptr, rpl_str(RPL_WELCOME), me.name, nick, nick);
/* This is a duplicate of the NOTICE but see below... */
sendto_one(sptr, rpl_str(RPL_YOURHOST), me.name, nick,
- get_client_name(&me, FALSE), version);
+ me.name, version);
sendto_one(sptr, rpl_str(RPL_CREATED), me.name, nick, creation);
sendto_one(sptr, rpl_str(RPL_MYINFO), me.name, parv[0], me.name, version);
m_lusers(sptr, sptr, 1, parv);
{
sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "NICK");
sendto_ops("bad NICK param count for %s from %s",
- parv[1], get_client_name(cptr, FALSE));
+ parv[1], cptr->name);
return 0;
}
if (MyConnect(sptr) && (s = strchr(parv[1], '~')))
{
ircstp->is_kill++;
sendto_ops("Bad Nick: %s From: %s %s",
- parv[1], parv[0], get_client_name(cptr, FALSE));
+ parv[1], parv[0], cptr->name);
if (Protocol(cptr) < 10)
sendto_one(cptr, ":%s KILL %s :%s (%s <- %s[%s])",
me.name, parv[1], me.name, parv[1], nick, cptr->name);
if (!IsServer(sptr)) /* bad nick _change_ */
{
sendto_lowprot_butone(cptr, 9, ":%s KILL %s :%s (%s <- %s!%s@%s)",
- me.name, parv[0], me.name, get_client_name(cptr, FALSE), parv[0],
+ me.name, parv[0], me.name, cptr->name, parv[0],
sptr->user ? sptr->username : "",
sptr->user ? sptr->user->server->name : cptr->name);
sendto_highprot_butone(cptr, 10, "%s KILL %s :%s (%s <- %s!%s@%s)",
- NumServ(&me), parv[0], me.name, get_client_name(cptr, FALSE),
+ NumServ(&me), parv[0], me.name, cptr->name,
parv[0], sptr->user ? sptr->username : "",
sptr->user ? sptr->user->server->name : cptr->name);
sptr->flags |= FLAGS_KILLED;
* Ultimate way to jupiter a nick ? >;-). -avalon
*/
sendto_ops("Nick collision on %s(%s <- %s)",
- sptr->name, acptr->from->name, get_client_name(cptr, FALSE));
+ sptr->name, acptr->from->name, cptr->name);
ircstp->is_kill++;
if (Protocol(cptr) < 10)
sendto_one(cptr, ":%s KILL %s :%s (%s <- %s)",
me.name, sptr->name, me.name, acptr->from->name,
- get_client_name(cptr, FALSE));
+ cptr->name);
else
sendto_one(cptr, "%s KILL %s%s :%s (%s <- %s)",
NumServ(&me), NumNick(sptr), me.name, acptr->from->name,
* NOTE: Cannot use get_client_name twice here, it returns static
* string pointer--the other info would be lost.
*/
- get_client_name(cptr, FALSE));
+ cptr->name);
sptr->flags |= FLAGS_KILLED;
return exit_client(cptr, sptr, &me, "Nick/Server collision");
}
strCasediff(acptr->user->host, parv[5]));
sendto_ops("Nick collision on %s (%s " TIME_T_FMT " <- %s " TIME_T_FMT
" (%s user@host))", acptr->name, acptr->from->name, acptr->lastnick,
- get_client_name(cptr, FALSE), lastnick, differ ? "Different" : "Same");
+ cptr->name, lastnick, differ ? "Different" : "Same");
}
else
{
strCasediff(acptr->user->host, sptr->user->host));
sendto_ops("Nick change collision from %s to %s (%s " TIME_T_FMT " <- %s "
TIME_T_FMT ")", sptr->name, acptr->name, acptr->from->name,
- acptr->lastnick, get_client_name(cptr, FALSE), lastnick);
+ acptr->lastnick, cptr->name, lastnick);
}
/*
* Now remove (kill) the nick on our side if it is the youngest.
sendto_lowprot_butone(cptr, 9, /* Kill old from outgoing servers */
":%s KILL %s :%s (%s <- %s (Nick collision))",
me.name, sptr->name, me.name, acptr->from->name,
- get_client_name(cptr, FALSE));
+ cptr->name);
sendto_highprot_butone(cptr, 10, /* Kill old from outgoing servers */
"%s KILL %s%s :%s (%s <- %s (Nick collision))",
NumServ(&me), NumNick(sptr), me.name, acptr->from->name,
- get_client_name(cptr, FALSE));
+ cptr->name);
if (MyConnect(sptr) && IsServer(cptr) && Protocol(cptr) > 9)
sendto_one(cptr, "%s KILL %s%s :%s (Ghost2)",
NumServ(&me), NumNick(sptr), me.name);
sendto_lowprot_butone(cptr, 9, /* Kill our old from outgoing servers */
":%s KILL %s :%s (%s <- %s (older nick overruled))",
me.name, acptr->name, me.name, acptr->from->name,
- get_client_name(cptr, FALSE));
+ cptr->name);
sendto_highprot_butone(cptr, 10, /* Kill our old from outgoing servers */
"%s KILL %s%s :%s (%s <- %s (older nick overruled))",
NumServ(&me), NumNick(acptr), me.name, acptr->from->name,
- get_client_name(cptr, FALSE));
+ cptr->name);
if (MyConnect(acptr) && IsServer(cptr) && Protocol(cptr) > 9)
sendto_one(cptr, "%s%s QUIT :Local kill by %s (Ghost)",
NumNick(acptr), me.name);
sendto_lowprot_butone(cptr, 9, /* Kill our old from outgoing servers */
":%s KILL %s :%s (%s <- %s (nick collision from same user@host))",
me.name, acptr->name, me.name, acptr->from->name,
- get_client_name(cptr, FALSE));
+ cptr->name);
sendto_highprot_butone(cptr, 10, /* Kill our old from outgoing servers */
"%s KILL %s%s :%s (%s <- %s (nick collision from same user@host))",
NumServ(&me), NumNick(acptr), me.name, acptr->from->name,
- get_client_name(cptr, FALSE));
+ cptr->name);
if (MyConnect(acptr) && IsServer(cptr) && Protocol(cptr) > 9)
sendto_one(cptr,
"%s%s QUIT :Local kill by %s (Ghost: switched servers too fast)",
int m_kill(aClient *cptr, aClient *sptr, int parc, char *parv[])
{
aClient *acptr;
- char *inpath = get_client_name(cptr, FALSE);
+ char *inpath = cptr->name;
char *user, *path, *killer;
int chasing = 0;
* ...!operhost!oper
* ...!operhost!oper (comment)
*/
- if (IsUnixSocket(cptr)) /* Don't use get_client_name syntax */
- inpath = me.sockhost;
- else
- inpath = cptr->sockhost;
+ inpath = cptr->user->host;
if (!BadPtr(path))
{
sprintf_irc(buf,
!strcmp(encr, aconf->passwd) && attach_conf(sptr, aconf) == ACR_OK)
{
int old = (sptr->flags & ALL_UMODES);
- char *s;
- s = strchr(aconf->host, '@');
- *s++ = '\0';
#ifdef OPER_REMOTE
if (aconf->status == CONF_LOCOP)
{
#else
- if ((match(s, me.sockhost) && !IsLocal(sptr)) ||
- aconf->status == CONF_LOCOP)
+ if (!IsLocal(sptr) || aconf->status == CONF_LOCOP)
{
#endif
ClearOper(sptr);
SetOper(sptr);
++nrof.opers;
}
- *--s = '@';
sendto_ops("%s (%s@%s) is now operator (%c)", parv[0],
sptr->user->username, sptr->sockhost, IsOper(sptr) ? 'O' : 'o');
sptr->flags |= (FLAGS_WALLOP | FLAGS_SERVNOTICE | FLAGS_DEBUG);
{
if (IsServer(cptr))
sendto_ops_butone(NULL, &me, ":%s WALLOPS :MODE for User %s From %s!%s",
- me.name, parv[1], get_client_name(cptr, FALSE), sptr->name);
+ me.name, parv[1], cptr->name, sptr->name);
else
sendto_one(sptr, err_str(ERR_USERSDONTMATCH), me.name, parv[0]);
return 0;
LastDeadComment(to)[sizeof(LastDeadComment(to)) - 1] = 0;
if (!IsUser(to) && !IsUnknown(to) && !(to->flags & FLAGS_CLOSING))
- sendto_ops("%s for %s", LastDeadComment(to), get_client_name(to, FALSE));
+ sendto_ops("%s for %s", LastDeadComment(to), to->name);
Debug((DEBUG_ERROR, LastDeadComment(to)));
}
{
if (IsServer(to))
sendto_ops("Max SendQ limit exceeded for %s: "
- SIZE_T_FMT " > " SIZE_T_FMT,
- get_client_name(to, FALSE), DBufLength(&to->sendQ), get_sendq(to));
+ SIZE_T_FMT " > " SIZE_T_FMT, to->name,
+ DBufLength(&to->sendQ), get_sendq(to));
dead_link(to, "Max sendQ exceeded");
return;
}
"Minute Hour Day Yest. YYest. Userload for:";
/* *INDENT-ON* */
static const char *what[3] = {
- "local domain clients",
+ "local clients",
"total clients",
"total connections"
};