push master
authorpk910 <philipp@zoelle1.de>
Wed, 28 Jan 2015 01:52:00 +0000 (02:52 +0100)
committerpk910 <philipp@zoelle1.de>
Wed, 28 Jan 2015 01:52:00 +0000 (02:52 +0100)
src/Makefile.am
src/cmd.h
src/cmd_ping.c [new file with mode: 0644]
src/cmd_pong.c [new file with mode: 0644]
src/cmd_user.c
src/crypt_rsa.c
src/crypt_rsa.h
src/ircd_auth.c
src/ircd_client.c
src/ircd_parse.c

index 9534bf49723c36aecc336edbdc9d3309b2107699..70f3a7943333b86b1af2626309d98cd8f7da625f 100644 (file)
@@ -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
index b3ec2690032e54d8f0b55b851374f98d94a23a98..e595f555cd213c9060b5cb606d1d962921217dea 100644 (file)
--- 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 (file)
index 0000000..5e29ea7
--- /dev/null
@@ -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 <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;
+}
diff --git a/src/cmd_pong.c b/src/cmd_pong.c
new file mode 100644 (file)
index 0000000..c1e9601
--- /dev/null
@@ -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 <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;
+}
index f2a8d389865580bc2c27746214344af495f935a2..91b67376c76c0e5022469c8de31e3ccc537344c0 100644 (file)
@@ -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;
index c78bf8907ad31c447217b7692dbdd83e54c6184c..223acb30e02e35ab523ae56210afd6c1d46703db 100644 (file)
@@ -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))
index 7e72176ab279360a485fc9d46bd301969d82bb6c..fee06159f32c04a7b0ec79387bbaab797d50c3af 100644 (file)
@@ -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);
index b0ff83145f675d02600281c13626e0399897926b..1645892042e434b3965ea2fc330a40a7d0297e60 100644 (file)
@@ -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;
index 001548ebae5408424a74621694ada982993131ea..77e1b6c5bfaae7efcab32220e7943bd481e769ce 100644 (file)
 #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, ...) {
index 0a72a2af9c681cbc6f0227f3baa9c965ec4090bc..950541c10c08749830b7092d0f7626388a6be103 100644 (file)
@@ -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 */