users.txt
newusers.txt
help.txt
+motd.txt
For TLS you gonna need to place your certificate and private key in
`cert.pem` and `key.pem` respectively.
-`ops.txt` `users.txt` and `newusers.txt` contain hashed passwords. `ops.txt` is
+`ops.txt`, `users.txt` and `newusers.txt` contain hashed passwords. `ops.txt` is
used for OPER command, `users.txt` is used for PASS command (which we use for
our bespoke user account system). NEWACC command adds lines to `newusers.txt`.
To verify a registration, simply copy lines from `newusers.txt` to `users.txt`.
(the file must already exist).
`help.txt` file contains the text for the HELP command. You can use the provided
-`help.example.txt` file.
+`help.example.txt` file. Similarly, `motd.txt` contains the MOTD text.
When the server starts, it reads the `init.txt` file. A fake oper connection
performs the actions specified in the file. This allows initializing permanent
}
void sendMOTD(struct client_data *client) {
- rpl_motdstart(client), sendbuf(client);
- rpl_motd(client, "Welcome to Montreal!"), sendbuf(client);
- rpl_motd(client, "You are retarded and I will have cybersex with your mom."), sendbuf(client);
- rpl_endofmotd(client), sendbuf(client);
+ char line[512];
+ FILE *f = fopen("motd.txt", "r");
+ if (f) {
+ rpl_motdstart(client), sendbuf(client);
+ while (fgets(line, 512, f)) {
+ char *c = strchr(line, '\n');
+ if (*c)
+ *c = '\0';
+ rpl_motd(client, line), sendbuf(client);
+ }
+ fclose(f);
+ rpl_endofmotd(client), sendbuf(client);
+ } else {
+ err_nomotd(client), sendbuf(client);
+ }
}
void setNick(struct client_data *client, char* nickname) {
{
copy_strf(&databuf, ":%s 421 %s %s :Unknown command\r\n", hostname, client->nick ? client->nick : "*", command);
}
-#if 0
void err_nomotd(struct client_data *client) // 422
{
copy_strf(&databuf, ":%s 422 %s :MOTD File is missing\r\n", hostname, client->nick);
}
-#endif
void err_erroneusnickname(struct client_data *client, const char *nick) // 432
{
copy_strf(&databuf, ":%s 432 %s %s :Erroneus nickname\r\n", hostname, client->nick, nick);