} while (trie_findnext(&f2) == 1);
} while (trie_findnext(&f1) == 1);
}
+const char *format_umodes(struct client_data *cl) {
+ static char umodes[6] = "";
+ char *p = umodes;
+ *p++ = '+';
+ if (cl->umode & UMODE_INVISIBLE) *p++ = 'i';
+ if (cl->umode & UMODE_OPER) *p++ = 'o';
+ if (cl->umode & UMODE_REGISTERED) *p++ = 'r';
+ if (cl->umode & UMODE_WALLOPS) *p++ = 'w';
+ if (cl->umode & UMODE_SECURE) *p++ = 'Z';
+ *p++ = '\0';
+ return umodes;
+}
int parsePacket(struct client_data *client) {
char *source = NULL;
char *command = NULL;
struct client_data *cl = findClient(nick);
if (!cl)
return err_nosuchnick(client, nick), sendbuf(client), 0;
- copy_strf(&databuf, ":%s 221 %s +", hostname, client->nick);
- if (cl->umode & UMODE_INVISIBLE) append_str(&databuf, "i");
- if (cl->umode & UMODE_OPER) append_str(&databuf, "o");
- if (cl->umode & UMODE_LOPER) append_str(&databuf, "O");
- if (cl->umode & UMODE_REGISTERED) append_str(&databuf, "r");
- if (cl->umode & UMODE_WALLOPS) append_str(&databuf, "w");
- if (cl->umode & UMODE_SECURE) append_str(&databuf, "Z");
- append_str(&databuf, "\r\n");
+ if (client->FD != cl->FD) {
+ copy_strf(&databuf, ":%s 502 %s :Can't view mode for other users\n", hostname, client->nick);
+ sendbuf(client);
+ return 0;
+ }
+ copy_strf(&databuf, ":%s 221 %s %s\r\n", hostname, client->nick, format_umodes(client));
sendbuf(client);
} else {
struct channel *chan = findChannel(nick);
copy_strf(&databuf, ":%s MODE %s %si\n", hostname, client->nick, is_plus?"+":"-");
sendbuf(client);
break;
+ case 'w':
+ SETBIT(cl->umode, UMODE_WALLOPS, is_plus);
+ copy_strf(&databuf, ":%s MODE %s %sw\n", hostname, client->nick, is_plus?"+":"-");
+ sendbuf(client);
+ break;
case 'o':
if (!is_plus) {
SETBIT(cl->umode, UMODE_OPER, is_plus);
if (!client->nick)
return;
client->regstate = REG_REGISTERED;
+ client->umode |= UMODE_INVISIBLE | UMODE_WALLOPS;
rpl_welcome(client), sendbuf(client);
rpl_yourhost(client), sendbuf(client);
rpl_created(client), sendbuf(client);
sendbuf(client);
copy_strf(&databuf, ":%s 252 %s :Jannies don't exist\n", hostname, client->nick);
sendbuf(client);
+ copy_strf(&databuf, ":%s 221 %s %s\r\n", hostname, client->nick, format_umodes(client));
+ sendbuf(client);
sendMOTD(client);
}
}
void rpl_myinfo(struct client_data *client) // 004
{
- copy_strf(&databuf, ":%s 004 %s PatchyIRCD 0.0.1 i nt\n", hostname, client->nick);
+ copy_strf(&databuf, ":%s 004 %s PatchyIRCD 0.0.1 iworZ beIklPimnst\n", hostname, client->nick);
}
void rpl_isupport(struct client_data *client) // 005
{
- copy_strf(&databuf, ":%s 005 %s CASEMAPPING=rfc1459 NICKLEN=%u CHANMODES=beI,k,l,Pimnst CHANTYPES=#& PREFIX=(ov)@+ :are supported by this server\n", hostname, client->nick, MAX_NICKLEN-1);
+ copy_strf(&databuf, ":%s 005 %s CASEMAPPING=rfc1459 NICKLEN=%u EXCEPTS=e INVEX=I MAXTARGETS=1 CHANMODES=beI,k,l,Pimnst CHANTYPES=#& PREFIX=(ov)@+ STATUSMSG=@+ :are supported by this server\n", hostname, client->nick, MAX_NICKLEN-1);
}
// 010 RPL_BOUNC