--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#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
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#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;
+}
#ifndef _crypt_md5_h
#define _crypt_md5_h
+#define MDHASHLEN 16
+
unsigned char *crypt_md5_bin(const char *str, int strlen);
#endif
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+#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)
+};
+
+
+
{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}}
};
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+#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
+}
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;
};
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#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
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#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
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#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
--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#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