X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fircd_auth.c;h=56f4481ab9c9c207eac4c9748615bb1bc2a9f75d;hb=b71e2c21fa000761fa80d66597f880496d9f45f2;hp=8079db1c78ff89092687b1ca5a1be44eba316dca;hpb=e17a8a5dc929df2a5ae6169f1955fcde7c70e04b;p=NextIRCd.git diff --git a/src/ircd_auth.c b/src/ircd_auth.c index 8079db1..56f4481 100644 --- a/src/ircd_auth.c +++ b/src/ircd_auth.c @@ -14,9 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - -#include - #include "struct_auth.h" #include "struct_connection.h" #include "ircd_client.h" @@ -25,13 +22,14 @@ #include "version.h" static IODNS_CALLBACK(auth_dns_callback); +static void auth_free(struct Auth *auth); static struct Auth *authlist_first = NULL; static struct Auth *authlist_last = NULL; -struct Auth *auth_new(struct Connection *conn) { +struct Auth *auth_new(struct Connection *conn) { struct Auth *auth = calloc(1, sizeof(*auth)); - client_printf(conn, "NOTICE AUTH :*** NextIRCd v%d.%d (%s)", VERSION_NUMBER, patchlevel, revision); + socket_printf(conn, "NOTICE AUTH :*** NextIRCd v%d.%d (%s)", VERSION_NUMBER, patchlevel, revision); auth->conn = conn; time(&auth->startup_time); @@ -39,14 +37,16 @@ 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); + return auth; } void auth_start_dnsreverse(struct Auth *auth) { - client_printf(auth->conn, "NOTICE AUTH :*** Looking up your hostname"); + socket_printf(auth->conn, "NOTICE AUTH :*** Looking up your hostname"); struct IODNSAddress *sockaddr; sockaddr = iosocket_get_remote_addr(auth->conn->socket); @@ -61,17 +61,21 @@ static IODNS_CALLBACK(auth_dns_callback) { struct Auth *auth = event->query->data; struct IODNSResult *dnsresult = event->result; + auth->dnslookup = NULL; + if(event->type == IODNSEVENT_SUCCESS) { strncpy(auth->host, dnsresult->result.host, HOSTLEN); - client_printf(auth->conn, "NOTICE AUTH :*** Found your hostname (%s)", auth->host); + socket_printf(auth->conn, "NOTICE AUTH :*** Found your hostname (%s)", auth->host); } else { struct IODNSAddress *sockaddr = iosocket_get_remote_addr(auth->conn->socket); - if(auth->conn->ipv6) - inet_ntop(AF_INET6, (void *)(&((struct sockaddr_in6 *)sockaddr->address)->sin6_addr), auth->host, HOSTLEN); - else + if(sockaddr->addresslen == sizeof(struct sockaddr_in)) { + //ipv4 inet_ntop(AF_INET, (void *)(&((struct sockaddr_in *)sockaddr->address)->sin_addr), auth->host, HOSTLEN); - - client_printf(auth->conn, "NOTICE AUTH :*** Couldn't look up your hostname. Using your IP instead (%s)", auth->host); + } else { + //ipv6 + inet_ntop(AF_INET6, (void *)(&((struct sockaddr_in6 *)sockaddr->address)->sin6_addr), auth->host, HOSTLEN); + } + socket_printf(auth->conn, "NOTICE AUTH :*** Couldn't look up your hostname. Using your IP instead (%s)", auth->host); } if(dnsresult) iodns_free_result(dnsresult); @@ -81,5 +85,30 @@ static IODNS_CALLBACK(auth_dns_callback) { void auth_try_finish(struct Auth *auth) { + if(auth->server) { + + } else { + if(!auth->have_nick || !auth->have_user) + return; + if(!auth->sent_ping) { + + auth->sent_ping = 1; + } else if(auth->have_pong && auth->have_dnsresolv) { + struct Client *client = client_connected(auth); + auth->conn->authed = 1; + auth->conn->data.client = client; + auth_free(auth); + } + } +} + +void auth_abort(struct Auth *auth) { + +} +static void auth_free(struct Auth *auth) { + if(auth->dnslookup) { + + } + }