+2004-05-10 Michael Poole <mdpoole@troilus.org>
+
+ Implement a per-connection-class default usermode option.
+
+ * doc/example.conf: Illustrate how to use the option.
+
+ * include/class.h (struct ConnectionClass): New "default_umode"
+ field.
+ (ConfUmode): New macro.
+
+ * include/client.h (client_get_default_umode): New function.
+
+ * ircd/client.c (client_get_default_umode): Implement it.
+
+ * ircd/ircd_lexer.l (usermode): New token.
+
+ * ircd/ircd_parser.y (classblock, etc): New syntax.
+
+ * ircd/s_user.c (register_user): Set default user modes for user.
+ This sends the new mode to the user, so the explicit send later
+ is no longer necessary.
+
2004-05-10 Michael Poole <mdpoole@troilus.org>
Forward port of asuka-topicburst.patch from Quakenet's "Asuka"
# connectfreq = time;
# maxlinks = number;
# sendq = size;
+# usermode = "+i";
# };
#
# <connect freq> applies only to servers, and specifies the frequency
pingfreq = 1 minutes 30 seconds;
sendq = 160000;
maxlinks = 100;
+ usermode = "+iw";
};
Client
{
struct ConnectionClass {
struct ConnectionClass* next;
char *cc_name;
+ char *default_umode;
unsigned int max_sendq;
short ping_freq;
short conn_freq;
#define ConfMaxLinks(x) ((x)->conn_class->max_links)
#define ConfSendq(x) ((x)->conn_class->max_sendq)
#define ConfLinks(x) ((x)->conn_class->ref_count)
+#define ConfUmode(x) ((x)->conn_class->default_umode)
/*
* Proto types
} ShowIPType;
extern const char* get_client_name(const struct Client* sptr, int showip);
+extern const char* client_get_default_umode(const struct Client* sptr);
extern int client_get_ping(const struct Client* local_client);
extern void client_drop_sendq(struct Connection* con);
extern void client_add_sendq(struct Connection* con,
return ping;
}
+/*
+ * client_get_default_umode
+ * returns default usermode in attached client connection class
+ */
+const char* client_get_default_umode(const struct Client* sptr)
+{
+ struct ConfItem* aconf;
+ struct SLink* link;
+
+ assert(cli_verify(sptr));
+
+ for (link = cli_confs(sptr); link; link = link->next) {
+ aconf = link->value.aconf;
+ if ((aconf->status & CONF_CLIENT) && ConfUmode(aconf))
+ return ConfUmode(aconf);
+ }
+ return NULL;
+}
+
/*
* client_drop_sendq
* removes the client's connection from the list of connections with
wide_glines return TPRIV_WIDE_GLINE;
pseudo return PSEUDO;
prepend return PREPEND;
+usermode return USERMODE;
\n lineno++;
. return yytext[0];
%token QUARANTINE
%token PSEUDO
%token PREPEND
+%token USERMODE
/* and now a lot of priviledges... */
%token TPRIV_CHAN_LIMIT TPRIV_MODE_LCHAN TPRIV_DEOP_LCHAN TPRIV_WALK_LCHAN
%token TPRIV_KILL TPRIV_LOCAL_KILL TPRIV_REHASH TPRIV_RESTART TPRIV_DIE
tconn = 0;
maxlinks = 0;
sendq = 0;
+ pass = NULL;
} '{' classitems '}'
{
if (name != NULL)
{
add_class(name, tping, tconn, maxlinks, sendq);
+ find_class(name)->default_umode = pass;
}
else {
parse_error("Missing name in class block");
}
+ pass = NULL;
} ';';
classitems: classitem classitems | classitem;
classitem: classname | classpingfreq | classconnfreq | classmaxlinks |
- classsendq | error;
+ classsendq | classusermode | error;
classname: NAME '=' QSTRING ';'
{
MyFree(name);
{
sendq = yylval.num;
};
+classusermode: USERMODE '=' QSTRING ';'
+{
+ if (pass)
+ MyFree(pass);
+ DupString(pass, yylval.text);
+};
connectblock: CONNECT
{
const char *nick, char *username)
{
struct ConfItem* aconf;
- char* parv[3];
+ char* parv[4];
char* tmpstr;
char* tmpstr2;
char c = 0; /* not alphanum */
short badid = 0;
short digitgroups = 0;
struct User* user = cli_user(sptr);
- struct Flags flag;
char ip_base64[8];
user->last = CurrentTime;
cli_sock_ip(sptr), get_client_class(sptr));
IPcheck_connect_succeeded(sptr);
+ /*
+ * Set user's initial modes
+ */
+ parv[0] = (char*)nick;
+ parv[1] = (char*)nick;
+ parv[2] = (char*)client_get_default_umode(sptr);
+ parv[3] = NULL; /* needed in case of +s */
+ set_user_mode(sptr, sptr, 3, parv);
+ ClearHiddenHost(sptr); /* just in case somebody stuck +x in there */
}
else
/* if (IsServer(cptr)) */
inttobase64(ip_base64, ntohl(cli_ip(sptr).s_addr), 6),
NumNick(sptr), cli_info(sptr));
- /* Send umode to client */
- if (MyUser(sptr))
- {
- memset(&flag, 0, sizeof(flag));
- send_umode(cptr, sptr, &flag, ALL_UMODES);
- if (cli_snomask(sptr) != SNO_DEFAULT && HasFlag(sptr, FLAG_SERVNOTICE))
- send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
- }
+ /* Send server notice mask to client */
+ if (MyUser(sptr) && (cli_snomask(sptr) != SNO_DEFAULT) && HasFlag(sptr, FLAG_SERVNOTICE))
+ send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
return 0;
}