From 1ed333a66df41a51352e13d3bb6c481f2c6617cf Mon Sep 17 00:00:00 2001 From: pk910 Date: Sun, 20 Jul 2014 19:32:46 +0200 Subject: [PATCH] added some files --- src/cmd.h | 30 +++++++++++++++++++++++ src/cmd_nick.c | 29 ++++++++++++++++++++++ src/crypt_md5.h | 2 ++ src/ircd_nicks.c | 29 ++++++++++++++++++++++ src/ircd_parse.c | 15 ++++++++++++ src/ircd_users.c | 34 ++++++++++++++++++++++++++ src/struct_auth.h | 8 ++++-- src/struct_channel.h | 34 ++++++++++++++++++++++++++ src/struct_client.h | 58 ++++++++++++++++++++++++++++++++++++++++++++ src/struct_member.h | 41 +++++++++++++++++++++++++++++++ src/struct_user.h | 44 +++++++++++++++++++++++++++++++++ 11 files changed, 322 insertions(+), 2 deletions(-) create mode 100644 src/cmd.h create mode 100644 src/cmd_nick.c create mode 100644 src/ircd_nicks.c create mode 100644 src/ircd_users.c create mode 100644 src/struct_channel.h create mode 100644 src/struct_client.h create mode 100644 src/struct_member.h create mode 100644 src/struct_user.h diff --git a/src/cmd.h b/src/cmd.h new file mode 100644 index 0000000..a2896a4 --- /dev/null +++ b/src/cmd.h @@ -0,0 +1,30 @@ +/* cmd.h - NextIRCd + * Copyright (C) 2012-2013 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _cmd_h +#define _cmd_h + +struct Client; +struct Auth; +struct Server; + + +int cmd_nick_cli(struct Client *client, char *argv[], int argc); +int cmd_nick_auth(struct Auth *auth, char *argv[], int argc); + + +#endif diff --git a/src/cmd_nick.c b/src/cmd_nick.c new file mode 100644 index 0000000..effb22f --- /dev/null +++ b/src/cmd_nick.c @@ -0,0 +1,29 @@ +/* cmd_nick.c - NextIRCd + * Copyright (C) 2012-2013 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "cmd.h" +#include "struct_auth.h" + +int cmd_nick_cli(struct Client *client, char *argv[], int argc) { + + return 0; +} + +int cmd_nick_auth(struct Auth *auth, char *argv[], int argc) { + + return 0; +} diff --git a/src/crypt_md5.h b/src/crypt_md5.h index e926e37..2b04665 100644 --- a/src/crypt_md5.h +++ b/src/crypt_md5.h @@ -18,6 +18,8 @@ #ifndef _crypt_md5_h #define _crypt_md5_h +#define MDHASHLEN 16 + unsigned char *crypt_md5_bin(const char *str, int strlen); #endif diff --git a/src/ircd_nicks.c b/src/ircd_nicks.c new file mode 100644 index 0000000..5b64ad2 --- /dev/null +++ b/src/ircd_nicks.c @@ -0,0 +1,29 @@ +/* ircd_nicks.c - NextIRCd + * Copyright (C) 2012-2013 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "struct_user.h" + +struct UserDictEntry { + struct User *user; + struct UserDict *next, *prev; +}; + +struct UserDict { + struct UserDictEntry *users[65536]; // 2^16 (first 16 bit of nickhash as identifier) +}; + + + diff --git a/src/ircd_parse.c b/src/ircd_parse.c index 392459b..21197b1 100644 --- a/src/ircd_parse.c +++ b/src/ircd_parse.c @@ -60,6 +60,21 @@ struct { {NULL, 0, 1, 0}, /* Unauthed */ {NULL, 0, 1, 0} /* Server */ }, + {{"PASS", NULL}, /* PASS Command */ + {NULL, 0, 1, 0}, /* Client */ + {NULL, 0, 1, 0}, /* Unauthed */ + {NULL, 0, 1, 0} /* Server */ + }, + {{"NICK", "N"}, /* Nick Command */ + {cmd_nick_cli, 0, 1, 0}, /* Client */ + {cmd_nick_auth, 0, 1, 0}, /* Unauthed */ + {NULL, 0, 1, 0} /* Server */ + }, + {{"USER", "U"}, /* User Command */ + {NULL, 0, 1, 0}, /* Client */ + {NULL, 0, 1, 0}, /* Unauthed */ + {NULL, 0, 1, 0} /* Server */ + }, {{NULL, NULL},{NULL, 0, 0, 0},{NULL, 0, 0, 0},{NULL, 0, 0, 0}} }; diff --git a/src/ircd_users.c b/src/ircd_users.c new file mode 100644 index 0000000..ef0bc82 --- /dev/null +++ b/src/ircd_users.c @@ -0,0 +1,34 @@ +/* ircd_users.c - NextIRCd + * Copyright (C) 2012-2013 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "struct_user.h" + +struct UserDictEntry { + struct User *user; + time_t lastaccess; + struct UserDict *next, *prev; +}; + +struct UserDict { + struct UserDictEntry *users[65536]; // 2^16 (first 16 bit of nickhash as identifier) +}; + + +void find_user_by_nick(char *nick) { + //calculate checksum + //search in UserDict + //ask trusted server multicast +} diff --git a/src/struct_auth.h b/src/struct_auth.h index 3a0147c..69a452a 100644 --- a/src/struct_auth.h +++ b/src/struct_auth.h @@ -20,14 +20,18 @@ struct Auth { struct Connection *conn; - + char *nick; char *ident; char *realname; char *passwd; unsigned int ping_number; - unsigned int server : 1; + + unsigned int server : 1; + unsigned int have_nick : 1; + unsigned int have_user : 1; + unsigned int have_pass : 1; }; diff --git a/src/struct_channel.h b/src/struct_channel.h new file mode 100644 index 0000000..a5c028b --- /dev/null +++ b/src/struct_channel.h @@ -0,0 +1,34 @@ +/* struct_channel.h - NextIRCd + * Copyright (C) 2012-2013 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _struct_channel_h +#define _struct_channel_h +#include "crypto_md5.h" + +#define NAMELEN 200 +#define TOPICLEN 500 +#define HOSTLEN 63 +#define REALLEN 50 + +struct Channel { + char name[NAMELEN+1]; + char namehash[MDHASHLEN]; + + struct Member *users; +}; + +#endif diff --git a/src/struct_client.h b/src/struct_client.h new file mode 100644 index 0000000..537b832 --- /dev/null +++ b/src/struct_client.h @@ -0,0 +1,58 @@ +/* struct_client.h - NextIRCd + * Copyright (C) 2012-2013 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _struct_client_h +#define _struct_client_h +#include "crypto_md5.h" +#include "struct_user.h" + +struct Connection; +struct User; + +struct ClientNickChange; + +#define AWAYLEN 300 + +/* Client represents a local User */ +struct Client { + struct Connection *conn; + struct User *user; + + struct ClientNickChange *nickchange; + + time_t userage; + time_t nickage; + time_t lastping; + time_t idlelen; + + char *userage_sign; + char *nickage_sign; + + char awaymsg[AWAYLEN-1]; + + unsigned int isonline : 1; + unsigned int isaway : 1; + + struct Client *prev, *next +}; + +struct ClientNickChange { + char newnick[NICKLEN+1]; + char nickhash[MDHASHLEN]; +}; + +#endif diff --git a/src/struct_member.h b/src/struct_member.h new file mode 100644 index 0000000..3f723fc --- /dev/null +++ b/src/struct_member.h @@ -0,0 +1,41 @@ +/* struct_member.h - NextIRCd + * Copyright (C) 2012-2013 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _struct_member_h +#define _struct_member_h + +struct Channel; +struct User; +struct Server; + +struct Member { + struct Channel *chan; + union { + struct User *user; + struct Server *server; + } user; + + unsigned int isserver : 1; + unsigned int isowner : 1; + unsigned int hasop : 1; + unsigned int hasvoice : 1; + + struct Member *prev_user, *next_user; + struct Member *prev_chan, *next_chan; +}; + +#endif diff --git a/src/struct_user.h b/src/struct_user.h new file mode 100644 index 0000000..47f722d --- /dev/null +++ b/src/struct_user.h @@ -0,0 +1,44 @@ +/* struct_user.h - NextIRCd + * Copyright (C) 2012-2013 Philipp Kreil (pk910) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _struct_user_h +#define _struct_user_h +#include "crypto_md5.h" + +#define NICKLEN 30 +#define IDENTLEN 15 +#define HOSTLEN 63 +#define REALLEN 50 + +struct User { + unsigned int usernum; + unsigned int servernum; + + struct Server *server; + + unsigned int islocal : 1; + + char nick[NICKLEN+1]; + char nickhash[MDHASHLEN]; + char ident[IDENTLEN+1]; + char realname[REALLEN+1]; + char hostname[HOSTLEN+1]; + + struct Member *channels; +}; + +#endif -- 2.20.1