Compare commits

..
4 Commits
Author SHA1 Message Date
retoor ea43985f79 Added logging, repaired server. 2025-05-06 15:52:54 +02:00
retoor 020138aa7f Added logging. 2025-05-06 15:44:09 +02:00
retoor 911fbb4681 update. 2025-05-06 15:26:23 +02:00
retoor a44c5b9bc2 Initial commit. 2025-05-06 15:00:06 +02:00
2 changed files with 7 additions and 20 deletions
-4
View File
@@ -1,4 +0,0 @@
irc_echo_boy.py
irc_server
load_test
motd.txt
+7 -16
View File
@@ -21,12 +21,12 @@
// MIT License
#define MAX_EVENTS 4096
#define MAX_CHANNELS 4096
#define MAX_NICKLEN 4096
#define MAX_USERLEN 4096
#define MAX_CHANNELLEN 128
#define MAX_TOPICLEN 4096
#define MAX_MSG 4096
#define MAX_CHANNELS 1024
#define MAX_NICKLEN 51
#define MAX_USERLEN 51
#define MAX_CHANNELLEN 51
#define MAX_TOPICLEN 256
#define MAX_MSG 512
#define MOTD_FILE "motd.txt"
#define SERVER_NAME "rirc"
#define VERSION "1.0"
@@ -39,7 +39,7 @@ typedef struct Client {
char nickname[MAX_NICKLEN+1];
char user[MAX_USERLEN+1];
char realname[MAX_USERLEN+1];
char host[128];
char host[64];
int registered;
int pass_ok;
char readbuf[MAX_MSG*2];
@@ -117,12 +117,6 @@ static void del_epoll(int fd) {
epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd, NULL);
}
static void update_client_events(Client *c) {
uint32_t events = EPOLLIN;
if (c->writebuf_len > 0) events |= EPOLLOUT;
mod_epoll(c->fd, events, c);
}
static void send_reply(Client *c, const char *fmt, ...) {
char buf[MAX_MSG];
va_list ap;
@@ -131,7 +125,6 @@ static void send_reply(Client *c, const char *fmt, ...) {
va_end(ap);
int n = snprintf(c->writebuf + c->writebuf_len, sizeof(c->writebuf) - c->writebuf_len, ":%s %s\r\n", SERVER_NAME, buf);
if (n > 0 && c->writebuf_len + n < sizeof(c->writebuf)) c->writebuf_len += n;
update_client_events(c);
}
static void send_raw(Client *c, const char *fmt, ...) {
@@ -142,7 +135,6 @@ static void send_raw(Client *c, const char *fmt, ...) {
va_end(ap);
int n = snprintf(c->writebuf + c->writebuf_len, sizeof(c->writebuf) - c->writebuf_len, "%s\r\n", buf);
if (n > 0 && c->writebuf_len + n < sizeof(c->writebuf)) c->writebuf_len += n;
update_client_events(c);
}
static Channel *find_channel(const char *name) {
@@ -525,7 +517,6 @@ int main(int argc, char **argv) {
char *line, *saveptr;
line = strtok_r(c->readbuf, "\r\n", &saveptr);
while (line) {
printf("%s\n",line);
handle_line(c, line);
line = strtok_r(NULL, "\r\n", &saveptr);
}