From: Bleep Date: Sun, 17 Sep 2000 08:32:40 +0000 (+0000) Subject: Author: Bleep X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=096611138b24de2734dc6950de7f0bd9d74f7fa8;p=ircu2.10.12-pk.git Author: Bleep Log message: Move me config stuff to local conf, fixup affected code, test changes. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@293 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 5cdea53..c008d01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-09-17 Thomas Helvey + * 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 * include/class.h: add missing prototype * ircd/class.c: make argument to get_conf_class const diff --git a/include/s_bsd.h b/include/s_bsd.h index 59dcc5f..dcada22 100644 --- a/include/s_bsd.h +++ b/include/s_bsd.h @@ -12,6 +12,10 @@ #include /* size_t, time_t */ #define INCLUDED_sys_types_h #endif +#ifndef INCLUDED_netinet_in_h +#include +#define INCLUDED_netinet_in_h +#endif struct Client; struct ConfItem; @@ -82,8 +86,9 @@ extern int net_close_unregistered_connections(struct Client* source); 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 */ diff --git a/include/s_conf.h b/include/s_conf.h index 9e676f9..73d0b9c 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -21,7 +21,6 @@ struct Client; struct SLink; struct TRecord; -struct hostent; /* @@ -38,7 +37,6 @@ 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 @@ -87,13 +85,13 @@ struct ServerConf { * A line: A::: */ 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 { @@ -153,33 +151,31 @@ extern struct TRecord* tdata; * 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 */ diff --git a/ircd/IPcheck.c b/ircd/IPcheck.c index 6c58f46..57865fc 100644 --- a/ircd/IPcheck.c +++ b/ircd/IPcheck.c @@ -27,7 +27,6 @@ #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" diff --git a/ircd/chkconf.c b/ircd/chkconf.c index 3538367..2b5fd4d 100644 --- a/ircd/chkconf.c +++ b/ircd/chkconf.c @@ -42,6 +42,7 @@ /* * 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 diff --git a/ircd/ircd.c b/ircd/ircd.c index fc45159..414eadf 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -658,10 +658,7 @@ int main(int argc, char **argv) { return 7; } - if (!init_server_identity()) { - ircd_log(L_CRIT, "Failed to initialize server identity"); - return 8; - } + init_server_identity(); uping_init(); diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index cda4eb7..613af93 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -1432,20 +1432,11 @@ int connect_server(struct ConfItem* aconf, struct Client* by, /* * 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; } /* @@ -1453,17 +1444,13 @@ void init_virtual_host(const struct ConfItem* conf) * 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); } diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 8385689..da60842 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -472,16 +472,6 @@ const struct LocalConf* conf_get_local(void) 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 * @@ -717,15 +707,48 @@ void conf_add_listener(const char* const* fields, int count) 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]); @@ -1040,8 +1063,9 @@ int read_configuration_file(void) /* 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; @@ -1090,20 +1114,9 @@ int read_configuration_file(void) 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 @@ -1158,17 +1171,6 @@ int read_configuration_file(void) 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 @@ -1365,6 +1367,9 @@ int init_conf(void) * 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)