+2004-09-13 Michael Poole <mdpoole@troilus.org>
+
+ * doc/example.conf: Remove sample VIRTUAL_HOST setting.
+
+ * doc/readme.features: Remove VIRTUAL_HOST documentation, and
+ update NODNS documentation to match current behavior.
+
+ * include/s_conf.h: Remove now-unused vhost_address field and
+ set_virtual_host() function.
+
+ * include/ircd_features.h, ircd/ircd_features.c, ircd/s_debug.c:
+ Remove VIRTUAL_HOST.
+
+ * ircd/ircd_auth.c, ircd/s_bsd.c: Use VirtualHost as local address
+ if we do not have a more specific alternate.
+
+ * ircd/ircd_parser.y: Check for sanity in General blocks (from old
+ conf_add_local()) and assign vhost directly to VirtualHost.
+
+ * ircd/ircd_res.c (irc_in_addr_valid): Fix thinko; obviously any
+ value will be either != 0 or != 0xffff.
+
+ * ircd/os_generic.c: Use AF_INET instead of AF_INET6 when the
+ local addresses are specified as IPv4 addresses.
+
+ * ircd/s_conf.c: Remove unused conf_add_local() and
+ set_virtual_host().
+
2004-09-13 Michael Poole <mdpoole@troilus.org>
* ircd/listener.c (add_listener): Consolidate duplicated code, and
# "MPATH" = "ircd.motd";
# "RPATH" = "remote.motd";
# "PPATH" = "ircd.pid";
-# "VIRTUAL_HOST" = "FALSE";
# "TOS_SERVER" = "0x08";
# "TOS_CLIENT" = "0x08";
# "POLLS_PER_LOOP" = "200";
then long delays occur before the server starts up because it tries to
resolve the name given in the General block (which usually isn't given
in /etc/hosts) and for each connecting client. If you specify "TRUE"
-here, then a call to gethostbyname() will be done only for the real
-hostname, and the server will not try to resolve clients that connect
-to "localhost." Note that other calls to gethostbyname() are still
-done if you use VIRTUAL_HOST; also note that the server still tries to
-resolve clients that connect to the real IP address of the server.
+here, then a DNS lookup will be done only for the real hostname, and
+the server will not try to resolve clients that connect to
+"localhost." Note that other DNS lookups are still done for outbound
+connections.
RANDOM_SEED
* Type: string
"PID" file. It is used for storing the server's process ID so that a
ps(1) isn't necessary.
-VIRTUAL_HOST
- * Type: boolean
- * Default: FALSE
-
-This option is only needed when you wish to run multiple IRC servers
-on the same machine, and they must share at least one port. This will
-require having multiple IP addresses for the machine that will be
-hosting the servers. If you specify "TRUE" here, you can cause the
-server to bind to one of these IP addresses. Use the vhost field of
-the General block to specify the IP address. If you are unsure, stick
-with "FALSE."
-
TOS_SERVER
* Type: integer
* Default: 0x08
FEAT_PPATH,
/* Networking features */
- FEAT_VIRTUAL_HOST,
FEAT_TOS_SERVER,
FEAT_TOS_CLIENT,
FEAT_POLLS_PER_LOOP,
extern void init_server_identity(void);
extern void close_connections(int close_stderr);
extern int init_connection_limits(void);
-extern void set_virtual_host(const struct irc_in_addr *addr);
extern void update_write(struct Client* cptr);
#endif /* INCLUDED_s_bsd_h */
struct LocalConf {
char* name;
char* description;
- struct irc_in_addr vhost_address;
unsigned int numeric;
char* location1;
char* location2;
gethost_byname(i_host(iauth), &i_query(iauth));
return;
}
- fd = os_socket((feature_bool(FEAT_VIRTUAL_HOST) ? &VirtualHost : NULL), SOCK_STREAM, "IAuth");
+ fd = os_socket(&VirtualHost, SOCK_STREAM, "IAuth");
if (fd < 0)
return;
if (!os_set_sockbufs(fd, SERVER_TCP_WINDOW, SERVER_TCP_WINDOW)) {
F_S(PPATH, FEAT_CASE | FEAT_MYOPER | FEAT_READ, "ircd.pid", 0),
/* Networking features */
- F_B(VIRTUAL_HOST, 0, 0, 0),
F_I(TOS_SERVER, 0, 0x08, 0),
F_I(TOS_CLIENT, 0, 0x08, 0),
F_I(POLLS_PER_LOOP, 0, 200, 0),
addNickJupes($3);
} ';';
-generalblock: GENERAL '{' generalitems '}' ';' ;
+generalblock: GENERAL '{' generalitems '}'
+{
+ if (localConf.name == NULL)
+ parse_error("Your General block must contain a name.");
+ if (localConf.numeric == 0)
+ parse_error("Your General block must contain a numeric (between 1 and 4095).");
+} ';' ;
generalitems: generalitem generalitems | generalitem;
generalitem: generalnumeric | generalname | generalvhost | generaldesc | error;
generalnumeric: NUMERIC '=' NUMBER ';'
generalvhost: VHOST '=' QSTRING ';'
{
- ircd_aton(&localConf.vhost_address, $3);
+ ircd_aton(&VirtualHost.addr, $3);
};
adminblock: ADMIN '{' adminitems '}'
unsigned short val;
val = addr->in6_16[0];
- if (val != 0 || val != 0xffff)
+ if (val != 0 && val != 0xffff)
return 1;
for (ii = 1; ii < 8; ii++)
if (addr->in6_16[ii] != val)
#ifdef IPV6
#define sockaddr_native sockaddr_in6
+#define sn_family sin6_family
void sockaddr_to_irc(const struct sockaddr_in6 *v6, struct irc_sockaddr *irc)
{
- assert(v6->sin6_family == AF_INET6);
- memcpy(&irc->addr.in6_16[0], &v6->sin6_addr, sizeof(v6->sin6_addr));
- irc->port = ntohs(v6->sin6_port);
+ if (v6->sin6_family == AF_INET6) {
+ memcpy(&irc->addr.in6_16[0], &v6->sin6_addr, sizeof(v6->sin6_addr));
+ irc->port = ntohs(v6->sin6_port);
+ }
+ else if (v6->sin6_family == AF_INET) {
+ const struct sockaddr_in *v4 = (const struct sockaddr_in*)v6;
+ memset(&irc->addr, 0, 5*sizeof(int16_t));
+ irc->addr.in6_16[5] = 0xffff;
+ memcpy(&irc->addr.in6_16[6], &v4->sin_addr, sizeof(v4->sin_addr));
+ irc->port = ntohs(v4->sin_port);
+ }
+ else assert(0 && "Unhandled native address family");
}
-void sockaddr_from_irc(struct sockaddr_in6 *v6, const struct irc_sockaddr *irc, int persist)
+int sockaddr_from_irc(struct sockaddr_in6 *v6, const struct irc_sockaddr *irc, int persist)
{
memset(v6, 0, sizeof(*v6));
- v6->sin6_family = AF_INET6;
- memcpy(&v6->sin6_addr, &irc->addr.in6_16[0], sizeof(v6->sin6_addr));
- if (persist && irc_in_addr_is_ipv4(&irc->addr))
- v6->sin6_addr.s6_addr[10] = v6->sin6_addr.s6_addr[11] = '\xff';
- v6->sin6_port = htons(irc->port);
+ if (!irc) {
+ memset(v6, 0, sizeof(v6));
+ v6->sin6_family = AF_INET6;
+ return sizeof(*v6);
+ }
+ else if (persist && irc_in_addr_is_ipv4(&irc->addr)) {
+ struct sockaddr_in *v4 = (struct sockaddr_in*)v6;
+ v4->sin_family = AF_INET;
+ memcpy(&v4->sin_addr, &irc->addr.in6_16[6], sizeof(v4->sin_addr));
+ v4->sin_port = htons(irc->port);
+ return sizeof(*v4);
+ }
+ else {
+ v6->sin6_family = AF_INET6;
+ memcpy(&v6->sin6_addr, &irc->addr.in6_16[0], sizeof(v6->sin6_addr));
+ v6->sin6_port = htons(irc->port);
+ return sizeof(*v6);
+ }
}
#else
#define sockaddr_native sockaddr_in
+#define sn_family sin_family
void sockaddr_to_irc(const struct sockaddr_in *v4, struct irc_sockaddr *irc)
{
irc->port = ntohs(v4->sin_port);
}
-void sockaddr_from_irc(struct sockaddr_in *v4, const struct irc_sockaddr *irc, int persist)
+int sockaddr_from_irc(struct sockaddr_in *v4, const struct irc_sockaddr *irc, int persist)
{
v4->sin_family = AF_INET;
- assert(!irc->addr.in6_16[0] && !irc->addr.in6_16[1] && !irc->addr.in6_16[2] && !irc->addr.in6_16[3] && !irc->addr.in6_16[4] && (!irc->addr.in6_16[5] || irc->addr.in6_16[5] == 0xffff));
- memcpy(&v4->sin_addr, &irc->addr.in6_16[6], sizeof(v4->sin_addr));
- v4->sin_port = htons(irc->port);
+ if (irc) {
+ assert(!irc->addr.in6_16[0] && !irc->addr.in6_16[1] && !irc->addr.in6_16[2] && !irc->addr.in6_16[3] && !irc->addr.in6_16[4] && (!irc->addr.in6_16[5] || irc->addr.in6_16[5] == 0xffff));
+ memcpy(&v4->sin_addr, &irc->addr.in6_16[6], sizeof(v4->sin_addr));
+ v4->sin_port = htons(irc->port);
+ } else{
+ memset(&v4, 0, sizeof(v4));
+ }
(void)persist;
+ return sizeof(*v4);
}
#endif
const struct irc_sockaddr* peer)
{
struct sockaddr_native addr;
- int res;
+ int res, size;
assert(0 != buf);
if (count_out)
*count_out = 0;
errno = 0;
- sockaddr_from_irc(&addr, peer, 1);
- if (-1 < (res = sendto(fd, buf, length, flags, (struct sockaddr*)&addr, sizeof(addr)))) {
+ size = sockaddr_from_irc(&addr, peer, 1);
+ if (-1 < (res = sendto(fd, buf, length, flags, (struct sockaddr*)&addr, size))) {
if (count_out)
*count_out = (unsigned) res;
return IO_SUCCESS;
int os_socket(const struct irc_sockaddr* local, int type, const char* port_name)
{
- int family, fd;
-#ifdef IPV6
- family = AF_INET6;
-#else
- family = AF_INET;
-#endif
- fd = socket(family, type, 0);
+ struct sockaddr_native addr;
+ int size, fd;
+
+ size = sockaddr_from_irc(&addr, local, 1);
+ fd = socket(addr.sn_family, type, 0);
if (fd < 0) {
report_error(SOCKET_ERROR_MSG, port_name, errno);
return -1;
return -1;
}
if (local) {
- struct sockaddr_native addr;
- sockaddr_from_irc(&addr, local, 1);
- if (bind(fd, (struct sockaddr*)&addr, sizeof(addr))) {
+ if (bind(fd, (struct sockaddr*)&addr, size)) {
report_error(BIND_ERROR_MSG, port_name, errno);
close(fd);
return -1;
IOResult os_connect_nonb(int fd, const struct irc_sockaddr* sin)
{
struct sockaddr_native addr;
- sockaddr_from_irc(&addr, sin, 1);
- if (connect(fd, (struct sockaddr*) &addr, sizeof(addr)))
+ int size;
+
+ size = sockaddr_from_irc(&addr, sin, 1);
+ if (connect(fd, (struct sockaddr*) &addr, size))
return (errno == EINPROGRESS) ? IO_BLOCKED : IO_FAILURE;
return IO_SUCCESS;
}
*/
if (irc_in_addr_valid(&aconf->origin.addr))
local = &aconf->origin;
- else if (feature_bool(FEAT_VIRTUAL_HOST))
- local = &VirtualHost;
else
- local = NULL;
+ local = &VirtualHost;
cli_fd(cptr) = os_socket(local, SOCK_STREAM, cli_name(cptr));
if (cli_fd(cptr) < 0)
return 0;
completed_connection(cptr) : 1;
}
-/*
- * Setup local socket structure to use for binding to.
- */
-void set_virtual_host(const struct irc_in_addr *addr)
-{
- memset(&VirtualHost, 0, sizeof(VirtualHost));
- memcpy(&VirtualHost.addr, addr, sizeof(VirtualHost.addr));
-}
-
/*
* Find the real hostname for the host running the server (or one which
* matches the server's name) and its primary IP#. Hostname is stored
add_listener(atoi(fields[4]), fields[2], fields[1], is_server, is_hidden);
}
-void conf_add_local(const char* const* fields, int count)
-{
- if (count < 6 || EmptyString(fields[1]) || EmptyString(fields[5])) {
- log_write(LS_CONFIG, L_CRIT, 0, "Your M: line must have 6 fields!");
- return;
- }
- /*
- * these two can only be set the first time
- */
- if (0 == localConf.name) {
- if (string_is_hostname(fields[1]))
- DupString(localConf.name, fields[1]);
- }
- if (0 == localConf.numeric) {
- localConf.numeric = atoi(fields[5]);
- if (0 == localConf.numeric)
- log_write(LS_CONFIG, L_WARNING, 0,
- "Your M: line must have a Numeric value greater than 0");
- }
- /*
- * these two can be changed while the server is running
- */
- if (string_is_address(fields[2])) {
- if (INADDR_NONE == (localConf.vhost_address.s_addr = inet_addr(fields[2])))
- localConf.vhost_address.s_addr = INADDR_ANY;
- }
- MyFree(localConf.description);
- DupString(localConf.description, fields[3]);
- /*
- * XXX - shouldn't be setting these directly here
- */
- ircd_strncpy(cli_info(&me), fields[3], REALLEN);
- set_virtual_host(localConf.vhost_address);
-}
-
void conf_add_admin(const char* const* fields, int count)
{
/*
AddC('U');
#endif
- if (feature_bool(FEAT_VIRTUAL_HOST))
- AddC('v');
-
serveropts[i] = '\0';
return serveropts;