mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-06 15:53:12 +02:00
Added short motds
This commit is contained in:
@@ -2209,3 +2209,11 @@ seen. gmtime warning still there
|
||||
- Fixed another serious bug in the win32 resolver.
|
||||
- Removed mutex stuff from rem_request, no longer needed, should make the resolver much
|
||||
faster.
|
||||
- Implemented short motds (ircd.smotd). If you don't know what short motds are, read on:
|
||||
short motds are a method of conserving bandwidth. When a user connects ircd.smotd
|
||||
is displayed (or a tld::shortmotd). This file contains brief text. Alternatively,
|
||||
ircd.motd (or tld::motd) is displayed when a user types /motd. The idea behind this is
|
||||
instead of displaying huge ASCII art, and tons of text to every user when they connect
|
||||
(since most users will ignore it anyway) you only show that stuff to users who specifically
|
||||
request it. Also, if you choose not to use short motds, everything will function as it used
|
||||
to the ircd.motd (or tld::motd) will be displayed both when users connect and /motd.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<font size="4"><a href="http://www.unrealircd.com">http://www.unrealircd.com</a></font><br>
|
||||
<font size="4">Version: 3.2</font><br>
|
||||
<b>Current Version:</b> 3.2 Beta16<br>
|
||||
<b>Last doc update:</b> 2003-05-29 </div>
|
||||
<b>Last doc update:</b> 2003-06-03 </div>
|
||||
<b>Head Coders:</b> Stskeeps / codemastr / Luke / McSkaf / Syzop<br>
|
||||
<b>Contributors:</b> Zogg / NiQuiL / assyrian / chasm / DrBin / llthangel / Griever / nighthawk<br>
|
||||
<b>Documentation:</b> CKnight^ / Syzop<br>
|
||||
@@ -970,6 +970,7 @@ tld {
|
||||
mask <hostmask>;
|
||||
motd <motd-file>;
|
||||
rules <rules-file>;
|
||||
shortmotd <shortmotd-file>;
|
||||
channel <channel-name>;
|
||||
options {
|
||||
ssl;
|
||||
@@ -978,8 +979,9 @@ tld {
|
||||
<p>The tld block allows you to specify a motd, rules, and channel for a user based
|
||||
on their host. This is useful if you want different motds for different languages.
|
||||
The <b>tld::mask</b> is a user@host mask that the user's username and hostname must
|
||||
match. The <b>tld::motd</b> and <b>tld::rules</b> specify the motd and rules file, respectively,
|
||||
to be displayed to this hostmask. <b>tld::channel</b> is optional, it allows
|
||||
match. The <b>tld::motd</b>, <b>tld::shortmotd</b>, and <b>tld::rules</b> specify the
|
||||
motd, shortmotd, and rules file, respectively, to be displayed to this hostmask.
|
||||
The tld::shortmotd is optional. <b>tld::channel</b> is optional, it allows
|
||||
you to specify a channel that this user will be forced to join on connect. If
|
||||
this exists it will override the default auto join channel.
|
||||
The <b>tld::options</b> block allows you to define additional requirements,
|
||||
|
||||
@@ -272,6 +272,7 @@
|
||||
*/
|
||||
#define CPATH "unrealircd.conf" /* server configuration file */
|
||||
#define MPATH "ircd.motd" /* server MOTD file */
|
||||
#define SMPATH "ircd.smotd" /* short MOTD file */
|
||||
#define RPATH "ircd.rules" /* server rules file */
|
||||
#define OPATH "oper.motd" /* Operators MOTD file */
|
||||
#define LPATH "debug.log" /* Where the debug file lives, if DEBUGMODE */
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ int match_ipv4(struct IN_ADDR *addr, struct IN_ADDR *mask, int b);
|
||||
#ifdef INET6
|
||||
int match_ipv6(struct IN_ADDR *addr, struct IN_ADDR *mask, int b);
|
||||
#endif
|
||||
extern struct tm motd_tm;
|
||||
extern struct tm motd_tm, smotd_tm;
|
||||
extern Link *Servers;
|
||||
void add_ListItem(ListStruct *, ListStruct **);
|
||||
ListStruct *del_ListItem(ListStruct *, ListStruct **);
|
||||
|
||||
+3
-3
@@ -1000,9 +1000,9 @@ struct _configitem_ulines {
|
||||
struct _configitem_tld {
|
||||
ConfigItem *prev, *next;
|
||||
ConfigFlag_tld flag;
|
||||
char *mask, *motd_file, *rules_file, *channel;
|
||||
struct tm motd_tm;
|
||||
aMotd *rules, *motd;
|
||||
char *mask, *motd_file, *rules_file, *smotd_file, *channel;
|
||||
struct tm motd_tm, smotd_tm;
|
||||
aMotd *rules, *motd, *smotd;
|
||||
u_short options;
|
||||
};
|
||||
|
||||
|
||||
+5
-3
@@ -91,6 +91,7 @@ extern aMotd *svsmotd;
|
||||
extern aMotd *motd;
|
||||
extern aMotd *rules;
|
||||
extern aMotd *botmotd;
|
||||
extern aMotd *smotd;
|
||||
MemoryInfo StatsZ;
|
||||
|
||||
int R_do_dns, R_fin_dns, R_fin_dnsc, R_fail_dns, R_do_id, R_fin_id, R_fail_id;
|
||||
@@ -1133,11 +1134,12 @@ int InitwIRCD(int argc, char *argv[])
|
||||
me.umodes = conf_listen->options;
|
||||
conf_listen->listener = &me;
|
||||
run_configuration();
|
||||
botmotd = (aMotd *) read_file(BPATH, &botmotd);
|
||||
botmotd = (aMotd *) read_file(BPATH, NULL);
|
||||
rules = (aMotd *) read_file(RPATH, NULL);
|
||||
opermotd = (aMotd *) read_file(OPATH, &opermotd);
|
||||
opermotd = (aMotd *) read_file(OPATH, NULL);
|
||||
motd = (aMotd *) read_file_ex(MPATH, NULL, &motd_tm);
|
||||
svsmotd = (aMotd *) read_file(VPATH, &svsmotd);
|
||||
smotd = (aMotd *) read_file_ex(SMPATH, NULL, &smotd_tm);
|
||||
svsmotd = (aMotd *) read_file(VPATH, NULL);
|
||||
strncpy(me.sockhost, conf_listen->ip, sizeof(me.sockhost) - 1);
|
||||
if (me.name[0] == '\0')
|
||||
strncpyzt(me.name, me.sockhost, sizeof(me.name));
|
||||
|
||||
@@ -1449,6 +1449,7 @@ void config_rehash()
|
||||
next = (ListStruct *)tld_ptr->next;
|
||||
ircfree(tld_ptr->motd_file);
|
||||
ircfree(tld_ptr->rules_file);
|
||||
ircfree(tld_ptr->smotd_file);
|
||||
if (!tld_ptr->flag.motdptr) {
|
||||
while (tld_ptr->motd) {
|
||||
motd = tld_ptr->motd->next;
|
||||
@@ -1465,6 +1466,12 @@ void config_rehash()
|
||||
tld_ptr->rules = motd;
|
||||
}
|
||||
}
|
||||
while (tld_ptr->smotd) {
|
||||
motd = tld_ptr->smotd->next;
|
||||
ircfree(tld_ptr->smotd->line);
|
||||
ircfree(tld_ptr->smotd);
|
||||
tld_ptr->smotd = motd;
|
||||
}
|
||||
DelListItem(tld_ptr, conf_tld);
|
||||
MyFree(tld_ptr);
|
||||
}
|
||||
@@ -3139,6 +3146,12 @@ int _conf_tld(ConfigFile *conf, ConfigEntry *ce)
|
||||
cep = config_find_entry(ce->ce_entries, "motd");
|
||||
ca->motd_file = strdup(cep->ce_vardata);
|
||||
ca->motd = read_file_ex(cep->ce_vardata, NULL, &ca->motd_tm);
|
||||
if ((cep = config_find_entry(ce->ce_entries, "shortmotd")))
|
||||
{
|
||||
ca->smotd_file = strdup(cep->ce_vardata);
|
||||
ca->smotd = read_file_ex(cep->ce_vardata, NULL, &ca->smotd_tm);
|
||||
}
|
||||
|
||||
cep = config_find_entry(ce->ce_entries, "rules");
|
||||
ca->rules_file = strdup(cep->ce_vardata);
|
||||
ca->rules = read_file(cep->ce_vardata, NULL);
|
||||
@@ -3188,6 +3201,8 @@ int _test_tld(ConfigFile *conf, ConfigEntry *ce)
|
||||
}
|
||||
else if (!strcmp(cep->ce_varname, "channel")) {
|
||||
}
|
||||
else if (!strcmp(cep->ce_varname, "shortmotd")) {
|
||||
}
|
||||
else if (!strcmp(cep->ce_varname, "options")) {
|
||||
ConfigEntry *cep2;
|
||||
for (cep2 = cep->ce_entries; cep2; cep2 = cep2->ce_next)
|
||||
|
||||
+77
-1
@@ -57,7 +57,9 @@ aMotd *rules;
|
||||
aMotd *motd;
|
||||
aMotd *svsmotd;
|
||||
aMotd *botmotd;
|
||||
aMotd *smotd;
|
||||
struct tm motd_tm;
|
||||
struct tm smotd_tm;
|
||||
aMotd *read_file(char *filename, aMotd **list);
|
||||
aMotd *read_file_ex(char *filename, aMotd **list, struct tm *);
|
||||
extern aMotd *Find_file(char *, short);
|
||||
@@ -3533,10 +3535,13 @@ ConfigItem_tld *tlds;
|
||||
|
||||
motd = (aMotd *) read_file_ex(MPATH, &motd, &motd_tm);
|
||||
rules = (aMotd *) read_file(RPATH, &rules);
|
||||
smotd = (aMotd *) read_file_ex(SMPATH, &smotd, &smotd_tm);
|
||||
for (tlds = conf_tld; tlds; tlds = (ConfigItem_tld *) tlds->next)
|
||||
{
|
||||
tlds->motd = read_file_ex(tlds->motd_file, &tlds->motd, &tlds->motd_tm);
|
||||
tlds->rules = read_file(tlds->rules_file, &tlds->rules);
|
||||
if (tlds->smotd_file)
|
||||
tlds->smotd = read_file_ex(tlds->smotd_file, &tlds->smotd, &tlds->smotd_tm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3675,7 +3680,7 @@ CMD_FUNC(m_rehash)
|
||||
/* Normal rehash, rehash main motd&rules too, just like the on in the tld block will :p */
|
||||
motd = (aMotd *) read_file_ex(MPATH, &motd, &motd_tm);
|
||||
rules = (aMotd *) read_file(RPATH, &rules);
|
||||
|
||||
smotd = (aMotd *) read_file_ex(SMPATH, &smotd, &smotd_tm);
|
||||
if (cptr == sptr)
|
||||
sendto_one(sptr, rpl_str(RPL_REHASHING), me.name, parv[0], configfile);
|
||||
return rehash(cptr, sptr, (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0);
|
||||
@@ -3964,6 +3969,77 @@ CMD_FUNC(m_trace)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Heavily modified from the ircu m_motd by codemastr
|
||||
* Also svsmotd support added
|
||||
*/
|
||||
int short_motd(aClient *sptr) {
|
||||
ConfigItem_tld *ptr;
|
||||
aMotd *temp, *temp2;
|
||||
struct tm *tm = &smotd_tm;
|
||||
char userhost[HOSTLEN + USERLEN + 6];
|
||||
char is_short = 1;
|
||||
strlcpy(userhost,make_user_host(sptr->user->username, sptr->user->realhost), sizeof userhost);
|
||||
ptr = Find_tld(sptr, userhost);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
if (ptr->smotd)
|
||||
{
|
||||
temp = ptr->smotd;
|
||||
tm = &ptr->smotd_tm;
|
||||
}
|
||||
else if (smotd)
|
||||
temp = smotd;
|
||||
else
|
||||
{
|
||||
temp = ptr->motd;
|
||||
tm = &ptr->motd_tm;
|
||||
is_short = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (smotd)
|
||||
temp = smotd;
|
||||
else
|
||||
{
|
||||
temp = motd;
|
||||
tm = &motd_tm;
|
||||
is_short = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!temp)
|
||||
{
|
||||
sendto_one(sptr, err_str(ERR_NOMOTD), me.name, sptr->name);
|
||||
return 0;
|
||||
}
|
||||
if (tm)
|
||||
{
|
||||
sendto_one(sptr, rpl_str(RPL_MOTDSTART), me.name, sptr->name,
|
||||
me.name);
|
||||
sendto_one(sptr, ":%s %d %s :- %d/%d/%d %d:%02d", me.name,
|
||||
RPL_MOTD, sptr->name, tm->tm_mday, tm->tm_mon + 1,
|
||||
1900 + tm->tm_year, tm->tm_hour, tm->tm_min);
|
||||
}
|
||||
if (is_short)
|
||||
{
|
||||
sendto_one(sptr, rpl_str(RPL_MOTD), me.name, sptr->name,
|
||||
"This is the short MOTD. To view the complete MOTD type /motd");
|
||||
sendto_one(sptr, rpl_str(RPL_MOTD), me.name, sptr->name, "");
|
||||
}
|
||||
|
||||
while (temp)
|
||||
{
|
||||
sendto_one(sptr, rpl_str(RPL_MOTD), me.name, sptr->name,
|
||||
temp->line);
|
||||
temp = temp->next;
|
||||
}
|
||||
sendto_one(sptr, rpl_str(RPL_ENDOFMOTD), me.name, sptr->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Heavily modified from the ircu m_motd by codemastr
|
||||
|
||||
+3
-1
@@ -57,6 +57,7 @@ void send_umode_out_nickv2(aClient *, aClient *, long);
|
||||
void send_umode(aClient *, aClient *, long, long, char *);
|
||||
void set_snomask(aClient *, char *);
|
||||
int create_snomask(char *, int);
|
||||
extern int short_motd(aClient *sptr);
|
||||
char *get_snostr(long sno);
|
||||
/* static Link *is_banned(aClient *, aChannel *); */
|
||||
int dontspread = 0;
|
||||
@@ -1018,7 +1019,8 @@ extern int register_user(aClient *cptr, aClient *sptr, char *nick, char *usernam
|
||||
ssl_get_cipher(sptr->ssl));
|
||||
#endif
|
||||
(void)m_lusers(sptr, sptr, 1, parv);
|
||||
(void)m_motd(sptr, sptr, 1, parv);
|
||||
short_motd(sptr);
|
||||
// (void)m_motd(sptr, sptr, 1, parv);
|
||||
#ifdef EXPERIMENTAL
|
||||
sendto_one(sptr,
|
||||
":%s NOTICE %s :*** \2NOTE:\2 This server (%s) is running experimental IRC server software. If you find any bugs or problems, please mail unreal-dev@lists.sourceforge.net about it",
|
||||
|
||||
Reference in New Issue
Block a user