Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 207668 - net-nntp/nzbget-0.2.3: Added IPv6 support
Summary: net-nntp/nzbget-0.2.3: Added IPv6 support
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement
Assignee: Sven Wegener
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-27 13:17 UTC by Maik Nijhuis
Modified: 2008-07-15 20:32 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to add IPv6 support to nzbget (nzbget-0.2.3-ipv6.patch,4.05 KB, patch)
2008-01-27 13:17 UTC, Maik Nijhuis
Details | Diff
Better patch (nzbget-0.2.3-ipv6.patch,4.41 KB, patch)
2008-01-27 13:26 UTC, Maik Nijhuis
Details | Diff
Better patch (nzbget-0.2.3-ipv6.patch,4.82 KB, patch)
2008-02-01 14:26 UTC, Maik Nijhuis
Details | Diff
ebuild that uses the ipv6 patch (nzbget-0.2.3-r2.ebuild,1012 bytes, text/plain)
2008-02-01 14:44 UTC, Maik Nijhuis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maik Nijhuis 2008-01-27 13:17:10 UTC
The given patch will add IPv6 support to nzbget. Both the internal client-server connection and the external connections to an IPv6 newsserver have been successfully tested. For testing, you can use newszilla6.xs4all.nl, which allows 3 simultaneous connections and is open for everyone with an IPv6 connection.

Reproducible: Always

Actual Results:  
No IPv6 support

Expected Results:  
IPv6 connection
Comment 1 Maik Nijhuis 2008-01-27 13:17:47 UTC
Created attachment 141875 [details, diff]
Patch to add IPv6 support to nzbget
Comment 2 Maik Nijhuis 2008-01-27 13:24:10 UTC
Comment on attachment 141875 [details, diff]
Patch to add IPv6 support to nzbget

