Subj : IPv6 Patch To : All From : Tommi Koivula Date : Thu Dec 05 2019 09:46:01 ============================================================================= * Forwarded by Tommi Koivula (2:221/360) * Area : UTF-8 (Fidonet - !!!) * From : Konstantin Kuzov, 2:5019/40.1 (Monday March 13 2017 13:19) * To : Kees van Eeten * Subj : Poetry for who can read it. ============================================================================= Greetings, Kees! KVE> With that done the next challenge is to get the reverse route KVE> going, as well as making smapinntpd IPv6 aware. Dunno if we need to go to IPV6 echo... But porting to ipv6 is pretty trivial: ===================================================================== diff -urN ganjanntpd-1.9/main.c ganjanntpd-1.9-ipv6/main.c -+- ganjanntpd-1.9/main.c 2017-02-27 23:41:23.000000000 +0300 +++ ganjanntpd-1.9-ipv6/main.c 2017-03-13 12:59:42.872717283 +0300 @@ -223,16 +223,6 @@ cfg_logfile=argv[++c]; } - else if(stricmp(arg,"-ip")==0 || stricmp(arg,"-ipaddress")==0) - { - if(c+1 == argc) - { - printf("Missing argument for %s%s\n",argv[c],src); - return(FALSE); - } - - cfg_ipaddr=argv[++c]; - } else if(stricmp(arg,"-config")==0) { if(filename) @@ -359,7 +349,6 @@ fprintf(fp,"users \"%s\"\n",cfg_usersfile); fprintf(fp,"xlat \"%s\"\n",cfg_xlatfile); fprintf(fp,"hostname \"%s\"\n",cfg_hostname); - fprintf(fp,"ipaddress \"%s\"\n",cfg_ipaddr); fprintf(fp,"logfile \"%s\"\n",cfg_logfile); fprintf(fp,"%snoecholog\n",cfg_noecholog ? "" : "#"); fprintf(fp,"%sdebug\n",cfg_debug ? "" : "#"); @@ -401,7 +390,7 @@ { SOCKET sock; int error,res; - struct sockaddr_in local; + struct sockaddr_in6 local; fd_set fds; struct timeval tv; FILE *fp; @@ -501,7 +490,7 @@ exit(10); } - sock = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP); + sock = socket(PF_INET6,SOCK_STREAM,IPPROTO_TCP); if(sock == INVALID_SOCKET) { @@ -518,9 +507,8 @@ memset(&local, 0, sizeof(local) ); - local.sin_family = AF_INET; - local.sin_addr.s_addr = (cfg_ipaddr && strcmp(cfg_ipaddr,"0.0.0.0") != 0) ? inet_addr(cfg_ipaddr) : INADDR_ANY; - local.sin_port = htons(cfg_port); + local.sin6_family = AF_INET6; + local.sin6_port = htons(cfg_port); error = bind(sock,(struct sockaddr *)&local,sizeof(local)); @@ -550,7 +538,7 @@ exit(10); } - os_logwrite(SERVER_NAME " " SERVER_VERSION " is running on %s:%d",cfg_ipaddr,cfg_port); + os_logwrite(SERVER_NAME " " SERVER_VERSION " is running on port %d",cfg_port); if(cfg_debug) os_logwrite("Compiled " __DATE__ " " __TIME__); diff -urN ganjanntpd-1.9/nntpserv.c ganjanntpd-1.9-ipv6/nntpserv.c -+- ganjanntpd-1.9/nntpserv.c 2017-03-10 09:54:41.000000000 +0300 +++ ganjanntpd-1.9-ipv6/nntpserv.c 2017-03-13 13:01:18.239794707 +0300 @@ -15,7 +15,6 @@ uchar *cfg_allowfile = CFG_ALLOWFILE; uchar *cfg_groupsfile = CFG_GROUPSFILE; -uchar *cfg_ipaddr = CFG_IPADDR; uchar *cfg_logfile = CFG_HOSTNAME; uchar *cfg_usersfile = CFG_USERSFILE; uchar *cfg_xlatfile = CFG_XLATFILE; @@ -3093,8 +3092,8 @@ struct var var; struct hostent *hostent; - struct sockaddr_in fromsa; - int fromsa_len = sizeof(struct sockaddr_in); + struct sockaddr_in6 fromsa; + int fromsa_len = sizeof(struct sockaddr_in6); os_getexclusive(); server_openconnections++; @@ -3156,16 +3155,16 @@ return; } - sprintf(var.clientid,"%s:%u",inet_ntoa(fromsa.sin_addr),ntohs(fromsa.sin_port)); + inet_ntop(AF_INET6, &fromsa.sin6_addr, lookup, sizeof(lookup)); - mystrncpy(lookup,inet_ntoa(fromsa.sin_addr),200); + snprintf(var.clientid,200,"%s:%u",lookup,ntohs(fromsa.sin6_port)); - if((hostent=gethostbyaddr((char *)&fromsa.sin_addr,sizeof(fromsa.sin_addr),AF_INET))) + if((hostent=gethostbyaddr((char *)&fromsa.sin6_addr,sizeof(fromsa.sin6_addr),AF_INET6))) mystrncpy(lookup,hostent->h_name,200); os_logwrite("(%s) Connection established to %s",var.clientid,lookup); - if(!checkallow(&var,inet_ntoa(fromsa.sin_addr))) + if(!checkallow(&var,lookup)) { socksendtext(&var,"502 Access denied." CRLF); os_logwrite("(%s) Access denied (not in allow list)",var.clientid); diff -urN ganjanntpd-1.9/nntpserv.h ganjanntpd-1.9-ipv6/nntpserv.h -+- ganjanntpd-1.9/nntpserv.h 2017-02-27 23:15:13.000000000 +0300 +++ ganjanntpd-1.9-ipv6/nntpserv.h 2017-03-13 12:59:11.824692072 +0300 @@ -108,7 +108,6 @@ #define CFG_LOGFILE LOG_BASEPATH "ganjanntpd.log" #define CFG_HOSTNAME "GaNJaNNTPd!not-for-mail" -#define CFG_IPADDR "0.0.0.0" #define CFG_DEF_FLOWED TRUE #define CFG_DEF_SHOWTO TRUE @@ -118,7 +117,6 @@ extern uchar *cfg_allowfile; extern uchar *cfg_groupsfile; extern uchar *cfg_hostname; -extern uchar *cfg_ipaddr; extern uchar *cfg_logfile; extern uchar *cfg_usersfile; extern uchar *cfg_xlatfile; ===================================================================== And make sure sysctl net.ipv6.bindv6only=0 for ipv4 to work as well. -+- Claws Mail 3.14.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) + Origin: Via 2:5019/40 NNTP (GaNJaNET STaTi0N, Smolensk) (2:5019/40.1) ============================================================================= 'Tommi --- * Origin: 2001:470:1f15:cb0:f1d0:2:221:360 (2:221/360) .