added some code
authorpk910 <philipp@zoelle1.de>
Thu, 24 Jul 2014 14:00:21 +0000 (16:00 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 24 Jul 2014 14:00:21 +0000 (16:00 +0200)
src/ircd_auth.c
src/ircd_auth.h
src/ircd_client.c
src/ircd_parse.c
src/ircd_sock.c
src/struct_auth.h
src/struct_client.h

index 56f4481ab9c9c207eac4c9748615bb1bc2a9f75d..22325f484e491da3072907098369ded701647b08 100644 (file)
@@ -14,6 +14,9 @@
  * 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 "ircd_auth.h"
 #include "struct_auth.h"
 #include "struct_connection.h"
 #include "ircd_client.h"
@@ -21,6 +24,7 @@
 #include "IOHandler/IODNSLookup.h"
 #include "version.h"
 
+static void auth_start_dnsreverse(struct Auth *auth);
 static IODNS_CALLBACK(auth_dns_callback);
 static void auth_free(struct Auth *auth);
 
@@ -37,7 +41,7 @@ struct Auth *auth_new(struct Connection *conn) {
        auth->prev = authlist_last;
        auth->next = NULL;
        if(!authlist_last)
-               authlist_first = auth
+               authlist_first = auth;
        authlist_last = auth;
        
        auth_start_dnsreverse(auth);
@@ -45,7 +49,7 @@ struct Auth *auth_new(struct Connection *conn) {
        return auth;
 }
 
-void auth_start_dnsreverse(struct Auth *auth) {
+static void auth_start_dnsreverse(struct Auth *auth) {
        socket_printf(auth->conn, "NOTICE AUTH :*** Looking up your hostname");
        
        struct IODNSAddress *sockaddr;
@@ -68,13 +72,7 @@ static IODNS_CALLBACK(auth_dns_callback) {
                socket_printf(auth->conn, "NOTICE AUTH :*** Found your hostname (%s)", auth->host);
        } else {
                struct IODNSAddress *sockaddr = iosocket_get_remote_addr(auth->conn->socket);
-               if(sockaddr->addresslen == sizeof(struct sockaddr_in)) {
-                       //ipv4
-                       inet_ntop(AF_INET, (void *)(&((struct sockaddr_in *)sockaddr->address)->sin_addr), auth->host, HOSTLEN);
-               } else {
-                       //ipv6
-                       inet_ntop(AF_INET6, (void *)(&((struct sockaddr_in6 *)sockaddr->address)->sin6_addr), auth->host, HOSTLEN);
-               }
+               iodns_print_address(sockaddr, auth->conn->socket->ipv6, auth->host, HOSTLEN);
                socket_printf(auth->conn, "NOTICE AUTH :*** Couldn't look up your hostname. Using your IP instead (%s)", auth->host);
        }
        if(dnsresult)
index f200e5df13cced078513faad035ad2907193dc47..9fee6a815885e094ebb82ade8ee9d7c6d6617370 100644 (file)
 #ifndef _ircd_auth_h
 #define _ircd_auth_h
 
+struct Connection;
+struct Auth;
+
 struct Auth *auth_new(struct Connection *conn);
-void auth_start_dnsreverse(struct Auth *auth);
 void auth_try_finish(struct Auth *auth);
 void auth_abort(struct Auth *auth);
 
index 088d4c4da24700ad4d9873478977d1b016d04c3e..001548ebae5408424a74621694ada982993131ea 100644 (file)
@@ -18,6 +18,7 @@
 #include "ircd_client.h"
 #include "ircd_sock.h"
 #include "struct_connection.h"
+#include "struct_client.h"
 #include "struct_auth.h"
 #include "ircd_config.h"
 
@@ -26,8 +27,9 @@
 #include <stdarg.h>
 #define CLIENT_MAXLEN 512
 
-void client_connected(struct Auth *auth) {
+struct Client *client_connected(struct Auth *auth) {
     
+    return NULL;
 }
 
 void client_printf(struct Client *client, const char *text, ...) {
index 54cdad20ef102d82455ea184b09d5f81b177a44f..3a23335d05e4b1fa11403ecaf4c1008e6d759b32 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 
 #include "tools.h"
 #include "IOHandler/IOSockets.h"
index a61686f5a22b089034b2b2d935f142e7b2d2fa62..259c74b84a851806a8e740d9d1d2aabeb2d834e1 100644 (file)
 #include "ircd_parse.h"
 #include "ircd_auth.h"
 #include "struct_connection.h"
+#include "struct_client.h"
+#include "struct_auth.h"
 
 #include "IOHandler/IOSockets.h"
 
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 #include <stdio.h> // @debug
 
 static struct Connection *sockets_listening = NULL;
@@ -196,7 +199,6 @@ static IOSOCKET_CALLBACK(sockets_iohandler_callback) {
             // listening socket could not be opened
         } else {
             sockets_remove_list(connection);
-            client_disconnected(connection);
             sockets_free_connection(connection);
         }
         break;
@@ -227,7 +229,7 @@ void socket_printf(struct Connection *conn, const char *text, ...) {
        va_start(arg_list, text);
        pos = vsnprintf(sendBuf, 512 - 2, text, arg_list);
        va_end(arg_list);
-       if (pos < 0 || pos > (512 - 2)) pos = CLIENT_MAXLEN - 2;
+       if (pos < 0 || pos > (512 - 2)) pos = 512 - 2;
        sendBuf[pos] = '\n';
     sendBuf[pos+1] = '\0';
        iosocket_send(conn->socket, sendBuf, pos+1);
index 335917e39005d77268c14a8bd0b8e1424d288a9f..0f21f5f2cf1ad99ecc25b71ab1fc7a922d381ba7 100644 (file)
@@ -44,6 +44,7 @@ struct Auth {
        unsigned int have_pass : 1;
     
        unsigned int have_dnsresolv : 1;
+       unsigned int sent_ping : 1;
        unsigned int have_pong : 1;
        
        struct Auth *prev, *next;
index a944bb2a0df7d811663bb6108ab9ac3730b27be9..0ffa68c11a68a0dd3f319e1df9fa236ab5fccac0 100644 (file)
@@ -17,6 +17,8 @@
 
 #ifndef _struct_client_h
 #define _struct_client_h
+#include <time.h>
+
 #include "crypt_md5.h"
 #include "struct_user.h"