diff --git a/Changes b/Changes index 65bf22a9b..2560a7786 100644 --- a/Changes +++ b/Changes @@ -83,3 +83,5 @@ - Merged in sts-laptop branch - Made /admin use the new config (had to modify some newconf stuff to make a backwards copy of the list as well) +- Added listen {} runtime-configuration code work :)) +- Removed unrealircd.conf from stock \ No newline at end of file diff --git a/include/struct.h b/include/struct.h index caafd95d9..601bf6e45 100644 --- a/include/struct.h +++ b/include/struct.h @@ -806,6 +806,7 @@ struct t_vhline { #define LISTENER_JAVACLIENT 0x000010 #define LISTENER_MASK 0x000020 #define LISTENER_SSL 0x000040 +#define LISTENER_BOUND 0x000080 #define CONNECT_SSL 0x000001 #define CONNECT_ZIP 0x000002 @@ -866,7 +867,7 @@ struct Client { long receiveK; /* Statistics: total k-bytes received */ u_short sendB; /* counters to count upto 1-k lots of bytes */ u_short receiveB; /* sent and received. */ - aClient *acpt; /* listening client which we accepted from */ + aClient *listener; Link *confs; /* Configuration record associated */ int authfd; /* fd for rfc931 authentication */ #ifdef SOCKSPORT diff --git a/src/bsd.c b/src/bsd.c index 95a8030d0..09c86dd8b 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -101,7 +101,7 @@ int deliver_it(cptr, str, len) char *str; { int retval; - aClient *acpt = cptr->acpt; + aClient *acpt = cptr->listener; #ifdef DEBUGMODE writecalls++; diff --git a/src/ircd.c b/src/ircd.c index cf0a2fa2d..184101b4a 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -1093,6 +1093,10 @@ int InitwIRCD(argc, argv) Debug((DEBUG_ERROR, "Port = %d", portnum)); if (inetport(&me, conf_listen->ip, portnum)) exit(1); + conf_listen->options |= LISTENER_BOUND; + me.umodes = conf_listen->options; + ircd_log("* Bound to %s:%i\n", conf_listen->ip, conf_listen->port); + run_configuration(); botmotd = (aMotd *) read_botmotd(BPATH); rules = (aMotd *) read_rules(RPATH); opermotd = (aMotd *) read_opermotd(OPATH); diff --git a/src/packet.c b/src/packet.c index 85c95ba37..b1819a430 100644 --- a/src/packet.c +++ b/src/packet.c @@ -70,7 +70,7 @@ int dopacket(cptr, buffer, length) { char *ch1; char *ch2; - aClient *acpt = cptr->acpt; + aClient *acpt = cptr->listener; me.receiveB += length; /* Update bytes received */ cptr->receiveB += length; @@ -112,8 +112,8 @@ int dopacket(cptr, buffer, length) *ch1 = '\0'; me.receiveM += 1; /* Update messages received */ cptr->receiveM += 1; - if (cptr->acpt != &me) - cptr->acpt->receiveM += 1; + if (cptr->listener != &me) + cptr->listener->receiveM += 1; cptr->count = 0; /* ...just in case parse returns with ** FLUSH_BUFFER without removing the ** structure pointed by cptr... --msa diff --git a/src/s_bsd.c b/src/s_bsd.c index 503867889..4ea35f630 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -405,7 +405,7 @@ int add_listener(aconf) cptr = make_client(NULL, NULL); cptr->flags = FLAGS_LISTEN; - cptr->acpt = cptr; + cptr->listener = cptr; cptr->from = cptr; SetMe(cptr); strncpyzt(cptr->name, aconf->host, sizeof(cptr->name)); @@ -465,6 +465,33 @@ int add_listener(aconf) return 0; } +int add_listener2(ConfigItem_listen *conf) +{ + aClient *cptr; + + cptr = make_client(NULL, NULL); + cptr->flags = FLAGS_LISTEN; + cptr->listener = cptr; + cptr->from = cptr; + SetMe(cptr); + strncpyzt(cptr->name, conf->ip, sizeof(cptr->name)); + if (inetport(cptr, conf->ip, conf->port)) + cptr->fd = -2; + + cptr->umodes = conf->options ? conf->options : LISTENER_NORMAL; + if (cptr->fd >= 0) + { + set_non_blocking(cptr->fd, cptr); + return 1; + } + else + { + free_client(cptr); + return -1; + } + +} + /* * close_listeners * @@ -1162,18 +1189,6 @@ void close_connection(cptr) DBufClear(&cptr->sendQ); DBufClear(&cptr->recvQ); - /* - * clean up extra sockets from P-lines which have been - * discarded. - */ - if (cptr->acpt != &me && cptr->acpt != cptr) - { - aconf = cptr->acpt->confs->value.aconf; - if (aconf->clients > 0) - aconf->clients--; - if (!aconf->clients && IsIllegal(aconf)) - close_connection(cptr->acpt); - } } for (; highest_fd > 0; highest_fd--) if (local[highest_fd]) @@ -1405,11 +1420,8 @@ aClient *add_connection(cptr, fd) { Link lin; aClient *acptr; - aConfItem *aconf = NULL; acptr = make_client(NULL, &me); - if (cptr != &me) - aconf = cptr->confs->value.aconf; /* 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 connections. @@ -1440,8 +1452,6 @@ aClient *add_connection(cptr, fd) return NULL; } /* don't want to add "Failed in connecting to" here.. */ - if (aconf && IsIllegal(aconf)) - goto add_con_refuse; /* Copy ascii address to 'sockhost' just in case. Then we * have something valid to put into error messages... */ @@ -1534,13 +1544,11 @@ aClient *add_connection(cptr, fd) #endif /*USENEWDNS*/ } - if (aconf) - aconf->clients++; acptr->fd = fd; if (fd > highest_fd) highest_fd = fd; local[fd] = acptr; - acptr->acpt = cptr; + acptr->listener = cptr; #ifdef USE_SSL if (cptr->umodes & LISTENER_SSL) { @@ -2176,8 +2184,8 @@ int read_message(delay, listp) */ (void)add_connection(cptr, fd); nextping = TStime(); - if (!cptr->acpt) - cptr->acpt = &me; + if (!cptr->listener) + cptr->listener = &me; } for (i = highest_fd; i >= 0; i--) @@ -2566,8 +2574,8 @@ int read_message(delay, listp) (void)add_connection(cptr, fd); nextping = TStime(); - if (!cptr->acpt) - cptr->acpt = &me; + if (!cptr->listener) + cptr->listener = &me; continue; } @@ -2822,7 +2830,7 @@ int connect_server(aconf, by, hp) if (cptr->fd > highest_fd) highest_fd = cptr->fd; local[cptr->fd] = cptr; - cptr->acpt = &me; + cptr->listener = &me; SetConnecting(cptr); IRCstats.unknown++; get_sockhost(cptr, aconf->host); diff --git a/src/s_conf.c b/src/s_conf.c index bb975a7d1..c7fca24d5 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -194,7 +194,7 @@ int attach_Iline(cptr, hp, sockhost) { if (aconf->status != CONF_CLIENT) continue; - if (aconf->port && aconf->port != cptr->acpt->port) + if (aconf->port && aconf->port != cptr->listener->port) continue; if (!aconf->host || !aconf->name) goto attach_iline; @@ -1677,12 +1677,12 @@ int find_kill(cptr) if ((tmp->status == CONF_KILL) && tmp->host && tmp->name && (match(tmp->host, host) == 0) && (!name || match(tmp->name, name) == 0) && - (!tmp->port || (tmp->port == cptr->acpt->port))) { + (!tmp->port || (tmp->port == cptr->listener->port))) { for (tmp2 = conf; tmp2; tmp2 = tmp2->next) if ((tmp2->status == CONF_EXCEPT) && tmp2->host && tmp2->name && (match(tmp2->host, host) == 0) && (!name || match(tmp2->name, name) == 0) && - (!tmp2->port || (tmp2->port == cptr->acpt->port))) + (!tmp2->port || (tmp2->port == cptr->listener->port))) return 0; if (BadPtr(tmp->passwd)) diff --git a/src/s_conf2.c b/src/s_conf2.c index 4a20bcaf0..e27c07fee 100644 --- a/src/s_conf2.c +++ b/src/s_conf2.c @@ -1785,6 +1785,28 @@ void report_configuration(void) } +void run_configuration(void) +{ + ConfigItem_listen *listenptr; + + for (listenptr = conf_listen; listenptr; listenptr = (ConfigItem_listen *) listenptr->next) + { + if (!(listenptr->options & LISTENER_BOUND)) + { + ircd_log("Binding to %s:%i", listenptr->ip, listenptr->port); + if (add_listener2(listenptr) == -1) + { + ircd_log("Failed to bind to %s:%i", listenptr->ip, listenptr->port); + } + else + { + ircd_log("Bound to %s:%i", listenptr->ip, listenptr->port); + } + } + } +} + + /* * Lookup functions * -Stskeeps @@ -1836,3 +1858,5 @@ ConfigItem_listen *Find_listen(char *ipmask, int port) } return NULL; } + + diff --git a/src/s_serv.c b/src/s_serv.c index 869639b02..0d37b1b74 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -605,7 +605,7 @@ int m_server(cptr, sptr, parc, parv) inpath); return exit_client(cptr, cptr, cptr, "Bad Password"); } - if (MyConnect(sptr) && (sptr->acpt->umodes & LISTENER_CLIENTSONLY)) + if (MyConnect(sptr) && (sptr->listener->umodes & LISTENER_CLIENTSONLY)) { return exit_client(cptr, sptr, sptr, "This port is for clients only"); } diff --git a/src/s_user.c b/src/s_user.c index 212c4815a..bc286d4dc 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -935,7 +935,7 @@ static int register_user(cptr, sptr, nick, username, umode, virthost) sendto_one(sptr, rpl_str(RPL_YOURHOST), me.name, nick, me.name, version); sendto_one(sptr, rpl_str(RPL_CREATED), me.name, nick, creation); - if (!(sptr->acpt->umodes & LISTENER_JAVACLIENT)) + if (!(sptr->listener->umodes & LISTENER_JAVACLIENT)) #ifndef _WIN32 sendto_one(sptr, rpl_str(RPL_MYINFO), me.name, parv[0], me.name, version, umodestring, cmodestring); @@ -2971,7 +2971,7 @@ int m_user(cptr, sptr, parc, parv) if (IsServer(cptr) && !IsUnknown(sptr)) return 0; - if (MyClient(sptr) && (sptr->acpt->umodes & LISTENER_SERVERSONLY)) { + if (MyClient(sptr) && (sptr->listener->umodes & LISTENER_SERVERSONLY)) { return exit_client(cptr, sptr, sptr, "This port is for servers only"); } diff --git a/src/send.c b/src/send.c index b5b2159b3..d1da3549d 100644 --- a/src/send.c +++ b/src/send.c @@ -272,8 +272,8 @@ void sendbufto_one(aClient *to) */ to->sendM += 1; me.sendM += 1; - if (to->acpt != &me) - to->acpt->sendM += 1; + if (to->listener != &me) + to->listener->sendM += 1; /* * This little bit is to stop the sendQ from growing too large when * there is no need for it to. Thus we call send_queued() every time @@ -1628,7 +1628,7 @@ void sendto_connectnotice(nick, user, sptr) char connecth[1024]; ircsprintf(connectd, "*** Notice -- Client connecting on port %d: %s (%s@%s) %s%s%s", - sptr->acpt->port, nick, user->username, user->realhost, + sptr->listener->port, nick, user->username, user->realhost, #ifdef USE_SSL IsSecure(sptr) ? "[secure " : "", IsSecure(sptr) ? SSL_get_cipher((SSL *)sptr->ssl) : "", diff --git a/unrealircd.conf b/unrealircd.conf deleted file mode 100644 index b90ee8529..000000000 --- a/unrealircd.conf +++ /dev/null @@ -1,232 +0,0 @@ -/* - * UnrealIRCd Config File - Example for irc.fyremoon.net -*/ - -// Information about me -me { - // My IRC server name - name "irc.fyremoon.net"; - // My infoline - info "Forever is gonna start tonight"; - // My numeric - numeric 13; -}; - -// Who is my admin? - -admin { - /* You can put as many lines as you want here */ - "Carsten Munk"; - "Stskeeps"; - "stskeeps@tspre.org"; -}; - -/* We use class names now :)*/ -class clients -{ - /* How often to ping the user */ - pingfreq 90; - /* How many clients allowed in class*/ - maxclients 900; - /* Maximum SendQueue */ - sendq 100000; -}; - -class servers -{ - pingfreq 90; - maxclients 1; - sendq 1000000; -}; - -/* The old I:lines */ -allow { - /* username mask*/ - user *; - /* ip mask */ - ip *; - /* hostmask */ - hostname *; - /* what class to put them in */ - class clients; - // Leave out password to make it passwordless - /* Password to require */ - password "moocowsrule"; -}; - -/* /oper (oper )*/ -oper stskeeps { - /* What class to put oper in upon opering */ - class clients; - /* What userhost masks to allow the IRCop to come from */ - from { - userhost *@the.elite-hacker.cx; - userhost *@*.image.dk; - }; - /* Password to require */ - password "moocow"; - /* We use named flags now :) */ - flags - { - netadmin; - global; - }; -}; - -/* P:lines, we listen here on IP 127.0.0.1 port 6667 */ -listen 127.0.0.1:7157 -{ - options - { - ssl; - serversonly; - }; -}; - - - -link irc.hs-bremen.de /* servername */ -{ - username *; /* usermask */ - hostname 194.94.24.40; /* hostmask */ - bind-ip *; /* What IP to bind to when connecting */ - port 7151; /* What port to connect to, if any */ - hub *; /* Is this a hub and what servermasks may it bring in */ - - // leaf *; - // leaf-depth 2; - password-connect "tdx6667"; - password-recieve "tdx6667"; - /* for later: class-connect, class-recieve */ - class servers; - // rsa-auth "path.to.public.key"; - options { - autoconnect; - ssl; - zip; - }; -}; - -/* As many as you like */ -ulines { - services.roxnet.org; - stats.roxnet.org; -}; - -drpass { - restart "time-to-restart"; /* Password to use for /restart */ - die "killme"; /* Password to use for /die */ -}; - -/* - * The old T:lines. We however also can use this as auto-join per .domain -*/ -tld { - mask *@*.fr; - motd "ircd.motd.fr"; - rules "ircd.rules.fr"; -}; - -/* The old nick Q:lines :) */ -ban nick { - mask "*C*h*a*n*S*e*r*v*"; - reason "Reserved for Services"; -}; -/* The old Z:lines */ -ban ip { mask 195.86.232.81; reason "Delinked server"; }; - -/* The old server Q:lines */ -ban server { - mask eris.berkeley.edu; - reason "Get out of here."; -}; - -/* The wonderful K:lines */ -ban user { mask *tirc@*.saturn.bbn.com; reason "Idiot"; }; - -/* Bans Realnames, the old n:lines */ -ban realname { - mask "Swat Team"; - reason "mIRKFORCE"; -}; - -ban realname { - mask "sub7server"; - reason "sub7"; -}; - - -/* Do not ban Stskeeps - * The old E:lines -*/ -except ban { - mask *stskeeps@212.*; -}; - -/* savage-r.* - * the old e: lines - */ -except socks { - mask 216.73.27.177; -}; - -/* Old vhost.conf */ -vhost { - vhost i.hate.microsefrs.com; - userhost *@*.image.dk; - login stskeeps; - password techie; -}; - -/* You can include other configuration files */ -// include "klines.conf"; - -// Network configuration -set { - network-name "ROXnet"; - default-server "irc.roxnet.org"; - services-name "services.roxnet.org"; - stats-name "stats.roxnet.org"; - help-channel "#ROXnet"; - hiddenhost-prefix "rox"; - prefix_quit "no"; - /* on-oper host */ - hosts { - local "locop.roxnet.org"; - global "ircop.roxnet.org"; - coadmin "coadmin.roxnet.org"; - admin "admin.roxnet.org"; - servicesadmin "csops.roxnet.org"; - techadmin "techadmin.roxnet.org"; - netadmin "netadmin.roxnet.org"; - host-on-oper-up "no"; - }; -}; - -/* Server specific configuration */ - -set { - kline-address "stskeeps@roxnet.org"; - modes-on-connect "+xwG"; - oper-auto-join "#opers"; - dns { - nameserver 127.0.0.1; - timeout 2s; - retries 2s; - }; - options { - enable-opermotd; - enable-chatops; - hide-ulines; - webtv-support; - identd-check; - }; - - socks { - ban-message "Insecure SOCKS server"; - quit-message "Insecure SOCKS server"; - ban-time "4d"; - }; - maxchannelsperuser 10; - -}; \ No newline at end of file