From: pk910 Date: Thu, 24 Jul 2014 14:00:21 +0000 (+0200) Subject: added some code X-Git-Url: http://git.pk910.de/?p=NextIRCd.git;a=commitdiff_plain;h=4e79b9632a41b2c7d2fecb4e4514692f9cf7e7f9 added some code --- diff --git a/src/ircd_auth.c b/src/ircd_auth.c index 56f4481..22325f4 100644 --- a/src/ircd_auth.c +++ b/src/ircd_auth.c @@ -14,6 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +#include + +#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) diff --git a/src/ircd_auth.h b/src/ircd_auth.h index f200e5d..9fee6a8 100644 --- a/src/ircd_auth.h +++ b/src/ircd_auth.h @@ -18,8 +18,10 @@ #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); diff --git a/src/ircd_client.c b/src/ircd_client.c index 088d4c4..001548e 100644 --- a/src/ircd_client.c +++ b/src/ircd_client.c @@ -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 #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, ...) { diff --git a/src/ircd_parse.c b/src/ircd_parse.c index 54cdad2..3a23335 100644 --- a/src/ircd_parse.c +++ b/src/ircd_parse.c @@ -16,6 +16,7 @@ */ #include +#include #include "tools.h" #include "IOHandler/IOSockets.h" diff --git a/src/ircd_sock.c b/src/ircd_sock.c index a61686f..259c74b 100644 --- a/src/ircd_sock.c +++ b/src/ircd_sock.c @@ -21,11 +21,14 @@ #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 #include +#include #include // @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); diff --git a/src/struct_auth.h b/src/struct_auth.h index 335917e..0f21f5f 100644 --- a/src/struct_auth.h +++ b/src/struct_auth.h @@ -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; diff --git a/src/struct_client.h b/src/struct_client.h index a944bb2..0ffa68c 100644 --- a/src/struct_client.h +++ b/src/struct_client.h @@ -17,6 +17,8 @@ #ifndef _struct_client_h #define _struct_client_h +#include + #include "crypt_md5.h" #include "struct_user.h"