Changeset 818
- Timestamp:
- 09/21/08 22:00:54 (4 years ago)
- Location:
- branches/ithildin-1.1/modules/ircd
- Files:
-
- 2 added
- 7 edited
-
addons/hostmask.c (modified) (1 diff)
-
commands/protocol.c (added)
-
commands/user.c (modified) (1 diff)
-
commands/webirc.c (added)
-
conf/commands.conf (modified) (2 diffs)
-
connection.c (modified) (2 diffs)
-
ircd.c (modified) (3 diffs)
-
protocol.c (modified) (2 diffs)
-
protocols/rfc1459.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/ithildin-1.1/modules/ircd/addons/hostmask.c
r778 r818 83 83 if (mask != NULL && *mask != '\0') { 84 84 if (!strcasecmp(mask, CGI_IRC_SPECIAL_MASK)) { 85 /* Special CGI:IRC hack. We take the password, if supplied, an 85 /* Special CGI:IRC hack. We take the password, if supplied, and 86 86 * use it as a hostname (as long as it's valid). Good stuff. */ 87 87 if (cli->conn->pass != NULL && *cli->conn->pass != '\0' && -
branches/ithildin-1.1/modules/ircd/commands/user.c
r693 r818 53 53 strcpy(u, "null"); 54 54 55 /* fill in other stuff */ 56 strncpy(cli->host, cp->host, HOSTLEN); 55 /* fill in other stuff if it hasn't already been set */ 56 if (*cli->host == '\0') 57 strncpy(cli->host, cp->host, HOSTLEN); 57 58 strncpy(cli->info, argv[4], GCOSLEN); 58 59 cli->server = ircd.me; -
branches/ithildin-1.1/modules/ircd/conf/commands.conf
r579 r818 128 128 //command pong; // (required by addons/core) 129 129 130 //command protocol; // allows unregistered clients to change their 131 // protocol (required by proto/rfc1459) 132 130 133 //command quit; // allows users to sign off the server (required by 131 134 // addons/core) … … 197 200 198 201 command watch; // adds 'server-side notify' support. 202 203 /* 204 // This command enables WEBIRC command support (largely for Mibbit). 205 // You must specify the correct originating IP and the password you 206 // expect sent for authentication purposes. 207 command webirc { 208 ip 67.207.141.120; 209 password "your-mibbit-password"; 210 }; 211 */ 199 212 200 213 command who; // allows users to get short-form information -
branches/ithildin-1.1/modules/ircd/connection.c
r772 r818 362 362 /* now stick them in the default protocol */ 363 363 c->proto = ircd.default_proto; 364 c->proto->setup(c); 364 365 c->last = me.now; 365 366 /* and monitor them */ … … 436 437 /* Only flag that we are writeable. The writer hook takes care of 437 438 * doing buffered writes for us outside the construct of this loop. 438 * I thi ml, potentially falsely, that it may be beneficial to batch439 * I think, potentially falsely, that it may be beneficial to batch 439 440 * writes and reads in this manner. */ 440 441 c->flags |= IRCD_CONNFL_WRITEABLE; -
branches/ithildin-1.1/modules/ircd/ircd.c
r802 r818 383 383 ircd.events.started = create_event(EVENT_FL_HOOKONCE); 384 384 385 /* setup our default protocol. if we didn't save it, then we allocate it386 * fresh, and fill in the name only. we set up the input no matter what387 * because function addresses may change. */388 if (!get_module_savedata(savelist, "ircd.default_proto",389 &ircd.default_proto)) {390 ircd.default_proto = malloc(sizeof(protocol_t));391 memset(ircd.default_proto, 0, sizeof(protocol_t));392 ircd.default_proto->name = strdup("default");393 }394 ircd.default_proto->input = protocol_default_input;395 if (LIST_EMPTY(ircd.lists.protocols))396 LIST_INSERT_HEAD(ircd.lists.protocols, ircd.default_proto, lp);397 398 385 /* grab the timer hook to see if connections have timed out */ 399 386 timer_ref = create_timer(-1, timer_fuzz, ircd_timer_hook, NULL); … … 511 498 if (!reload && !ircd_parse_conf(conf)) 512 499 return 0; 500 501 /* setup our default protocol (rfc1459). */ 502 #define DEFAULT_PROTOCOL "rfc1459" 503 if (find_protocol(DEFAULT_PROTOCOL) == NULL && 504 !add_protocol(DEFAULT_PROTOCOL)) { 505 log_error("could not load rfc1459 protocol?"); 506 return 0; 507 } 508 ircd.default_proto = find_protocol(DEFAULT_PROTOCOL); 513 509 514 510 if (!ircd.started) { … … 635 631 add_module_savedata(savelist, "ircd.privileges", 636 632 sizeof(ircd.privileges), &ircd.privileges); 637 add_module_savedata(savelist, "ircd.default_proto",638 sizeof(ircd.default_proto), &ircd.default_proto);639 633 add_module_savedata(savelist, "ircd.lists", sizeof(ircd.lists), 640 634 &ircd.lists); -
branches/ithildin-1.1/modules/ircd/protocol.c
r717 r818 14 14 15 15 IDSTRING(rcsid, "$Id$"); 16 17 /* this function, defined below, and the one defined immediately below here are18 * the default packet parsers. The default packets resemble rfc1459 strongly.19 * The actual packet parser is a bit pickier about what gets passed along,20 * however. */21 static int protocol_packet_parse(connection_t *cp, char *end);22 23 /* Return codes from protocol_packet_parse */24 #define PROTOCOL_PARSE_PROTOSET 125 #define PROTOCOL_PARSE_1459STOP 226 27 #define DEFAULT_BUFFER_SIZE 51228 HOOK_FUNCTION(protocol_default_input) {29 isocket_t *sp = (isocket_t *)data;30 connection_t *cp = (connection_t *)sp->udata;31 int ret = 0;32 char *s;33 34 if (!(cp->flags & IRCD_CONNFL_STAGE2)) { /* initialize the connection */35 cp->buf = malloc(DEFAULT_BUFFER_SIZE);36 cp->buflen = 0;37 cp->bufsize = DEFAULT_BUFFER_SIZE;38 cp->flags |= IRCD_CONNFL_STAGE2;39 cp->buf[0] = '\0';40 }41 42 if (cp->buflen < cp->bufsize)43 ret = socket_read(sp, cp->buf + cp->buflen,44 cp->bufsize - cp->buflen);45 if (ret < 0)46 return (void *)0; /* the error should be picked up by the handler. */47 else if (ret == 0)48 return (void *)0; /* nothing to do */49 50 cp->buflen += ret;51 52 cp->stats.recv += ret;53 /* the rest of this was yanked almost verbatim from proto/rfc1459.c, I had54 * done it a different way, but it ate a flaming bag of acidli when55 * connections to servers were attempted. Now I've split this into a56 * pretty straightforward rfc1459 packet parser, and a command handler57 * function which lives below */58 59 while (cp->buflen > 0) {60 /* if the buffer is full but no terminating character (\n) is found, we61 * cheat */62 if (cp->buflen == cp->bufsize) {63 cp->buf[cp->bufsize - 1] = '\n';64 s = cp->buf + cp->bufsize - 1;65 } else {66 cp->buf[cp->buflen] = '\0';67 s = strchr(cp->buf, '\n');68 if (s == NULL)69 return (void *)0; /* no command terminator found and we're out70 of data */71 }72 /* make a local copy of the packet, then pass it off to the parser.73 * Bump the rest of the contents of 'buf' down if we read more than we74 * have parsed. */75 /* null-terminate and get rid of the [\r]\n sequence */76 if (*(s - 1) == '\r')77 *(s - 1) = '\0';78 else79 *s = '\0';80 81 /* Parse the packet, we must stop parsing immediately if the82 * connection is closed. Additionally, we stop parsing immediately83 * if we get the 1459 return because the code that returns it84 * modifies our buffer for us. In that case we return proto changed85 * and let input be call for us above. */86 if ((ret = protocol_packet_parse(cp, s)) == IRCD_CONNECTION_CLOSED)87 return (void *)ret; /* stop parsing.. */88 else if (ret == PROTOCOL_PARSE_1459STOP)89 return (void *)IRCD_PROTOCOL_CHANGED;90 s++; /* increment s, now we see if our packet contains more data */91 if ((size_t)(s - cp->buf) < cp->buflen) {92 cp->buflen -= s - cp->buf;93 memcpy(cp->buf, s, cp->buflen);94 } else {95 cp->buflen = 0; /* all done */96 *cp->buf = '\0'; /* no leftovers! */97 }98 if (ret == PROTOCOL_PARSE_PROTOSET)99 return (void *)IRCD_PROTOCOL_CHANGED;100 }101 102 return (void *)0;103 }104 105 static int protocol_packet_parse(connection_t *cp, char *end) {106 char *s, emsg[128];107 int rfc1459 = 0; /* this is such a dumb hack */108 109 cp->stats.precv++; /* another packet received.. */110 s = cp->buf;111 if (*s == ':') /* prefixed command? ignore it totally! */112 return 0;113 114 if (!strncasecmp(cp->buf, "QUIT", 4)) {115 destroy_connection(cp, "");116 return IRCD_CONNECTION_CLOSED;117 } else if (!strncasecmp(cp->buf, "PROTOCOL", 8)) {118 /* we received a 'protocol' command. cool. this makes our life easy,119 * just grab the stuff after and find a protocol if possible */120 s += 8;121 while (isspace(*s))122 s++;123 if (*s == '\0') {124 destroy_connection(cp, "bogus protocol command");125 return IRCD_CONNECTION_CLOSED;126 }127 128 /* otherwise, s points to their desired protocol */129 } else if (!strncasecmp(s, "NICK", 4) || !strncasecmp(s, "USER", 4) ||130 !strncasecmp(s, "PASS", 4)) {131 /* this is probably an rfc1459 connection */132 rfc1459 = 1;133 s = "rfc1459";134 } else {135 log_debug("received weird packet for unprotocoled connection: %s",136 cp->buf);137 return 0;138 }139 140 /* s now points to our chosen protocol! joy */141 cp->proto = find_protocol(s);142 if (cp->proto == NULL) {143 sprintf(emsg, "protocol %s is not supported", s);144 destroy_connection(cp, emsg);145 return IRCD_CONNECTION_CLOSED;146 }147 148 /* call the setup function for this connection */149 if (cp->proto->setup != NULL)150 cp->proto->setup(cp);151 152 if (rfc1459) {153 /* Re-adjust the buffer and return the special token to immediately154 * and successfully halt parsing (see above). We do this because155 * the protocol itself needs to receive the message we hooked onto156 * for 1459 verification. */157 if (*(end - 1) == '\0')158 *(end - 1) = '\r';159 *end = '\n';160 161 return PROTOCOL_PARSE_1459STOP;162 }163 164 return PROTOCOL_PARSE_PROTOSET;165 }166 16 167 17 protocol_t *find_protocol(char *name) { … … 237 87 pp->bufsize = *i64p; 238 88 else 239 pp->bufsize = DEFAULT_BUFFER_SIZE;89 pp->bufsize = 512; 240 90 } 241 91 -
branches/ithildin-1.1/modules/ircd/protocols/rfc1459.c
r814 r818 16 16 @DEPENDENCIES@: ircd 17 17 @DEPENDENCIES@: ircd/commands/nick ircd/commands/pass ircd/commands/user 18 @DEPENDENCIES@: ircd/commands/protocol 18 19 */ 19 20
Note: See TracChangeset
for help on using the changeset viewer.
