Package: klibido
Version: 0.2.5-6
Severity: wishlist
Tags: patch
klibido lacks support for IPv6.
The attached patch adds a name lookup for an IPv6 address if no
IPv4 address is found.
Since the protocol autodetection of QSocketDevice does not work in
this scenario, we need to recreate the socket with specified protocol
(and save the IPv6 state for the thread in case of reconnects).
Regards,
Martin
--- klibido-0.2.5.orig/src/nntpthreadsocket.cpp
+++ klibido-0.2.5/src/nntpthreadsocket.cpp
@@ -26,6 +26,7 @@
#include assert.h
#include netdb.h
#include sys/poll.h
+#include arpa/inet.h
#include queueparts.h
@@ -241,24 +242,39 @@
}
ha.setAddress(addrList[0]);
*/
+ QString s;
+ char tempstr[64];
hostent *he=gethostbyname(nHost-hostName );
if (!he) {
- qDebug(Cannot resolve hostname);
- errorString=Cannot resolve + nHost-hostName;
- error=NntpThreadSocket::Comm_Err;
- reset();
- return false;
- }
- QString address=QString::number( (unsigned char) he-h_addr[0]);
- QString s;
-
- for (int i = 1; i he-h_length; i++) {
- address+='.' + QString::number( (unsigned char) he-h_addr[i]);
+ // possibly IPV6
+ he = gethostbyname2(nHost-hostName, AF_INET6);
+ if (he) {
+ // IPV6 lookup successful
+
+ // extra v6 socket (assigning v6 address to a standard socket leads to errors)
+ // not needed for reconnects
+ if ( false == useIPv6 ) {
+kes-close();
+delete kes;
+kes = new QSocketDevice(QSocketDevice::Stream, QSocketDevice::IPv6, 0);
+useIPv6 = true;
+ }
+
+ inet_ntop(AF_INET6, he-h_addr, tempstr, 64);
+ ha.setAddress(tempstr);
+ } else {
+ qDebug(Cannot resolve hostname);
+ errorString=Cannot resolve + nHost-hostName;
+ error=NntpThreadSocket::Comm_Err;
+ reset();
+ return false;
}
-
-// qDebug(Address: %s, (const char *) address);
- ha.setAddress(address);
-
+ } else {
+ // IPv4
+ inet_ntop(AF_INET, he-h_addr, tempstr, 64);
+ ha.setAddress(tempstr);
+ }
+// qDebug(Address: %s, ha.toString().latin1());
/*
//Debug!
qDebug(Connecting);
@@ -363,7 +379,11 @@
error=NntpThreadSocket::Comm_Err;
kes-close();
delete kes;
- kes = new QSocketDevice(QSocketDevice::Stream);
+ if ( useIPv6 ) {
+kes = new QSocketDevice(QSocketDevice::Stream, QSocketDevice::IPv6, 0);
+ } else {
+kes = new QSocketDevice(QSocketDevice::Stream);
+ }
kes-setBlocking(true);
isLoggedIn=false;
watermark=buffer;
@@ -382,7 +402,11 @@
qDebug(Bad response to the \user\ cmd);
kes-close();
delete kes;
- kes = new QSocketDevice(QSocketDevice::Stream);
+ if ( useIPv6 ) {
+kes = new QSocketDevice(QSocketDevice::Stream, QSocketDevice::IPv6, 0);
+ } else {
+kes = new QSocketDevice(QSocketDevice::Stream);
+ }
kes-setBlocking(true);
isLoggedIn=false;
watermark=buffer;
@@ -1778,7 +1802,7 @@
cancel=false;
pause=false;
status=Ready;
-
+ useIPv6 = false;
lineBufSize=1000;
line=new char[lineBufSize];
@@ -2234,7 +2266,11 @@
{
kes-close();
delete kes;
- kes = new QSocketDevice(QSocketDevice::Stream);
+ if ( useIPv6 ) {
+ kes = new QSocketDevice(QSocketDevice::Stream, QSocketDevice::IPv6, 0);
+ } else {
+ kes = new QSocketDevice(QSocketDevice::Stream);
+ }
isLoggedIn=false;
// *status=NntpThreadSocket::Ready;
watermark=buffer; //buffer emptyied :)
--- klibido-0.2.5.orig/src/nntpthreadsocket.h
+++ klibido-0.2.5/src/nntpthreadsocket.h
@@ -238,6 +238,7 @@
void setHost(NntpHost *nh);
bool m_sendCmd( QString cmd, int response );
QTime prevTime, currentTime;
+ bool useIPv6;
public:
@@ -257,10 +258,6 @@
void tPause();
void tResume();
void tStart();
-
-
-
-
};
___
pkg-kde-extras mailing list
pkg-kde-extras@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/pkg-kde-extras