Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 141877 Details for
Bug 207668
net-nntp/nzbget-0.2.3: Added IPv6 support
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Better patch
nzbget-0.2.3-ipv6.patch (text/plain), 4.41 KB, created by
Maik Nijhuis
on 2008-01-27 13:26:18 UTC
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Maik Nijhuis
Created:
2008-01-27 13:26:18 UTC
Size:
4.41 KB
patch
obsolete
>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->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(&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->GetPort()); >+ >+ res = ::getaddrinfo( m_pNetAddress->GetHost(), iPortStr, &addr_hints, &addr_list ); >+ >+ if( res != 0 ) > { > error( "Could not resolve hostname %s", m_pNetAddress->GetHost() ); > return -1; > } > >- memset(&m_SocketAddress, '\0', sizeof(m_SocketAddress)); >- m_SocketAddress.sin_family = AF_INET; >- memcpy(&m_SocketAddress.sin_addr.s_addr, hinfo->h_addr_list[0], sizeof(m_SocketAddress.sin_addr.s_addr)); >- m_SocketAddress.sin_port = htons( m_pNetAddress->GetPort() ); >- >- m_iSocket = ::socket(PF_INET,SOCK_STREAM,0); >- >- if( m_iSocket < 0 ) >- { >- error("Socket creation failed for %s!", m_pNetAddress->GetHost() ); >- return -1; >- } >- >- int res = ::connect( m_iSocket ,(struct sockaddr *) &m_SocketAddress, sizeof(m_SocketAddress) ); >- >- if (res < 0) >+ for (addr = addr_list; addr != NULL; addr = addr->ai_next) >+ { >+ m_iSocket = ::socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); >+ if (m_iSocket == -1) continue; >+ >+ res = ::connect( m_iSocket , addr->ai_addr, addr->ai_addrlen ); >+ if (res != -1) break; /* Connection established */ >+ } >+ >+ if( addr == NULL ) > { >- error("Connection to %s failed!", m_pNetAddress->GetHost() ); >+ error("Socket creation or connection failed for %s!", m_pNetAddress->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->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(&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->GetPort()); >+ >+ res = ::getaddrinfo( m_pNetAddress->GetHost(), iPortStr, &addr_hints, &addr_list ); >+ >+ if( res != 0 ) > { > error( "Could not resolve hostname %s", m_pNetAddress->GetHost() ); > return -1; > } > >- m_iSocket = ::socket( PF_INET, SOCK_STREAM, 0 ); >- >- if( m_iSocket < 0 ) >+ for (addr = addr_list; addr != NULL; addr = addr->ai_next) >+ { >+ m_iSocket = ::socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); >+ if (m_iSocket == -1) continue; >+ >+ res = ::bind( m_iSocket , addr->ai_addr, addr->ai_addrlen ); >+ if (res != -1) break; /* Connection established */ >+ } >+ >+ if( addr == NULL ) > { >- error("Socket creation failed for %s!", m_pNetAddress->GetHost() ); >+ error("Socket creation or binding failed for %s!", m_pNetAddress->GetHost() ); > return -1; > } > >- memset(&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->GetPort() ); >- >- if( bind( m_iSocket, (struct sockaddr *) &m_SocketAddress, sizeof(m_SocketAddress)) < 0) >- { >- error( "binding socket failed for %s!", m_pNetAddress->GetHost() ); >- return -1; >- } >+ freeaddrinfo( addr_list ); /* No longer needed */ > > if( listen( m_iSocket, 10 ) < 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;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 207668
:
141875
|
141877
|
142397
|
142402