Only in eggdrop1.3.28: CONTENTS diff -r -u eggdrop1.3.28/README eggdrop1.3.28+ipv6/README --- eggdrop1.3.28/README Sun Jun 27 08:39:14 1999 +++ eggdrop1.3.28+ipv6/README Thu Aug 10 22:04:16 2000 @@ -486,7 +486,9 @@ If there are any serious places that should be added, let us know. +(11) SPECIAL IPV6 Version + This is eggdrop1.3.28 with IPV6 support. Added by psychoid. The eggdrop 1.3 devteam. diff -r -u eggdrop1.3.28/config.h.in eggdrop1.3.28+ipv6/config.h.in --- eggdrop1.3.28/config.h.in Wed Jun 23 21:51:22 1999 +++ eggdrop1.3.28+ipv6/config.h.in Thu Aug 10 22:02:54 2000 @@ -140,3 +140,7 @@ /* running on NeXT Step */ #undef BORGCUBES + +/* undef this if theres no IPV6 */ + +#define IPV6 diff -r -u eggdrop1.3.28/eggdrop.conf.dist eggdrop1.3.28+ipv6/eggdrop.conf.dist --- eggdrop1.3.28/eggdrop.conf.dist Tue Aug 10 00:51:05 1999 +++ eggdrop1.3.28+ipv6/eggdrop.conf.dist Sat Aug 12 12:10:28 2000 @@ -39,7 +39,7 @@ # let you know if it has trouble -- trust me.) #set my-hostname "virtual.host.com" #set my-ip "99.99.0.0" - +#set my-ip6 "3ffe:400:5a0:0:0:0:0:1" ##### LOG FILES ##### diff -r -u eggdrop1.3.28/src/botnet.c eggdrop1.3.28+ipv6/src/botnet.c --- eggdrop1.3.28/src/botnet.c Wed Jun 23 21:51:26 1999 +++ eggdrop1.3.28+ipv6/src/botnet.c Thu Aug 10 22:07:49 2000 @@ -925,7 +925,7 @@ dcc[i].u.bot->numver = idx; dcc[i].timeval = now; dcc[i].u.bot->port = dcc[i].port; /* remember where i started */ - dcc[i].sock = getsock(SOCK_STRONGCONN); + dcc[i].sock = getsock(SOCK_STRONGCONN,getprotocol(bi->address)); dcc[i].user = u; if (open_telnet_raw(dcc[i].sock, bi->address, dcc[i].port) >= 0) return 1; @@ -964,7 +964,7 @@ return; } killsock(dcc[idx].sock); - dcc[idx].sock = getsock(SOCK_STRONGCONN); + dcc[idx].sock = getsock(SOCK_STRONGCONN,getprotocol(dcc[idx].host)); dcc[uidx].u.relay->sock = dcc[idx].sock; dcc[idx].port++; dcc[idx].timeval = now; @@ -1029,7 +1029,7 @@ dcc[idx].u.relay->chat = ci; dcc[idx].type = &DCC_PRE_RELAY; - dcc[i].sock = getsock(SOCK_STRONGCONN); + dcc[i].sock = getsock(SOCK_STRONGCONN,getprotocol(dcc[i].host)); dcc[idx].u.relay->sock = dcc[i].sock; dcc[i].u.relay->sock = dcc[idx].sock; dcc[i].timeval = now; diff -r -u eggdrop1.3.28/src/dcc.c eggdrop1.3.28+ipv6/src/dcc.c --- eggdrop1.3.28/src/dcc.c Wed Aug 4 17:51:58 1999 +++ eggdrop1.3.28+ipv6/src/dcc.c Thu Aug 10 21:47:30 2000 @@ -202,7 +202,7 @@ } /* try next port */ killsock(dcc[idx].sock); - dcc[idx].sock = getsock(SOCK_STRONGCONN); + dcc[idx].sock = getsock(SOCK_STRONGCONN,getprotocol(dcc[idx].host)); dcc[idx].port++; dcc[idx].timeval = now; if (open_telnet_raw(dcc[idx].sock, dcc[idx].host, dcc[idx].port) < 0) { diff -r -u eggdrop1.3.28/src/eggdrop.h eggdrop1.3.28+ipv6/src/eggdrop.h --- eggdrop1.3.28/src/eggdrop.h Fri Jul 23 17:53:41 1999 +++ eggdrop1.3.28+ipv6/src/eggdrop.h Thu Aug 10 19:54:39 2000 @@ -429,6 +429,7 @@ char *inbuf; char *outbuf; unsigned long outbuflen; /* outbuf could be binary data */ + unsigned int af; } sock_list; #endif diff -r -u eggdrop1.3.28/src/main.c eggdrop1.3.28+ipv6/src/main.c --- eggdrop1.3.28/src/main.c Mon Aug 2 22:16:47 1999 +++ eggdrop1.3.28+ipv6/src/main.c Thu Aug 10 21:42:18 2000 @@ -184,7 +184,7 @@ /* all of these are pretty reliable, so we'll try these */ /* dont try and display context-notes in here, it's _not_ safe */ x = creat("DEBUG.DEBUG", 0644); - setsock(x, SOCK_NONSOCK); + setsock(x, SOCK_NONSOCK,AF_INET); if (x >= 0) { strcpy(s, ctime(&now)); dprintf(-x, "Debug (%s) written %s", ver, s); @@ -206,7 +206,7 @@ putlog(LOG_MISC, "*", "* Last context: %s/%d [%s]", cx_file[cx_ptr], cx_line[cx_ptr], cx_note[cx_ptr][0] ? cx_note[cx_ptr] : ""); x = creat("DEBUG", 0644); - setsock(x, SOCK_NONSOCK); + setsock(x, SOCK_NONSOCK,AF_INET); if (x < 0) { putlog(LOG_MISC, "*", "* Failed to write DEBUG"); } else { @@ -716,7 +716,7 @@ adduser(userlist, "HQ", "none", "-", USER_PARTY); dcc[n].user = get_user_by_handle(userlist, "HQ"); } - setsock(STDOUT, 0); /* entry in net table */ + setsock(STDOUT, 0,AF_INET); /* entry in net table */ dprintf(n, "\n### ENTERING DCC CHAT SIMULATION ###\n\n"); dcc_chatter(n); } diff -r -u eggdrop1.3.28/src/mod/filesys.mod/filesys.c eggdrop1.3.28+ipv6/src/mod/filesys.mod/filesys.c --- eggdrop1.3.28/src/mod/filesys.mod/filesys.c Wed Jun 23 21:51:35 1999 +++ eggdrop1.3.28+ipv6/src/mod/filesys.mod/filesys.c Thu Aug 10 21:50:15 2000 @@ -663,7 +663,7 @@ lostdcc(i); } else { dcc[i].timeval = now; - dcc[i].sock = getsock(SOCK_BINARY); + dcc[i].sock = getsock(SOCK_BINARY,getprotocol(ip)); if (open_telnet_dcc(dcc[i].sock, ip, prt) < 0) { dcc[i].type->eof(i); } @@ -708,7 +708,7 @@ } else { ip = newsplit(&msg); prt = newsplit(&msg); - sock = getsock(0); + sock = getsock(0,getprotocol(ip)); if (open_telnet_dcc(sock, ip, prt) < 0) { neterror(buf); dprintf(DP_HELP, "NOTICE %s :%s (%s)\n", nick, diff -r -u eggdrop1.3.28/src/mod/module.h eggdrop1.3.28+ipv6/src/mod/module.h --- eggdrop1.3.28/src/mod/module.h Sun Jul 25 20:57:42 1999 +++ eggdrop1.3.28+ipv6/src/mod/module.h Sat Aug 12 13:40:56 2000 @@ -128,7 +128,7 @@ /* 80 - 83 */ #define new_dcc ((int (*) (struct dcc_table *, int))global[80]) #define lostdcc ((void (*) (int))global[81]) -#define getsock ((int (*) (int))global[82]) +#define getsock ((int (*) (int, int))global[82]) #define killsock ((void (*) (int))global[83]) /* 84 - 87 */ #define open_listen ((int (*) (int *))global[84]) @@ -312,6 +312,7 @@ #define use_exempts (*(int *)(global[225])) /* drummer/Jason */ #define use_invites (*(int *)(global[226])) /* drummer/Jason */ #define force_expire (*(int *)(global[227])) /* Rufus */ +#define getprotocol ((int (*)(char *))global[228]) /* get protocol */ /* this is for blowfish module, couldnt be bothereed making a whole new .h * file for it ;) */ #ifndef MAKING_BLOWFISH diff -r -u eggdrop1.3.28/src/mod/server.mod/server.c eggdrop1.3.28+ipv6/src/mod/server.mod/server.c --- eggdrop1.3.28/src/mod/server.mod/server.c Wed Aug 4 17:51:58 1999 +++ eggdrop1.3.28+ipv6/src/mod/server.mod/server.c Sat Aug 12 13:14:30 2000 @@ -707,7 +707,7 @@ } else { if (!sanitycheck_dcc(nick, from, ip, prt)) return 1; - sock = getsock(0); + sock = getsock(0,getprotocol(ip)); if (open_telnet_dcc(sock, ip, prt) < 0) { neterror(buf); if(!quiet_reject) @@ -895,7 +895,12 @@ gethostname(s, 80); if (strchr(s, '.') != NULL) return; - hp = gethostbyname(s); +#ifdef IPV6 + if(getprotocol(s)==AF_INET6) + hp = gethostbyname2(s,AF_INET6); + else +#endif + hp = gethostbyname(s); if (hp == NULL) fatal("Hostname self-lookup failed.", 0); strcpy(s, hp->h_name); diff -r -u eggdrop1.3.28/src/mod/share.mod/share.c eggdrop1.3.28+ipv6/src/mod/share.mod/share.c --- eggdrop1.3.28/src/mod/share.mod/share.c Fri Jul 23 04:07:18 1999 +++ eggdrop1.3.28+ipv6/src/mod/share.mod/share.c Sat Aug 12 14:45:05 2000 @@ -907,7 +907,7 @@ /* ufsend */ static void share_ufsend(int idx, char *par) { - char *ip, *port; + char *ip=NULL, *port; char s[1024]; int i, sock; FILE *f; @@ -925,9 +925,9 @@ putlog(LOG_MISC, "*", "CAN'T WRITE USERFILE DOWNLOAD FILE!"); zapfbot(idx); } else { - sock = getsock(SOCK_BINARY); ip = newsplit(&par); port = newsplit(&par); + sock = getsock(SOCK_BINARY,getprotocol(ip)); if (open_telnet_dcc(sock, ip, port) < 0) { putlog(LOG_MISC, "*", "Asynchronous connection failed!"); dprintf(idx, "s e Can't connect to you!\n"); diff -r -u eggdrop1.3.28/src/modules.c eggdrop1.3.28+ipv6/src/modules.c --- eggdrop1.3.28/src/modules.c Sun Jul 25 20:57:41 1999 +++ eggdrop1.3.28+ipv6/src/modules.c Sat Aug 12 14:23:57 2000 @@ -441,6 +441,7 @@ (Function) & use_exempts, /* int - drummer/Jason */ (Function) & use_invites, /* int - drummer/Jason */ (Function) & force_expire, /* int - Rufus */ + (Function) & getprotocol, /* int - psychoid */ }; void init_modules(void) diff -r -u eggdrop1.3.28/src/net.c eggdrop1.3.28+ipv6/src/net.c --- eggdrop1.3.28/src/net.c Wed Aug 4 17:51:58 1999 +++ eggdrop1.3.28+ipv6/src/net.c Sat Aug 12 14:46:24 2000 @@ -37,7 +37,9 @@ char hostname[121] = ""; /* hostname can be specified in the config * file */ +char hostname6[121] = ""; /* hostname for ipv6 */ char myip[121] = ""; /* IP can be specified in the config file */ +char myip6[121] = ""; /* ip for ipv6 */ char firewall[121] = ""; /* socks server for firewall */ int firewallport = 1080; /* default port of Sock4/5 firewalls */ char botuser[21] = "eggdrop"; /* username of the user running the bot */ @@ -88,6 +90,29 @@ } #endif +/* define the protocol based on a given host */ + +int getprotocol(char *host) +{ +#ifndef IPV6 + return AF_INET; +#else + struct hostent *he; + if (!setjmp(alarmret)) { + alarm(resolve_timeout); + he = gethostbyname2(host,AF_INET6); + alarm(0); + } else + he=NULL; + if(!he) + { + return AF_INET; // we check no resolve on IPv4 and assume it, if v6 does not work + } + return AF_INET6; +#endif +} + + /* initialize the socklist */ void init_net() { @@ -114,6 +139,9 @@ return tot; } +struct hostent *myipv6he; +char myipv6host[120]; + /* get my ip number */ IP getmyip() { @@ -121,11 +149,27 @@ char s[121]; IP ip; struct in_addr *in; - + myipv6he=NULL; /* could be pre-defined */ - if (myip[0]) { - if ((myip[strlen(myip) - 1] >= '0') && (myip[strlen(myip) - 1] <= '9')) - return (IP) inet_addr(myip); +#ifdef IPV6 + if (myip6[0]) { + myipv6he=gethostbyname2(myip6,AF_INET6); + if(myipv6he==NULL) + fatal("Hostname IPV6 self-lookup failed.", 0); + } + if (hostname6[0]) { + myipv6he=gethostbyname2(hostname6,AF_INET6); + if(myipv6he==NULL) + fatal("Hostname IPV6 self-lookup failed.", 0); + } + if(myipv6he!=NULL) + { + inet_ntop(AF_INET6,&myipv6he,myipv6host,119); + } +#endif + if(myip[0]) { + if ((myip[strlen(myip) - 1] >= '0') && (myip[strlen(myip) - 1] <= '9')) + return (IP) inet_addr(myip); } /* also could be pre-defined */ if (hostname[0]) @@ -134,8 +178,9 @@ gethostname(s, 120); hp = gethostbyname(s); } - if (hp == NULL) + if (hp == NULL && myipv6he==NULL) fatal("Hostname self-lookup failed.", 0); + if(hp==NULL) return 0; in = (struct in_addr *) (hp->h_addr_list[0]); ip = (IP) (in->s_addr); return ip; @@ -215,7 +260,7 @@ } /* request a normal socket for i/o */ -void setsock(int sock, int options) +void setsock(int sock, int options, int af_ty) { int i; int parm; @@ -227,6 +272,7 @@ socklist[i].outbuflen = 0; socklist[i].flags = options; socklist[i].sock = sock; + socklist[i].af=af_ty; if (((sock != STDOUT) || backgrd) && !(socklist[i].flags & SOCK_NONSOCK)) { parm = 1; @@ -250,13 +296,13 @@ fatal("Socket table is full!", 0); } -int getsock(int options) +int getsock(int options,int AF_DEF) { - int sock = socket(AF_INET, SOCK_STREAM, 0); + int sock = socket(AF_DEF, SOCK_STREAM, 0); if (sock < 0) fatal("Can't open a socket at all!", 0); - setsock(sock, options); + setsock(sock, options, AF_DEF); return sock; } @@ -287,23 +333,38 @@ /* send connection request to proxy */ static int proxy_connect(int sock, char *host, int port, int proxy) { +#ifdef IPV6 + unsigned char x[32]; +#else unsigned char x[10]; +#endif struct hostent *hp; char s[30]; + int af_ty; int i; + af_ty=getprotocol(host); /* socks proxy */ if (proxy == PROXY_SOCKS) { /* numeric IP? */ - if ((host[strlen(host) - 1] >= '0') && (host[strlen(host) - 1] <= '9')) { + if ((host[strlen(host) - 1] >= '0') && (host[strlen(host) - 1] <= '9') && af_ty!=AF_INET6) { IP ip = ((IP) inet_addr(host)); /* drummer */ my_memcpy((char *) x, (char *) &ip, 4); /* Beige@Efnet */ } else { /* no, must be host.domain */ if (!setjmp(alarmret)) { +#ifdef IPV6 alarm(resolve_timeout); - hp = gethostbyname(host); + if(af_ty==AF_INET6) + { + hp = gethostbyname2(host,AF_INET6); + } else { +#endif + hp = gethostbyname(host); +#ifdef IPV6 + } alarm(0); +#endif } else { hp = NULL; } @@ -317,7 +378,17 @@ if (!(socklist[i].flags & SOCK_UNUSED) && (socklist[i].sock == sock)) socklist[i].flags |= SOCK_PROXYWAIT; /* drummer */ } - sprintf(s, "\004\001%c%c%c%c%c%c%s", (port >> 8) % 256, (port % 256), +#ifdef IPV6 + if(af_ty==AF_INET6) + sprintf(s, "\004\001%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%s", (port >> 8) % 256, (port % 256), + x[0], x[1], x[2], x[3], + x[4], x[5], x[6], x[7], + x[9], x[9], x[10], x[11], + x[12], x[13], x[14], x[15], + botuser); + else +#endif + sprintf(s, "\004\001%c%c%c%c%c%c%s", (port >> 8) % 256, (port % 256), x[0], x[1], x[2], x[3], botuser); tputs(sock, s, strlen(botuser) + 9); /* drummer */ } else if (proxy == PROXY_SUN) { @@ -327,6 +398,20 @@ return sock; } +/* + * return protocol of socket + */ + +int getsockproto(int sock) +{ + int i; + for (i = 0; i < MAXSOCKS; i++) { + if (socklist[i].sock == sock) + return socklist[i].af; + } + return AF_INET; // default +} + /* starts a connection attempt to a socket * returns <0 if connection refused: * -1 neterror() type error @@ -334,9 +419,15 @@ int open_telnet_raw(int sock, char *server, int sport) { struct sockaddr_in name; +#ifdef IPV6 + struct sockaddr_in6 name6; + int rc; + unsigned long succ; +#endif struct hostent *hp; char host[121]; int i, port; + int af_ty; volatile int proxy; /* firewall? use socks */ @@ -354,44 +445,95 @@ strcpy(host, server); port = sport; } +#ifdef IPV6 + af_ty=getprotocol(host); + if(af_ty==AF_INET6) + { + succ=getmyip(); + bzero((char *) &name6, sizeof(struct sockaddr_in6)); + + name6.sin6_family = AF_INET6; + if(myip[0]) + { + if(myipv6he==NULL) + { + memcpy(&name6.sin6_addr,&in6addr_any,16); + } else { + memcpy(&name6.sin6_addr,myipv6he->h_addr,myipv6he->h_length); + } + } else { + + } + if (bind(sock, (struct sockaddr *) &name6, sizeof(name6)) < 0) { + killsock(sock); + return -1; + } + bzero((char *) &name6, sizeof(struct sockaddr_in6)); + name6.sin6_family = AF_INET6; + name6.sin6_port = my_htons(port); + if (!setjmp(alarmret)) { + alarm(resolve_timeout); + hp = gethostbyname2(host,AF_INET6); + alarm(0); + } else { + hp = NULL; + } + if (hp == NULL) { + killsock(sock); + return -2; + } + my_memcpy((char *) &name6.sin6_addr, hp->h_addr, hp->h_length); + name6.sin6_family = hp->h_addrtype; + } else { +#endif /* patch by tris for multi-hosted machines: */ - bzero((char *) &name, sizeof(struct sockaddr_in)); + bzero((char *) &name, sizeof(struct sockaddr_in)); - name.sin_family = AF_INET; - name.sin_addr.s_addr = (myip[0] ? getmyip() : INADDR_ANY); - if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0) { - killsock(sock); - return -1; - } - bzero((char *) &name, sizeof(struct sockaddr_in)); + name.sin_family = AF_INET; + name.sin_addr.s_addr = (myip[0] ? getmyip() : INADDR_ANY); + if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0) { + killsock(sock); + return -1; + } + bzero((char *) &name, sizeof(struct sockaddr_in)); - name.sin_family = AF_INET; - name.sin_port = my_htons(port); - /* numeric IP? */ - if ((host[strlen(host) - 1] >= '0') && (host[strlen(host) - 1] <= '9')) - name.sin_addr.s_addr = inet_addr(host); - else { - /* no, must be host.domain */ - if (!setjmp(alarmret)) { - alarm(resolve_timeout); - hp = gethostbyname(host); - alarm(0); - } else { - hp = NULL; - } - if (hp == NULL) { - killsock(sock); - return -2; - } - my_memcpy((char *) &name.sin_addr, hp->h_addr, hp->h_length); - name.sin_family = hp->h_addrtype; + name.sin_family = AF_INET; + name.sin_port = my_htons(port); + /* numeric IP? */ + if ((host[strlen(host) - 1] >= '0') && (host[strlen(host) - 1] <= '9')) + name.sin_addr.s_addr = inet_addr(host); + else { + /* no, must be host.domain */ + if (!setjmp(alarmret)) { + alarm(resolve_timeout); + hp = gethostbyname(host); + alarm(0); + } else { + hp = NULL; + } + if (hp == NULL) { + killsock(sock); + return -2; + } + my_memcpy((char *) &name.sin_addr, hp->h_addr, hp->h_length); + name.sin_family = hp->h_addrtype; + } +#ifdef IPV6 } +#endif for (i = 0; i < MAXSOCKS; i++) { if (!(socklist[i].flags & SOCK_UNUSED) && (socklist[i].sock == sock)) socklist[i].flags |= SOCK_CONNECT; } - if (connect(sock, (struct sockaddr *) &name, - sizeof(struct sockaddr_in)) < 0) { +#ifdef IPV6 + if(af_ty==AF_INET6) + rc=connect(sock, (struct sockaddr *) &name6, + sizeof(struct sockaddr_in6)); + else +#endif + rc=connect(sock, (struct sockaddr *) &name, + sizeof(struct sockaddr_in)); + if (rc < 0) { if (errno == EINPROGRESS) { /* firewall? announce connect attempt to proxy */ if (firewall[0]) @@ -411,14 +553,19 @@ /* ordinary non-binary connection attempt */ int open_telnet(char *server, int port) { - return open_telnet_raw(getsock(0), server, port); + return open_telnet_raw(getsock(0,getprotocol(server)), server, port); } /* returns a socket number for a listening socket that will accept any * connection -- port # is returned in port */ int open_listen(int *port) { - int sock, addrlen; + int sock=0, addrlen; + int af_def; + unsigned long ipp; +#ifdef IPV6 + struct sockaddr_in6 name6; +#endif struct sockaddr_in name; if (firewall[0]) { @@ -426,27 +573,58 @@ putlog(LOG_ALL, "*", "!! Cant open a listen port (you are using a firewall)\n"); return -1; } - sock = getsock(SOCK_LISTEN); - bzero((char *) &name, sizeof(struct sockaddr_in)); - - name.sin_family = AF_INET; - name.sin_port = my_htons(*port); /* 0 = just assign us a port */ - name.sin_addr.s_addr = (myip[0] ? getmyip() : INADDR_ANY); - if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0) { - killsock(sock); - return -1; - } - /* what port are we on? */ - addrlen = sizeof(name); - if (getsockname(sock, (struct sockaddr *) &name, &addrlen) < 0) { - killsock(sock); - return -1; - } - *port = my_ntohs(name.sin_port); - if (listen(sock, 1) < 0) { - killsock(sock); - return -1; + if(getmyip()>0) { + af_def=AF_INET; + sock = getsock(SOCK_LISTEN,af_def); + bzero((char *) &name, sizeof(struct sockaddr_in)); + + name.sin_family = AF_INET; + name.sin_port = my_htons(*port); /* 0 = just assign us a port */ + name.sin_addr.s_addr = (myip[0] ? getmyip() : INADDR_ANY); + if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0) { + killsock(sock); + goto tryv6; + } + /* what port are we on? */ + addrlen = sizeof(name); + if (getsockname(sock, (struct sockaddr *) &name, &addrlen) < 0) { + killsock(sock); + goto tryv6; + } + *port = my_ntohs(name.sin_port); + if (listen(sock, 1) < 0) { + killsock(sock); + goto tryv6; + } + return sock; } +tryv6: +#ifdef IPV6 + ipp=getmyip(); + af_def=AF_INET6; + if(af_def==AF_INET6 && myipv6he!=NULL) + { + sock = getsock(SOCK_LISTEN,af_def); + bzero((char *) &name6,sizeof(name6)); + name6.sin6_family=af_def; + name6.sin6_port=my_htons(*port); + memcpy(&name6.sin6_addr,myipv6he->h_addr,myipv6he->h_length); + if (bind(sock, (struct sockaddr *) &name6, sizeof(name6)) < 0) { + killsock(sock); + return -1; + } + addrlen = sizeof(name6); + if (getsockname(sock, (struct sockaddr *) &name6, &addrlen) < 0) { + killsock(sock); + return -1; + } + *port = my_ntohs(name6.sin6_port); + if (listen(sock, 1) < 0) { + killsock(sock); + return -1; + } + } +#endif return sock; } @@ -476,6 +654,8 @@ return s; } +unsigned long notalloc=0; + /* short routine to answer a connect received on a socket made previously * by open_listen ... returns hostname of the caller & the new socket * does NOT dispose of old "public" socket! */ @@ -483,22 +663,55 @@ unsigned short *port, int binary) { int new_sock, addrlen; + int af_ty; +#ifdef IPV6 + struct sockaddr_in6 from6; +#endif struct sockaddr_in from; - addrlen = sizeof(struct sockaddr); - - new_sock = accept(sock, (struct sockaddr *) &from, &addrlen); + af_ty=getsockproto(sock); + +#ifdef IPV6 + if(af_ty==AF_INET6) + { + addrlen = sizeof(from6); + new_sock = accept(sock, (struct sockaddr *) &from6, &addrlen); + } else { +#endif + addrlen = sizeof(struct sockaddr); + new_sock = accept(sock, (struct sockaddr *) &from, &addrlen); +#ifdef IPV6 + } +#endif if (new_sock < 0) return -1; if (ip != NULL) { - *ip = from.sin_addr.s_addr; - strncpy(caller, hostnamefromip(*ip), 120); - caller[120] = 0; - *ip = my_ntohl(*ip); +#ifdef IPV6 + if(af_ty==AF_INET6) + { + *ip=notalloc; + inet_ntop(AF_INET6,&from6,caller,119); + caller[120]=0; + } else { +#endif + *ip = from.sin_addr.s_addr; + strncpy(caller, hostnamefromip(*ip), 120); + caller[120] = 0; + *ip = my_ntohl(*ip); +#ifdef IPV6 + } +#endif } if (port != NULL) - *port = my_ntohs(from.sin_port); + { +#ifdef IPV6 + if(af_ty==AF_INET6) + *port = my_ntohs(from6.sin6_port); + else +#endif + *port = my_ntohs(from.sin_port); + } /* set up all the normal socket crap */ - setsock(new_sock, (binary ? SOCK_BINARY : 0)); + setsock(new_sock, (binary ? SOCK_BINARY : 0),af_ty); return new_sock; } @@ -507,24 +720,35 @@ { int p; unsigned long addr; - char sv[121]; + char sv[500]; unsigned char c[4]; if (port != NULL) p = atoi(port); else p = 2000; - if (server != NULL) - addr = my_atoul(server); - else - addr = 0L; - if (addr < (1 << 24)) - return -3; /* fake address */ - c[0] = (addr >> 24) & 0xff; - c[1] = (addr >> 16) & 0xff; - c[2] = (addr >> 8) & 0xff; - c[3] = addr & 0xff; - sprintf(sv, "%u.%u.%u.%u", c[0], c[1], c[2], c[3]); +#ifdef IPV6 + if(getprotocol(server)==AF_INET6) + { + server[0]=0; + if(strlen(server)<500) + strcpy(sv,server); + } else { +#endif + if (server != NULL) + addr = my_atoul(server); + else + addr = 0L; + if (addr < (1 << 24)) + return -3; /* fake address */ + c[0] = (addr >> 24) & 0xff; + c[1] = (addr >> 16) & 0xff; + c[2] = (addr >> 8) & 0xff; + c[3] = addr & 0xff; + sprintf(sv, "%u.%u.%u.%u", c[0], c[1], c[2], c[3]); +#ifdef IPV6 + } +#endif /* strcpy(sv,hostnamefromip(addr)); */ p = open_telnet_raw(sock, sv, p); return p; @@ -942,6 +1166,12 @@ return 1; context; /* This should be pretty solid, but * something _might_ break. */ +#ifdef IPV6 + if(getprotocol(ipaddy)==AF_INET6) + { + return 1; + } +#endif sprintf(badaddress, "%u.%u.%u.%u", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); if (prt < 1) { diff -r -u eggdrop1.3.28/src/proto.h eggdrop1.3.28+ipv6/src/proto.h --- eggdrop1.3.28/src/proto.h Tue Jul 20 20:14:39 1999 +++ eggdrop1.3.28+ipv6/src/proto.h Sat Aug 12 13:14:23 2000 @@ -194,8 +194,9 @@ unsigned long iptolong(IP); IP getmyip(); void neterror(char *); -void setsock(int, int); -int getsock(int); +void setsock(int, int, int); +int getsock(int, int); +int getprotocol(char *); void killsock(int); int answer(int, char *, unsigned long *, unsigned short *, int); int open_listen(int *); diff -r -u eggdrop1.3.28/src/tcl.c eggdrop1.3.28+ipv6/src/tcl.c --- eggdrop1.3.28/src/tcl.c Wed Aug 4 17:51:58 1999 +++ eggdrop1.3.28+ipv6/src/tcl.c Sat Aug 12 12:16:50 2000 @@ -40,7 +40,7 @@ extern int firewallport, reserved_port, notify_users_at; extern int flood_thr, ignore_time; extern char origbotname[], botuser[], motdfile[], admin[], userfile[], - firewall[], helpdir[], notify_new[], hostname[], myip[], moddir[], + firewall[], helpdir[], notify_new[], hostname[], hostname6[], myip[], myip6[], moddir[], tempdir[], owner[], network[], botnetnick[], bannerfile[]; extern int die_on_sighup, die_on_sigterm, max_logs, max_logsize, enable_simul; extern int dcc_total, debug_output, identtimeout, protect_telnet; @@ -358,7 +358,9 @@ {"notify-newusers", notify_new, 120, 0}, {"owner", owner, 120, STR_PROTECT}, {"my-hostname", hostname, 120, 0}, + {"my-hostname6", hostname6, 120, 0}, {"my-ip", myip, 120, 0}, + {"my-ip6", myip6, 120, 0}, {"network", network, 40, 0}, {"whois-fields", whois_fields, 120, 0}, {"nat-ip", natip, 120, 0}, diff -r -u eggdrop1.3.28/src/tcldcc.c eggdrop1.3.28+ipv6/src/tcldcc.c --- eggdrop1.3.28/src/tcldcc.c Wed Jun 23 21:51:32 1999 +++ eggdrop1.3.28+ipv6/src/tcldcc.c Sat Aug 12 12:17:12 2000 @@ -837,7 +837,7 @@ return TCL_ERROR; } i = dcc_total; - sock = getsock(0); + sock = getsock(0,getprotocol(argv[1])); z = open_telnet_raw(sock, argv[1], atoi(argv[2])); if (z < 0) { if (z == (-2)) diff -r -u eggdrop1.3.28/src/tclmisc.c eggdrop1.3.28+ipv6/src/tclmisc.c --- eggdrop1.3.28/src/tclmisc.c Tue Jul 20 20:16:58 1999 +++ eggdrop1.3.28+ipv6/src/tclmisc.c Sat Aug 12 13:31:04 2000 @@ -289,6 +289,21 @@ return TCL_OK; } +extern char myipv6host[120]; + +static int tcl_myip6 STDVAR +{ + char s[120]; + getmyip(); + context; + BADARGS(1, 1, ""); + s[0]=0; + if(strlen(myipv6host)<120) + strcpy(s,myipv6host); + Tcl_AppendResult(irp, s, NULL); + return TCL_OK; +} + static int tcl_rand STDVAR { unsigned long x; @@ -522,6 +537,7 @@ {"utimers", tcl_utimers}, {"ctime", tcl_ctime}, {"myip", tcl_myip}, + {"myip6", tcl_myip6}, {"rand", tcl_rand}, {"sendnote", tcl_sendnote}, {"dumpfile", tcl_dumpfile},