+2000-09-17 Thomas Helvey <helveytw@home.com>
+ * ircd/s_conf.c: add me to local conf
+ * include/s_conf.h: move CONF_ME macro to chkconf.c
+ * ircd/s_bsd.c: cleanup initialization, allow virtual host
+ to be changed by rehash
+
2000-09-17 Thomas Helvey <helveytw@home.com>
* include/class.h: add missing prototype
* ircd/class.c: make argument to get_conf_class const
#include <sys/types.h> /* size_t, time_t */
#define INCLUDED_sys_types_h
#endif
+#ifndef INCLUDED_netinet_in_h
+#include <netinet/in.h>
+#define INCLUDED_netinet_in_h
+#endif
struct Client;
struct ConfItem;
extern void close_connection(struct Client *cptr);
extern void add_connection(struct Listener* listener, int fd);
extern int read_message(time_t delay);
-extern int init_server_identity(void);
+extern void init_server_identity(void);
extern void close_connections(int close_stderr);
extern int init_connection_limits(void);
+extern void set_virtual_host(struct in_addr addr);
#endif /* INCLUDED_s_bsd_h */
struct Client;
struct SLink;
struct TRecord;
-struct hostent;
/*
#define CONF_SERVER 0x0004
#define CONF_LOCOP 0x0010
#define CONF_OPERATOR 0x0020
-#define CONF_ME 0x0040
#define CONF_KILL 0x0080
#define CONF_LEAF 0x1000
#define CONF_HUB 0x4000
* A line: A:<line 1>:<line 2>:<line 3>
*/
struct LocalConf {
- char* server_alias;
- char* vhost_address;
- char* description;
- char* numeric_id;
- char* location1;
- char* location2;
- char* contact;
+ char* name;
+ char* description;
+ struct in_addr vhost_address;
+ unsigned int numeric;
+ char* location1;
+ char* location2;
+ char* contact;
};
struct MotdItem {
* Proto types
*/
+extern int init_conf(void);
+
extern const struct LocalConf* conf_get_local(void);
extern const struct MotdConf* conf_get_motd_list(void);
extern const struct CRuleConf* conf_get_crule_list(void);
-extern const char* conf_crule_eval(const char* host, int mask);
+extern const char* conf_eval_crule(const char* name, int mask);
extern struct ConfItem* attach_confs_byhost(struct Client* cptr, const char* host, int statmask);
extern struct ConfItem* find_conf_byhost(struct SLink* lp, const char* host, int statmask);
extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, int statmask);
extern struct ConfItem* conf_find_server(const char* name);
-const char* conf_eval_crule(const char* name, int mask);
extern void det_confs_butmask(struct Client *cptr, int mask);
extern int detach_conf(struct Client *cptr, struct ConfItem *aconf);
extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf);
-extern struct ConfItem* find_me(void);
extern struct ConfItem* find_conf_exact(const char* name, const char* user,
const char* host, int statmask);
extern enum AuthorizationCheckResult conf_check_client(struct Client *cptr);
extern int conf_check_server(struct Client *cptr);
extern struct ConfItem* find_conf_name(const char* name, int statmask);
extern int rehash(struct Client *cptr, int sig);
-extern int init_conf(void);
extern void read_tlines(void);
extern int find_kill(struct Client *cptr);
extern int find_restrict(struct Client *cptr);
-extern int m_killcomment(struct Client *sptr, char *parv, char *filename);
extern struct MotdItem* read_motd(const char* motdfile);
#endif /* INCLUDED_s_conf_h */
#include "ircd.h"
#include "numnicks.h" /* NumNick, NumServ (GODMODE) */
#include "ircd_alloc.h"
-#include "s_bsd.h" /* SetIPChecked */
#include "s_debug.h" /* Debug */
#include "s_user.h" /* TARGET_DELAY */
#include "send.h"
/*
* stuff that isn't used by s_conf.c anymore
*/
+#define CONF_ME 0x0040
#define CONF_ADMIN 0x0100
#define CONF_CLASS 0x0400
#define CONF_LISTEN_PORT 0x2000
return 7;
}
- if (!init_server_identity()) {
- ircd_log(L_CRIT, "Failed to initialize server identity");
- return 8;
- }
+ init_server_identity();
uping_init();
/*
* 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);
}
return &localConf;
}
-struct ConfItem* find_me(void)
-{
- struct ConfItem* aconf;
- for (aconf = GlobalConfList; aconf; aconf = aconf->next) {
- if (aconf->status & CONF_ME)
- break;
- }
- return aconf;
-}
-
/*
* attach_confs_byname
*
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])) {
+ ircd_log(L_CRIT, "Your M: line must have 6 fields!\n");
+ 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)
+ ircd_log(L_WARNING, "Your M: line must have a Numeric value greater than 0\n");
+ }
+ /*
+ * 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(me.info, fields[3], REALLEN);
+ set_virtual_host(localConf.vhost_address);
+}
+
void conf_add_admin(const char* const* fields, int count)
{
/*
* if you have one, it MUST have 3 lines
*/
if (count < 4) {
- Debug((DEBUG_FATAL, "Your A: line must have 4 fields!\n"));
ircd_log(L_CRIT, "Your A: line must have 4 fields!\n");
- exit(-1);
+ return;
}
MyFree(localConf.location1);
DupString(localConf.location1, fields[1]);
/* Me. Host field is name used for this host */
/* and port number is the number of the port */
case 'M':
- case 'm':
- aconf->status = CONF_ME;
+ case 'm': /* CONF_ME */
+ conf_add_local(field_vector, field_count);
+ aconf->status = CONF_ILLEGAL;
break;
case 'O':
aconf->status = CONF_OPERATOR;
if (field_count > 4 && !EmptyString(field_vector[4]))
aconf->port = atoi(field_vector[4]);
- if (field_count > 5 && !EmptyString(field_vector[5])) {
- int n = atoi(field_vector[5]);
- if (CONF_ME == (aconf->status & CONF_ME))
- SetYXXServerName(&me, n); /* Our Numeric Nick */
- else
- aconf->confClass = find_class(n);
- }
- else if (CONF_ME == (aconf->status & CONF_ME)) {
- Debug((DEBUG_FATAL, "Your M: line must have the Numeric, "
- "assigned to you by routing-com!\n"));
- ircd_log(L_WARNING, "Your M: line must have the Numeric, "
- "assigned to you by routing-com!\n");
- exit(-1);
- }
+ if (field_count > 5 && !EmptyString(field_vector[5]))
+ aconf->confClass = find_class(atoi(field_vector[5]));
+
/*
* Associate each conf line with a class by using a pointer
* to the correct class record. -avalon
continue;
lookup_confhost(aconf);
}
- /*
- * Own port and name cannot be changed after the startup.
- * (or could be allowed, but only if all links are closed first).
- * Configuration info does not override the name and port
- * if previously defined. Note, that "info"-field can be
- * changed by "/rehash".
- */
- if (aconf->status == CONF_ME) {
- ircd_strncpy(me.info, aconf->name, REALLEN);
- }
-
if (aconf->status == CONF_IPKILL) {
/*
* Here we use the same kludge as in listener.c to parse
* XXX - should any of these abort the server?
* TODO: add warning messages
*/
+ if (0 == localConf.name || 0 == localConf.numeric)
+ return 0;
+
if (0 == localConf.location1)
DupString(localConf.location1, "");
if (0 == localConf.location2)