ircd_parse.c \
ircd_auth.c \
ircd_users.c \
+ cmd_ping.c \
+ cmd_pong.c \
cmd_nick.c \
cmd_user.c \
main.c
struct Auth;
struct Server;
+int cmd_ping_cli(struct Client *client, char *argv[], int argc);
+int cmd_ping_auth(struct Auth *auth, char *argv[], int argc);
+int cmd_pong_cli(struct Client *client, char *argv[], int argc);
+int cmd_pong_auth(struct Auth *auth, char *argv[], int argc);
int cmd_nick_cli(struct Client *client, char *argv[], int argc);
int cmd_nick_auth(struct Auth *auth, char *argv[], int argc);
int cmd_user_cli(struct Client *client, char *argv[], int argc);
--- /dev/null
+/* cmd_ping.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 <string.h>
+
+#include "cmd.h"
+#include "struct_auth.h"
+#include "ircd_users.h"
+#include "ircd_auth.h"
+#include "ircd_sock.h"
+
+int cmd_ping_cli(struct Client *client, char *argv[], int argc) {
+
+ return 0;
+}
+
+int cmd_ping_auth(struct Auth *auth, char *argv[], int argc) {
+ char *parameter = argv[0];
+ if(!parameter || !*parameter)
+ parameter = "PONG";
+
+ socket_printf(auth->conn, ":AUTH PONG :%s", parameter);
+
+ return 0;
+}
--- /dev/null
+/* cmd_pong.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 <string.h>
+
+#include "cmd.h"
+#include "struct_auth.h"
+#include "ircd_users.h"
+#include "ircd_auth.h"
+
+int cmd_pong_cli(struct Client *client, char *argv[], int argc) {
+
+ return 0;
+}
+
+int cmd_pong_auth(struct Auth *auth, char *argv[], int argc) {
+ if(!auth->have_pong) {
+ auth->have_pong = 1;
+ auth_try_finish(auth);
+ }
+
+ return 0;
+}
int cmd_user_auth(struct Auth *auth, char *argv[], int argc) {
char *user = argv[0];
- char *mode = argv[1];
+ //char *mode = argv[1];
char *realname = argv[3];
char *hostname;
return pubkey;
}
-int crypt_rsa_encrypt_data(struct crypt_rsa_pubkey *pubkey, const char *data, int datalen, char **encrypted) {
+int crypt_rsa_encrypt_data(struct crypt_rsa_pubkey *pubkey, const unsigned char *data, int datalen, unsigned char **encrypted) {
if(!pubkey)
return 0;
if(datalen > crypt_rsa_encrypt_maxlen(pubkey))
return ret;
}
-int crypt_rsa_decrypt_data(struct crypt_rsa_privkey *privkey, const char *encrypted, int enclen, char **data) {
+int crypt_rsa_decrypt_data(struct crypt_rsa_privkey *privkey, const unsigned char *encrypted, int enclen, unsigned char **data) {
if(!privkey)
return 0;
if(enclen > RSA_size(privkey->rsa))
char *crypt_rsa_export_privkey(struct crypt_rsa_privkey *privkey, int pubkey);
struct crypt_rsa_pubkey *crypt_rsa_get_pubkey(struct crypt_rsa_privkey *privkey);
-int crypt_rsa_encrypt_data(struct crypt_rsa_pubkey *pubkey, const char *data, int datalen, char **encrypted);
-int crypt_rsa_decrypt_data(struct crypt_rsa_privkey *privkey, const char *encrypted, int enclen, char **data);
+int crypt_rsa_encrypt_data(struct crypt_rsa_pubkey *pubkey, const unsigned char *data, int datalen, unsigned char **encrypted);
+int crypt_rsa_decrypt_data(struct crypt_rsa_privkey *privkey, const unsigned char *encrypted, int enclen, unsigned char **data);
int crypt_rsa_encrypt_maxlen(struct crypt_rsa_pubkey *pubkey);
void crypt_rsa_encrypt_free(char *encrypted);
void crypt_rsa_decrypt_free(char *data);
return;
if(!auth->sent_ping) {
auth->sent_ping = 1;
+ socket_printf(auth->conn, ":AUTH PING :%d", auth->startup_time);
} else if(auth->have_pong && auth->have_dnsresolv) {
struct Client *client = client_connected(auth);
auth->conn->authed = 1;
#define CLIENT_MAXLEN 512
struct Client *client_connected(struct Auth *auth) {
-
- return NULL;
+ struct Client *client = calloc(1, sizeof(*client));
+ client->conn = auth->conn;
+
+ client_printf(client, "Hi");
+
+ return client;
}
void client_printf(struct Client *client, const char *text, ...) {
} parse_command_list[] = {
{{"PING", "P"}, /* Ping Command */
- {NULL, 0, 1, 0}, /* Client */
- {NULL, 0, 1, 0}, /* Unauthed */
+ {cmd_ping_cli, 0, 1, 0}, /* Client */
+ {cmd_ping_auth, 0, 1, 0}, /* Unauthed */
{NULL, 0, 1, 0} /* Server */
},
{{"PASS", NULL}, /* PASS Command */