><HTML><HEAD/><BODY><PRE>diff -Naur nzbget-0.2.3/Connection.cpp nzbget-0.2.3-ipv6/Connection.cpp
>--- nzbget-0.2.3/Connection.cpp	2005-09-02 09:00:41.000000000 +0200
>+++ nzbget-0.2.3-ipv6/Connection.cpp	2008-01-27 14:07:32.000000000 +0100
>@@ -255,37 +255,42 @@
> 	m_iBufferLength = 0;
> 	m_iBufferPos = 0;
> 
>-	struct hostent *hinfo;
>-	
>-	hinfo = ::gethostbyname( m_pNetAddress-&gt;GetHost() );
>-	
>-	if( !hinfo )
>+    int res;
>+    
>+    struct addrinfo addr_hints, *addr_list, *addr;
>+	char iPortStr[sizeof(int) * 4 + 1]; //is enough to hold any converted int
>+    
>+    memset(&amp;addr_hints, 0, sizeof(addr_hints));
>+    addr_hints.ai_family = AF_UNSPEC;    /* Allow IPv4 or IPv6 */
>+    addr_hints.ai_socktype = SOCK_STREAM,
>+    
>+    sprintf(iPortStr, "%d", m_pNetAddress-&gt;GetPort());
>+    
>+	res = ::getaddrinfo( m_pNetAddress-&gt;GetHost(), iPortStr, &amp;addr_hints, &amp;addr_list );
>+    
>+	if( res != 0 )
> 	{
> 		error( "Could not resolve hostname %s", m_pNetAddress-&gt;GetHost() );
> 		return -1;
> 	}
> 	
>-	memset(&amp;m_SocketAddress, '\0', sizeof(m_SocketAddress));
>-	m_SocketAddress.sin_family = AF_INET;
>-	memcpy(&amp;m_SocketAddress.sin_addr.s_addr, hinfo-&gt;h_addr_list[0], sizeof(m_SocketAddress.sin_addr.s_addr));
>-	m_SocketAddress.sin_port = htons( m_pNetAddress-&gt;GetPort() );
>-	
>-	m_iSocket = ::socket(PF_INET,SOCK_STREAM,0);
>-	
>-	if( m_iSocket &lt; 0 )
>-	{
>-		error("Socket creation failed for %s!", m_pNetAddress-&gt;GetHost() );
>-		return -1;
>-	}
>-
>-	int res = ::connect( m_iSocket ,(struct sockaddr *) &amp;m_SocketAddress, sizeof(m_SocketAddress) );
>-	
>-	if (res &lt; 0)
>+    for (addr = addr_list; addr != NULL; addr = addr-&gt;ai_next)
>+    { 
>+        m_iSocket = ::socket(addr-&gt;ai_family, addr-&gt;ai_socktype, addr-&gt;ai_protocol);
>+        if (m_iSocket == -1) continue;
>+    
>+        res = ::connect( m_iSocket , addr-&gt;ai_addr, addr-&gt;ai_addrlen );
>+        if (res != -1) break; /* Connection established */
>+    }
>+    
>+	if( addr == NULL )
> 	{
>-		error("Connection to %s failed!", m_pNetAddress-&gt;GetHost() );
>+		error("Socket creation or connection failed for %s!", m_pNetAddress-&gt;GetHost() );
> 		return -1;
> 	}
> 	
>+    freeaddrinfo( addr_list ); /* No longer needed */
>+    
> 	m_pFileBuffer = fdopen( m_iSocket, "r+" );
> 	
> 	if( !m_pFileBuffer )
>@@ -339,34 +344,42 @@
> {
> 	debug("Connection::DoBind()");
> 	
>-	struct hostent *hinfo;
>-	
>-	hinfo = ::gethostbyname( m_pNetAddress-&gt;GetHost() );
>-	
>-	if( !hinfo )
>+    int res;
>+    
>+    struct addrinfo addr_hints, *addr_list, *addr;
>+	char iPortStr[sizeof(int) * 4 + 1]; //is enough to hold any converted int
>+    
>+    memset(&amp;addr_hints, 0, sizeof(addr_hints));
>+    addr_hints.ai_family = AF_UNSPEC;    /* Allow IPv4 or IPv6 */
>+    addr_hints.ai_socktype = SOCK_STREAM,
>+    addr_hints.ai_flags = AI_PASSIVE;    /* For wildcard IP address */
>+    
>+    sprintf(iPortStr, "%d", m_pNetAddress-&gt;GetPort());
>+    
>+	res = ::getaddrinfo( m_pNetAddress-&gt;GetHost(), iPortStr, &amp;addr_hints, &amp;addr_list );
>+    
>+	if( res != 0 )
> 	{
> 		error( "Could not resolve hostname %s", m_pNetAddress-&gt;GetHost() );
> 		return -1;
> 	}
> 	
>-	m_iSocket = ::socket( PF_INET, SOCK_STREAM, 0 );
>-	
>-	if( m_iSocket &lt; 0 )
>+    for (addr = addr_list; addr != NULL; addr = addr-&gt;ai_next)
>+    { 
>+        m_iSocket = ::socket(addr-&gt;ai_family, addr-&gt;ai_socktype, addr-&gt;ai_protocol);
>+        if (m_iSocket == -1) continue;
>+    
>+        res = ::bind( m_iSocket , addr-&gt;ai_addr, addr-&gt;ai_addrlen );
>+        if (res != -1) break; /* Connection established */
>+    }
>+    
>+	if( addr == NULL )
> 	{
>-		error("Socket creation failed for %s!", m_pNetAddress-&gt;GetHost() );
>+		error("Socket creation or binding failed for %s!", m_pNetAddress-&gt;GetHost() );
> 		return -1;
> 	}
> 	
>-	memset(&amp;m_SocketAddress, '\0', sizeof(m_SocketAddress));
>-	m_SocketAddress.sin_family = AF_INET;
>-	m_SocketAddress.sin_addr.s_addr = htonl(INADDR_ANY);
>-	m_SocketAddress.sin_port = htons( m_pNetAddress-&gt;GetPort() );
>-
>-	if( bind( m_iSocket, (struct sockaddr *) &amp;m_SocketAddress, sizeof(m_SocketAddress)) &lt; 0)
>-	{
>-		error( "binding socket failed for %s!", m_pNetAddress-&gt;GetHost() );
>-		return -1;
>-	}
>+    freeaddrinfo( addr_list ); /* No longer needed */
> 
> 	if( listen( m_iSocket, 10 ) &lt; 0 )
> 	{
>diff -Naur nzbget-0.2.3/Connection.h nzbget-0.2.3-ipv6/Connection.h
>--- nzbget-0.2.3/Connection.h   2005-09-02 09:00:41.000000000 +0200
>+++ nzbget-0.2.3-ipv6/Connection.h      2008-01-27 14:21:37.000000000 +0100
>@@ -42,7 +42,6 @@
> class Connection
> {
> protected:
>-       struct sockaddr_in      m_SocketAddress;
>        NetAddress*             m_pNetAddress;
>        int                                     m_iSocket;
>        int                                     m_iStatus;
></PRE></BODY></HTML>
Comment 3 Jakub Moc (RETIRED) gentoo-dev 2008-01-27 13:25:52 UTC
Did you submit the upstream? (BTW, 0.3.0 was released last November).
Comment 4 Maik Nijhuis 2008-01-27 13:26:18 UTC
Created attachment 141877 [details, diff]
Better patch
Comment 5 Maik Nijhuis 2008-01-27 23:39:47 UTC
Yes, I submitted it upstream and I saw 0.3.0 is out. The patch may also be applicable to 0.3.0, as it uses a similar Connection class. I didn't try 0.3.0.
Comment 6 Maik Nijhuis 2008-02-01 14:26:08 UTC
Created attachment 142397 [details, diff]
Better patch

Had to remove one more line that wasn't used to make it work.
Comment 7 Maik Nijhuis 2008-02-01 14:44:15 UTC
Created attachment 142402 [details]
ebuild that uses the ipv6 patch

Added one epatch line to nzbget-0.2.3-r1.ebuild
Comment 8 Sven Wegener gentoo-dev 2008-06-07 21:30:57 UTC
0.2.3 is no longer in the tree, and such feature requests belong more to the uptsream bug tracker than to a distribution.
Comment 9 Chris Carlin 2008-07-15 20:32:44 UTC
See Bug #231740 for a patch for the current version of nzbget.