Created
June 19, 2010 21:22
-
-
Save Estella/445290 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- orignick.c 2010-06-19 19:33:15.000000000 +0000 | |
+++ orignick6.c 2010-06-19 21:13:12.000000000 +0000 | |
@@ -6,6 +6,7 @@ | |
* * | |
* AUTHOR: * | |
* v9/vade79@realhalo.org, realhalo.org. (* model) * | |
+ * Estella/Estella@Mystagic, mystagic.com (ipv6 port) * | |
* * | |
* COMPILE: * | |
* # cc orignick.c -o orignick -lcrypt * | |
@@ -129,6 +130,7 @@ | |
*****************************************************************************/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
+#include <string.h> | |
#include <unistd.h> | |
#include <pwd.h> | |
#include <signal.h> | |
@@ -137,8 +139,9 @@ | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
+ | |
/* GENERAL INFORMATION, POSSIBLE CHANGES. */ | |
-#define VERSION "X+final+++" /* version information. */ | |
+#define VERSION "X+final-ipv6+++" /* version information. */ | |
#define ENV_IRCHOST "IRC_HOST" /* optional virtual host variable. */ | |
#define ENV_PASSWORD "PASSWD" /* optional passwd variable. */ | |
#define ENV_EPASSWORD "EPASSWD" /* optional crypted passwd variable. */ | |
@@ -158,7 +161,7 @@ | |
#define _XOPEN_SOURCE /* for the encrypted passwd option. */ | |
/* PROMPTS OR PRECURSORS TO DISPLAY TEXT. */ | |
#ifdef NOCOLOR | |
-#define PMT "[orignick]: " /* regular. (no color) */ | |
+#define PMT "[orignick6]: " /* regular. (no color) */ | |
#define EPMT "[ERROR]: " /* error. (no color) */ | |
#define DPMT "[debug]: " /* debug. (no color) */ | |
#endif | |
@@ -625,6 +628,7 @@ int rand_nickname(int size){ | |
return(0); | |
} | |
int irc_parse(char *host,int port){ | |
+ int err; | |
int i=0; | |
int j=0; | |
int k=0; | |
@@ -642,55 +646,57 @@ int irc_parse(char *host,int port){ | |
char sread[BASE_BUFFER]; | |
char sread_line[BASE_BUFFER]; | |
struct hostent *he; | |
- struct sockaddr_in irc; | |
+ struct sockaddr_in6 irc; | |
alarm(0); | |
allowversion=0; | |
if(!bg) | |
fprintf(stderr,"%sAttempting to connect to: %s:%d.\n",PMT,host,port); | |
- sock=socket(AF_INET,SOCK_STREAM,0); | |
+ sock=socket(PF_INET6,SOCK_STREAM,0); | |
if(sock<0){ | |
if(!bg) | |
printe("socket error",0); | |
serr=1; | |
} | |
- bzero(&irc,sizeof(struct sockaddr_in)); | |
- irc.sin_family=AF_INET; | |
+ bzero(&irc,sizeof(struct sockaddr_in6)); | |
+ irc.sin6_family=AF_INET6; | |
if(isvhost){ | |
- if(irc.sin_addr.s_addr=inet_addr(vhost)){ | |
- if(!(he=gethostbyname(vhost))){ | |
+ if (inet_pton(AF_INET6, vhost, &(irc.sin6_addr)) <= 0) { | |
+ if ((he = getipnodebyname(vhost, AF_INET6, AI_DEFAULT, &err)) == NULL) { | |
if(!bg&&!serr) | |
printe("couldn't resolve the provided host, trying any.",0); | |
- irc.sin_addr.s_addr=INADDR_ANY; | |
+ irc.sin6_addr=in6addr_any; | |
} | |
else | |
- memcpy((char *)&irc.sin_addr,(char *)he->h_addr,sizeof(irc.sin_addr)); | |
+ memcpy((char *)&irc.sin6_addr,(char *)he->h_addr,he->h_length); | |
} | |
- if(bind(sock,(struct sockaddr*)&irc,sizeof(struct sockaddr_in))){ | |
+ if(bind(sock,(struct sockaddr*)&irc,sizeof(struct sockaddr_in6))){ | |
if(!bg&&!serr) | |
printe("binding name to socket, trying any.",0); | |
- bzero(&irc,sizeof(struct sockaddr_in)); | |
- irc.sin_family=AF_INET; | |
- irc.sin_addr.s_addr=INADDR_ANY; | |
- if(bind(sock,(struct sockaddr*)&irc,sizeof(struct sockaddr_in))){ | |
+ bzero(&irc,sizeof(struct sockaddr_in6)); | |
+ irc.sin6_len=sizeof(irc); | |
+ irc.sin6_family=AF_INET6; | |
+ irc.sin6_addr=in6addr_any; | |
+ if(bind(sock,(struct sockaddr*)&irc,sizeof(struct sockaddr_in6))){ | |
if(!bg&&!serr) | |
printe("binding any name to socket.",0); | |
serr=1; | |
} | |
} | |
} | |
- bzero(&irc,sizeof(struct sockaddr_in)); | |
- irc.sin_family=AF_INET; | |
- irc.sin_port=htons(port); | |
- if(irc.sin_addr.s_addr=inet_addr(host)){ | |
- if(!(he=gethostbyname(host))){ | |
+ bzero(&irc,sizeof(struct sockaddr_in6)); | |
+ irc.sin6_len=sizeof(irc); | |
+ irc.sin6_family=AF_INET6; | |
+ irc.sin6_port=htons(port); | |
+ if (inet_pton(AF_INET6, host, &(irc.sin6_addr)) <= 0) { | |
+ if ((he = getipnodebyname(host, AF_INET6, AI_DEFAULT, &err)) == NULL) { | |
if(!bg&&!serr) | |
printe("couldn't resolve the provided host",0); | |
serr=1; | |
} | |
else | |
- memcpy((char *)&irc.sin_addr,(char *)he->h_addr,sizeof(irc.sin_addr)); | |
+ memcpy((char *)&irc.sin6_addr,(char *)he->h_addr,he->h_length); | |
} | |
- if(connect(sock,(struct sockaddr_in*)&irc,sizeof(irc))){ | |
+ if(connect(sock,(struct sockaddr *)&irc,sizeof(irc))){ | |
if(!bg&&!serr) | |
printe("couldn't connect to the provided host",0); | |
serr=1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment