From: pk910 Date: Wed, 28 Jan 2015 01:52:00 +0000 (+0100) Subject: push X-Git-Url: http://git.pk910.de/?p=NextIRCd.git;a=commitdiff_plain;h=b708125495aacd544ee33d252368814acae5adb9 push --- diff --git a/src/Makefile.am b/src/Makefile.am index 9534bf4..70f3a79 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,6 +23,8 @@ nextircd_SOURCES = \ ircd_parse.c \ ircd_auth.c \ ircd_users.c \ + cmd_ping.c \ + cmd_pong.c \ cmd_nick.c \ cmd_user.c \ main.c diff --git a/src/cmd.h b/src/cmd.h index b3ec269..e595f55 100644 --- a/src/cmd.h +++ b/src/cmd.h @@ -22,6 +22,10 @@ struct Client; 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); diff --git a/src/cmd_ping.c b/src/cmd_ping.c new file mode 100644 index 0000000..5e29ea7 --- /dev/null +++ b/src/cmd_ping.c @@ -0,0 +1,39 @@ +/* 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 . + */ + +#include + +#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; +} diff --git a/src/cmd_pong.c b/src/cmd_pong.c new file mode 100644 index 0000000..c1e9601 --- /dev/null +++ b/src/cmd_pong.c @@ -0,0 +1,37 @@ +/* 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 . + */ + +#include + +#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; +} diff --git a/src/cmd_user.c b/src/cmd_user.c index f2a8d38..91b6737 100644 --- a/src/cmd_user.c +++ b/src/cmd_user.c @@ -30,7 +30,7 @@ int cmd_user_cli(struct Client *client, char *argv[], int argc) { 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; diff --git a/src/crypt_rsa.c b/src/crypt_rsa.c index c78bf89..223acb3 100644 --- a/src/crypt_rsa.c +++ b/src/crypt_rsa.c @@ -415,7 +415,7 @@ struct crypt_rsa_pubkey *crypt_rsa_get_pubkey(struct crypt_rsa_privkey *privkey) 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)) @@ -429,7 +429,7 @@ int crypt_rsa_encrypt_data(struct crypt_rsa_pubkey *pubkey, const char *data, in 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)) diff --git a/src/crypt_rsa.h b/src/crypt_rsa.h index 7e72176..fee0615 100644 --- a/src/crypt_rsa.h +++ b/src/crypt_rsa.h @@ -33,8 +33,8 @@ void crypt_rsa_unload_privkey(struct crypt_rsa_privkey *privkey); 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); diff --git a/src/ircd_auth.c b/src/ircd_auth.c index b0ff831..1645892 100644 --- a/src/ircd_auth.c +++ b/src/ircd_auth.c @@ -92,6 +92,7 @@ void auth_try_finish(struct Auth *auth) { 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; diff --git a/src/ircd_client.c b/src/ircd_client.c index 001548e..77e1b6c 100644 --- a/src/ircd_client.c +++ b/src/ircd_client.c @@ -28,8 +28,12 @@ #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, ...) { diff --git a/src/ircd_parse.c b/src/ircd_parse.c index 0a72a2a..950541c 100644 --- a/src/ircd_parse.c +++ b/src/ircd_parse.c @@ -63,8 +63,8 @@ struct { } 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 */