Thread: [srvx-commits] CVS: services/src common.h,1.81,1.82 conf.c,1.30,1.31 hash.h,1.92,1.93 opserv.c,1.274
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2002-09-14 03:49:02
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv4965/src
Modified Files:
common.h conf.c hash.h opserv.c proto-common.c proto-p10.c
proto.h tools.c
Log Message:
support +x usermode for ircu2.10.11, moving generate_hostmask() into protocol section
Index: common.h
===================================================================
RCS file: /cvsroot/srvx/services/src/common.h,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -r1.81 -r1.82
*** common.h 18 Aug 2002 05:50:23 -0000 1.81
--- common.h 14 Sep 2002 03:48:58 -0000 1.82
***************
*** 94,107 ****
char *sanitize_ircmask(char *text);
- /* The "default" for generate_hostmask is to have all of these options off. */
- #define GENMASK_STRICT_HOST 1
- #define GENMASK_STRICT_IDENT 32
- #define GENMASK_ANY_IDENT 64
- #define GENMASK_STRICT (GENMASK_STRICT_IDENT|GENMASK_STRICT_HOST)
- #define GENMASK_USENICK 2
- #define GENMASK_OMITNICK 4 /* Hurray for Kevin! */
- #define GENMASK_BYIP 8
- #define GENMASK_SRVXMASK 16
- char *generate_hostmask(struct userNode *user, int options);
unsigned long ParseInterval(const unsigned char *interval);
unsigned long ParseVolume(const unsigned char *volume);
--- 94,97 ----
Index: conf.c
===================================================================
RCS file: /cvsroot/srvx/services/src/conf.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** conf.c 23 Aug 2002 04:49:38 -0000 1.30
--- conf.c 14 Sep 2002 03:48:58 -0000 1.31
***************
*** 30,38 ****
{
if (num_rfs >= size_rfs) {
! size_rfs <<= 1;
! reload_funcs = realloc(reload_funcs, size_rfs*sizeof(conf_reload_func));
}
reload_funcs[num_rfs++] = crf;
! crf();
}
--- 30,43 ----
{
if (num_rfs >= size_rfs) {
! if (reload_funcs) {
! size_rfs <<= 1;
! reload_funcs = realloc(reload_funcs, size_rfs*sizeof(conf_reload_func));
! } else {
! size_rfs = 8;
! reload_funcs = calloc(size_rfs, sizeof(conf_reload_func));
! }
}
reload_funcs[num_rfs++] = crf;
! if (conf_db) crf();
}
***************
*** 48,61 ****
{
dict_t old_conf = conf_db;
! if (!(conf_db = parse_database(conf_file_name))) {
! goto fail;
! }
! if (!reload_funcs) {
! size_rfs = 5;
! reload_funcs = malloc(size_rfs*sizeof(conf_reload_func));
! num_rfs = 0;
! } else {
! conf_call_reload_funcs();
! }
if (old_conf && old_conf != conf_db) free_database(old_conf);
return 1;
--- 53,58 ----
{
dict_t old_conf = conf_db;
! if (!(conf_db = parse_database(conf_file_name))) goto fail;
! if (reload_funcs) conf_call_reload_funcs();
if (old_conf && old_conf != conf_db) free_database(old_conf);
return 1;
Index: hash.h
===================================================================
RCS file: /cvsroot/srvx/services/src/hash.h,v
retrieving revision 1.92
retrieving revision 1.93
diff -C2 -r1.92 -r1.93
*** hash.h 9 Sep 2002 19:13:51 -0000 1.92
--- hash.h 14 Sep 2002 03:48:58 -0000 1.93
***************
*** 54,57 ****
--- 54,58 ----
#define FLAGS_AWAY 0x0800 /* for away users */
#define FLAGS_STAMPED 0x1000 /* for users who have been stamped */
+ #define FLAGS_HIDDEN_HOST 0x2000 /* user's host is masked by their account */
#define IsOper(x) ((x)->modes & FLAGS_OPER)
***************
*** 65,68 ****
--- 66,70 ----
#define IsGagged(x) ((x)->modes & FLAGS_GAGGED)
#define IsAway(x) ((x)->modes & FLAGS_AWAY)
+ #define IsHiddenHost(x) ((x)->modes & FLAGS_HIDDEN_HOST)
#define IsLocal(x) ((x)->uplink == self)
Index: opserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/opserv.c,v
retrieving revision 1.274
retrieving revision 1.275
diff -C2 -r1.274 -r1.275
*** opserv.c 13 Sep 2002 19:50:28 -0000 1.274
--- opserv.c 14 Sep 2002 03:48:58 -0000 1.275
***************
*** 1202,1205 ****
--- 1202,1206 ----
if (IsService(target)) buffer[bpos++] = 'k';
if (IsDeaf(target)) buffer[bpos++] = 'd';
+ if (IsHiddenHost(target)) buffer[bpos++] = 'x';
if (IsGagged(target)) buffer_cat(" (gagged)");
buffer[bpos] = 0;
Index: proto-common.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-common.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** proto-common.c 5 Sep 2002 14:55:48 -0000 1.13
--- proto-common.c 14 Sep 2002 03:48:59 -0000 1.14
***************
*** 23,26 ****
--- 23,27 ----
#include "ioset.h"
#include "log.h"
+ #include "nickserv.h"
#include "policer.h"
#include "timeq.h"
***************
*** 37,40 ****
--- 38,42 ----
static int replay_connected;
static unsigned int nicklen = NICKLEN; /* how long do we think servers allow nicks to be? */
+ static const char *hidden_host_suffix;
extern struct cManagerNode cManager;
***************
*** 502,504 ****
--- 504,602 ----
mcf_list[n](channel, user, change_type, change);
}
+ }
+
+ char *
+ generate_hostmask(struct userNode *user, int options)
+ {
+ char *nickname, *ident, *hostname;
+ char *mask;
+ int len, ii;
+
+ /* figure out string parts */
+ if (options & GENMASK_OMITNICK) {
+ nickname = NULL;
+ } else if (options & GENMASK_USENICK) {
+ nickname = user->nick;
+ } else {
+ nickname = "*";
+ }
+ if (options & GENMASK_STRICT_IDENT) {
+ ident = user->ident;
+ } else if (options & GENMASK_ANY_IDENT) {
+ ident = "*";
+ } else {
+ ident = alloca(strlen(user->ident)+2);
+ ident[0] = '*';
+ strcpy(ident+1, user->ident + ((*user->ident == '~')?1:0));
+ }
+ hostname = user->hostname;
+ if (IsHiddenHost(user) && user->handle_info && hidden_host_suffix) {
+ hostname = alloca(strlen(user->handle_info->handle) + strlen(hidden_host_suffix) + 2);
+ sprintf(hostname, "%s.%s", user->handle_info->handle, hidden_host_suffix);
+ } else if (options & GENMASK_STRICT_HOST) {
+ if (options & GENMASK_BYIP) {
+ hostname = alloca(32);
+ sprintf(hostname, "%lu.%lu.%lu.%lu", (user->ip>>24)&0xFF, (user->ip>>16)&0xFF, (user->ip>>8)&0xFF, user->ip&0xFF);
+ } else {
+ /* leave hostname as is */
+ }
+ } else if ((options & GENMASK_BYIP) || !hostname[strspn(hostname, "0123456789.")]) {
+ /* Should generate an IP-based hostmask. By popular acclaim, a /16
+ * hostmask is used by default. */
+ unsigned masked_ip, mask, masklen;
+ masklen = 16;
+ mask = ~0 << masklen;
+ masked_ip = user->ip & mask;
+ hostname = alloca(32);
+ if (options & GENMASK_SRVXMASK) {
+ sprintf(hostname, "%d.%d.%d.%d/%d", (masked_ip>>24)&0xFF, (masked_ip>>16)&0xFF, (masked_ip>>8)&0xFF, masked_ip&0xFF, masklen);
+ } else {
+ int ofs = 0;
+ for (ii=0; ii<4; ii++) {
+ if (masklen) {
+ ofs += sprintf(hostname+ofs, "%d.", (masked_ip>>24)&0xFF);
+ masklen -= 8;
+ masked_ip <<= 8;
+ } else {
+ ofs += sprintf(hostname+ofs, "*.");
+ }
+ }
+ /* Truncate the last . */
+ hostname[ofs-1] = 0;
+ }
+ } else {
+ int cnt;
+ /* This heuristic could be made smarter. Is it worth the effort? */
+ for (ii=cnt=0; hostname[ii]; ii++) {
+ if (hostname[ii] == '.') cnt++;
+ }
+ if (cnt == 1) {
+ /* only a two-level domain name; leave hostname */
+ } else if (cnt == 2) {
+ for (ii=0; user->hostname[ii] != '.'; ii++) ;
+ /* Add 3 to account for the *. and \0. */
+ hostname = alloca(strlen(user->hostname+ii)+3);
+ sprintf(hostname, "*.%s", user->hostname+ii+1);
+ } else {
+ for (cnt=3, ii--; cnt; ii--) {
+ if (user->hostname[ii] == '.') cnt--;
+ }
+ /* The loop above will overshoot the dot one character;
+ we skip forward two (the one character and the dot)
+ when printing, so we only add one for the \0. */
+ hostname = alloca(strlen(user->hostname+ii)+1);
+ sprintf(hostname, "*.%s", user->hostname+ii+2);
+ }
+ }
+ /* Emit hostmask */
+ len = strlen(ident) + strlen(hostname) + 2;
+ if (nickname) {
+ len += strlen(nickname) + 1;
+ mask = malloc(len);
+ sprintf(mask, "%s!%s@%s", nickname, ident, hostname);
+ } else {
+ mask = malloc(len);
+ sprintf(mask, "%s@%s", ident, hostname);
+ }
+ return mask;
}
Index: proto-p10.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-p10.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -r1.32 -r1.33
*** proto-p10.c 12 Sep 2002 01:26:48 -0000 1.32
--- proto-p10.c 14 Sep 2002 03:48:59 -0000 1.33
***************
*** 378,383 ****
inttobase64(b64ip, user->ip, 6);
if (user->modes) {
! int modelen = 0;
! char modes[9];
if (IsOper(user)) modes[modelen++] = 'o';
if (IsInvisible(user)) modes[modelen++] = 'i';
--- 378,385 ----
inttobase64(b64ip, user->ip, 6);
if (user->modes) {
! int modelen;
! char modes[32];
!
! modelen = 0;
if (IsOper(user)) modes[modelen++] = 'o';
if (IsInvisible(user)) modes[modelen++] = 'i';
***************
*** 388,391 ****
--- 390,394 ----
if (IsGlobal(user)) modes[modelen++] = 'g';
if (IsHelperIrcu(user)) modes[modelen++] = 'h';
+ if (IsHiddenHost(user)) modes[modelen++] = 'x';
modes[modelen] = 0;
***************
*** 1345,1348 ****
--- 1348,1352 ----
}
self = AddServer(NULL, str, 0, boot_time, now, numer, desc);
+ hidden_host_suffix = conf_get_data("server/hidden_host", RECDB_QSTRING);
irc_func_dict = dict_new();
***************
*** 1854,1857 ****
--- 1858,1862 ----
case 'g': do_user_mode(FLAGS_GLOBAL); break;
case 'h': do_user_mode(FLAGS_HELPER); break;
+ case 'x': do_user_mode(FLAGS_HIDDEN_HOST); break;
}
#undef do_user_mode
***************
*** 1876,1880 ****
do_chan_mode(MODE_KEY, 'k');
do_chan_mode(MODE_LIMIT, 'l');
- do_chan_mode(MODE_DELAYJOINS, 'D');
do_chan_mode(MODE_REGONLY, 'r');
do_chan_mode(MODE_NOCOLORS, 'c');
--- 1881,1884 ----
Index: proto.h
===================================================================
RCS file: /cvsroot/srvx/services/src/proto.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -r1.65 -r1.66
*** proto.h 8 Sep 2002 04:32:12 -0000 1.65
--- proto.h 14 Sep 2002 03:48:59 -0000 1.66
***************
*** 183,185 ****
--- 183,196 ----
/* (most protocols will want to make an AddUser helper function) */
+ /* The "default" for generate_hostmask is to have all of these options off. */
+ #define GENMASK_STRICT_HOST 1
+ #define GENMASK_STRICT_IDENT 32
+ #define GENMASK_ANY_IDENT 64
+ #define GENMASK_STRICT (GENMASK_STRICT_IDENT|GENMASK_STRICT_HOST)
+ #define GENMASK_USENICK 2
+ #define GENMASK_OMITNICK 4 /* Hurray for Kevin! */
+ #define GENMASK_BYIP 8
+ #define GENMASK_SRVXMASK 16
+ char *generate_hostmask(struct userNode *user, int options);
+
#endif /* !defined(PROTO_H) */
Index: tools.c
===================================================================
RCS file: /cvsroot/srvx/services/src/tools.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -C2 -r1.116 -r1.117
*** tools.c 5 Sep 2002 14:57:22 -0000 1.116
--- tools.c 14 Sep 2002 03:48:59 -0000 1.117
***************
*** 450,546 ****
}
- char *
- generate_hostmask(struct userNode *user, int options)
- {
- char *nickname, *ident, *hostname;
- char *mask;
- int len, ii;
-
- /* figure out string parts */
- if (options & GENMASK_OMITNICK) {
- nickname = NULL;
- } else if (options & GENMASK_USENICK) {
- nickname = user->nick;
- } else {
- nickname = "*";
- }
- if (options & GENMASK_STRICT_IDENT) {
- ident = user->ident;
- } else if (options & GENMASK_ANY_IDENT) {
- ident = "*";
- } else {
- ident = alloca(strlen(user->ident)+2);
- ident[0] = '*';
- strcpy(ident+1, user->ident + ((*user->ident == '~')?1:0));
- }
- hostname = user->hostname;
- if (options & GENMASK_STRICT_HOST) {
- if (options & GENMASK_BYIP) {
- hostname = alloca(32);
- sprintf(hostname, "%lu.%lu.%lu.%lu", (user->ip>>24)&0xFF, (user->ip>>16)&0xFF, (user->ip>>8)&0xFF, user->ip&0xFF);
- } else {
- /* leave hostname as is */
- }
- } else if ((options & GENMASK_BYIP) || !hostname[strspn(hostname, "0123456789.")]) {
- /* Should generate an IP-based hostmask. By popular acclaim, a /16
- * hostmask is used by default. */
- unsigned masked_ip, mask, masklen;
- masklen = 16;
- mask = ~0 << masklen;
- masked_ip = user->ip & mask;
- hostname = alloca(32);
- if (options & GENMASK_SRVXMASK) {
- sprintf(hostname, "%d.%d.%d.%d/%d", (masked_ip>>24)&0xFF, (masked_ip>>16)&0xFF, (masked_ip>>8)&0xFF, masked_ip&0xFF, masklen);
- } else {
- int ofs = 0;
- for (ii=0; ii<4; ii++) {
- if (masklen) {
- ofs += sprintf(hostname+ofs, "%d.", (masked_ip>>24)&0xFF);
- masklen -= 8;
- masked_ip <<= 8;
- } else {
- ofs += sprintf(hostname+ofs, "*.");
- }
- }
- /* Truncate the last . */
- hostname[ofs-1] = 0;
- }
- } else {
- int cnt;
- /* This heuristic could be made smarter. Is it worth the effort? */
- for (ii=cnt=0; hostname[ii]; ii++) {
- if (hostname[ii] == '.') cnt++;
- }
- if (cnt == 1) {
- /* only a two-level domain name; leave hostname */
- } else if (cnt == 2) {
- for (ii=0; user->hostname[ii] != '.'; ii++) ;
- /* Add 3 to account for the *. and \0. */
- hostname = alloca(strlen(user->hostname+ii)+3);
- sprintf(hostname, "*.%s", user->hostname+ii+1);
- } else {
- for (cnt=3, ii--; cnt; ii--) {
- if (user->hostname[ii] == '.') cnt--;
- }
- /* The loop above will overshoot the dot one character;
- we skip forward two (the one character and the dot)
- when printing, so we only add one for the \0. */
- hostname = alloca(strlen(user->hostname+ii)+1);
- sprintf(hostname, "*.%s", user->hostname+ii+2);
- }
- }
- /* Emit hostmask */
- len = strlen(ident) + strlen(hostname) + 2;
- if (nickname) {
- len += strlen(nickname) + 1;
- mask = malloc(len);
- sprintf(mask, "%s!%s@%s", nickname, ident, hostname);
- } else {
- mask = malloc(len);
- sprintf(mask, "%s@%s", ident, hostname);
- }
- return mask;
- }
-
static long
TypeLength(char type)
--- 450,453 ----
|